Beispiel #1
0
def run(ctx, file, description, u):  # pylint:disable=redefined-builtin
    """Run polyaxonfile specification.

    Example:

    \b
    ```bash
    $ polyaxon run -f file -f file_override ...
    ```

    Example: upload before running

    \b
    ```bash
    $ polyaxon run -f file -u
    ```

    """
    file = file or 'polyaxonfile.yml'
    specification = check_polyaxonfile(file, log=False).specification

    # Check if we need to upload
    if u:
        ctx.invoke(upload, async=False)

    project = ProjectManager.get_config_or_raise()
    project_client = PolyaxonClients().project

    if specification.is_experiment:
        click.echo('Creating an independent experiment.')
        experiment = ExperimentConfig(
            description=description,
            config=specification.parsed_data)
        try:
            project_client.create_experiment(project.user,
                                             project.name,
                                             experiment)
        except (PolyaxonHTTPError, PolyaxonShouldExitError) as e:
            Printer.print_error('Could not create experiment.')
            Printer.print_error('Error message `{}`.'.format(e))
            sys.exit(1)
        Printer.print_success('Experiment was created')
    else:
        click.echo('Creating an experiment group with the following definition:')
        experiments_def = specification.experiments_def
        get_group_experiments_info(**experiments_def)
        experiment_group = ExperimentGroupConfig(
            description=description,
            content=specification._data)  # pylint:disable=protected-access
        try:
            project_client.create_experiment_group(project.user,
                                                   project.name,
                                                   experiment_group)
            Printer.print_success('Experiment group was created')
        except (PolyaxonHTTPError, PolyaxonShouldExitError) as e:
            Printer.print_error('Could not create experiment group.')
            Printer.print_error('Error message `{}`.'.format(e))
            sys.exit(1)
Beispiel #2
0
def run(file, description):
    """Command for running polyaxonfile specification.

    Example:

    ```
    polyaxon run -f file -f file_override ...
    ```
    """
    file = file or 'polyaxonfile.yml'
    plx_file = check_polyaxonfile(file)
    num_experiments, concurrency = plx_file.experiments_def
    project = get_current_project_or_exit()
    project_client = PolyaxonClients().project
    if num_experiments == 1:
        click.echo('Creating an independent experiment.')
        experiment = ExperimentConfig(
            description=description,
            content=plx_file._data,
            config=plx_file.experiment_specs[0].parsed_data)
        try:
            response = project_client.create_experiment(
                project.user, project.name, experiment)
        except (PolyaxonHTTPError, PolyaxonShouldExitError) as e:
            Printer.print_error('Could not create experiment.')
            Printer.print_error('Error message `{}`.'.format(e))
            sys.exit(1)
        Printer.print_success('Experiment was created')
    else:
        click.echo('Creating an experiment group with {} experiments.'.format(
            num_experiments))
        experiment_group = ExperimentGroupConfig(description=description,
                                                 content=plx_file._data)
        try:
            response = project_client.create_experiment_group(
                project.user, project.name, experiment_group)
            Printer.print_success('Experiment group was created')
        except (PolyaxonHTTPError, PolyaxonShouldExitError) as e:
            Printer.print_error('Could not create experiment group.')
            Printer.print_error('Error message `{}`.'.format(e))
            sys.exit(1)
    response = response.to_dict()
    dict_tabulate(response)