Example #1
0
def execute_command():
    """ Runs the deploy command """

    parser = ArgumentParser()

    parser.description = cli.reformat(DESCRIPTION)

    parser.add_argument(
        'deploy',
        type=str,
        help='The deploy command to execute'
    )

    parser.add_argument(
        'root_path',
        type=str,
        help=cli.reformat("""
            The folder in the S3 bucket where your files will be uploaded
            """)
    )

    parser.add_argument(
        '-p', '--profile',
        dest='profile',
        type=str,
        default=None,
        help=cli.reformat("""
            The name of the AWS credentials profile to use for access to the
            AWS S3 bucket resources
            """)
    )

    parser.add_argument(
        '-b', '--bucket',
        dest='bucket',
        type=str,
        default=None,
        help=cli.reformat("""
            The name of the S3 bucket where the files will be uploaded
            """)
    )

    args = vars(parser.parse_args())
    configs = system.load_configs()

    upload_in_folder(
        get_aws_settings(configs, **args),
        paths.results('report')
    )
    system.log('[COMPLETE]: Trials have been deployed')
Example #2
0
def run(**kwargs):
    """

    :param kwargs:
    :return:
    """

    cli_configs = kwargs.get('settings')
    if cli_configs is None:
        cli_configs = system.load_configs()

    path = get_path(kwargs.get('path'), cli_configs)
    if path is None:
        system.log('ERROR: Invalid or missing path argument')
        sys.exit(1)

    urls = []

    if os.path.isfile(path):
        with open(path, 'r+') as f:
            data = json.load(f)

        urls.append(run_simulation(
            is_group=bool('trials' in data),
            cli_configs=cli_configs,
            settings_path=path,
            **kwargs
        ))

    else:
        group_paths = find_group_files(path)
        if not kwargs.get('run_all_groups'):
            group_paths = group_paths[0:1]

        for p in group_paths:
            urls.append(run_simulation(
                is_group=True,
                cli_configs=cli_configs,
                settings_path=p,
                **kwargs
            ))

    save_recent_path(kwargs.get('path'), cli_configs)
    print_results(urls)
def execute_command():
    """

    :return:
    """

    parser = ArgumentParser()

    parser.description = cli.reformat(DESCRIPTION)

    parser.add_argument(
        'generate_command',
        type=str,
        help='The generate command itself'
    )

    parser.add_argument(
        'trial_or_group',
        type=str,
        help='Path to a trial or group file where the data source is specified'
    )

    parser.add_argument(
        'output_filename',
        type=str,
        help='Name of the csv file to be created'
    )

    args = parser.parse_args()
    cli_configs = system.load_configs()

    path = get_path(args.trial_or_group, cli_configs)
    if path is None:
        system.log('ERROR: Invalid or missing trial/group path')
        sys.exit(1)

    settings = configs.load(None, path)
    out_path = os.path.join(settings['directory'], args.output_filename)

    simulate.load_trackway_positions(
        settings,
        save_as=out_path
    )
Example #4
0
def project(*args: typing.List[str], configs_override: str = None) -> str:
    """
    Creates an absolute path to a file or folder within the trackway gait
    analysis project using the relative path elements specified by the args.

    :param args:
        Zero or more relative path elements that describe a file or folder
        within the project

    :param configs_override:
        An optional key within the tracksim configuration file where an
        override path can be supplied. If omitted, the path will default to the
        internal location within the source project
    """

    if configs_override:
        path = system.load_configs().get(configs_override)
        if path is not None:
            return clean(os.path.join(path, *args))

    return clean(os.path.join(MY_PATH, "..", *args))
def execute_command():
    """ Runs the configure command """

    parser = ArgumentParser()
    parser.description = cli.reformat(DESCRIPTION)

    parser.add_argument(
        'configure',
        type=str,
        help='The configure command to execute'
    )

    parser.add_argument(
        'key',
        type=str,
        nargs='?',
        default=None,
        help=cli.reformat("""
            The configuration key to be modify
            """)
    )

    parser.add_argument(
        'value',
        type=str,
        nargs='*',
        default=None,
        help=cli.reformat("""
            The value to assign to the configuration key. If omitted, the
            currently stored value for this key will be displayed.
            """)
    )

    parser.add_argument(
        '-r', '--remove',
        dest='remove',
        action='store_true',
        default=False,
        help=cli.reformat("""
            When included, this flag indicates that the specified key should
            be removed from the tracksim configs file.
            """)
    )

    parser.add_argument(
        '-l', '--list',
        dest='list',
        action='store_true',
        default=False,
        help=cli.reformat("""
            This flag is only useful when no key and no value have been
            specified. In such a case, this command will list all keys and
            values currently stored in the configuration file.
            """)
    )

    args = vars(parser.parse_args())

    configs = system.load_configs()
    if args['key'] is None:
        if args['list']:
            echo_all(configs)
        else:
            parser.print_help()
    elif len(args['value']) < 1:
        if args['remove']:
            remove_key(configs, args['key'])
        else:
            echo_key(configs, args['key'])
    else:
        set_key(configs, args['key'], args['value'])

    system.end(0)