Exemplo n.º 1
0
def get_experiment_details(experiment):  # pylint:disable=redefined-outer-name
    if experiment.description:
        Printer.print_header("Experiment description:")
        click.echo('{}\n'.format(experiment.description))

    if experiment.resources:
        get_resources(experiment.resources.to_dict(),
                      header="Experiment resources:")

    if experiment.params:
        Printer.print_header("Experiment params:")
        dict_tabulate(experiment.params)

    if experiment.last_metric:
        Printer.print_header("Experiment last metrics:")
        dict_tabulate(experiment.last_metric)

    response = experiment.to_light_dict(humanize_values=True,
                                        exclude_attrs=[
                                            'uuid', 'config', 'project',
                                            'experiments', 'description',
                                            'params', 'last_metric',
                                            'resources', 'jobs', 'run_env'
                                        ])

    Printer.print_header("Experiment info:")
    dict_tabulate(Printer.add_status_color(response))
Exemplo n.º 2
0
def get_build_details(_build):
    if _build.description:
        Printer.print_header("Build description:")
        click.echo('{}\n'.format(_build.description))

    if _build.resources:
        get_resources(_build.resources.to_dict(), header="Build resources:")

    response = _build.to_light_dict(
        humanize_values=True,
        exclude_attrs=[
            'uuid', 'content', 'project', 'description', 'resources', 'is_clone', 'build_job'
        ])

    Printer.print_header("Build info:")
    dict_tabulate(Printer.add_status_color(response))
Exemplo n.º 3
0
def get_job_details(_job):
    if _job.description:
        Printer.print_header("Job description:")
        click.echo('{}\n'.format(_job.description))

    if _job.resources:
        get_resources(_job.resources.to_dict(), header="Job resources:")

    response = _job.to_light_dict(humanize_values=True,
                                  exclude_attrs=[
                                      'uuid',
                                      'content',
                                      'project',
                                      'description',
                                      'resources',
                                  ])

    Printer.print_header("Job info:")
    dict_tabulate(Printer.add_status_color(response))
Exemplo n.º 4
0
def get(ctx):
    """Get job.

    Uses [Caching](/polyaxon_cli/introduction#Caching)

    Examples:

    \b
    ```bash
    $ polyaxon job --job=1 --experiment=1 get
    ```

    \b
    ```bash
    $ polyaxon job --job=1 --project=project_name get
    ```
    """
    user, project_name, experiment, _job = get_job_or_local(
        ctx.obj['project'], ctx.obj['experiment'], ctx.obj['job'])
    try:
        response = PolyaxonClients().job.get_job(user, project_name,
                                                 experiment, _job)
        # Set caching only if we have an initialized project
        if ProjectManager.is_initialized():
            JobManager.set_config(response)
    except (PolyaxonHTTPError, PolyaxonShouldExitError) as e:
        Printer.print_error('Could not get job `{}`.'.format(_job))
        Printer.print_error('Error message `{}`.'.format(e))
        sys.exit(1)

    if response.resources:
        get_resources(response.resources.to_dict(), header="Job resources:")

    response = Printer.add_status_color(
        response.to_light_dict(humanize_values=True,
                               exclude_attrs=[
                                   'uuid', 'definition', 'experiment',
                                   'unique_name', 'resources'
                               ]))
    Printer.print_header("Job info:")
    dict_tabulate(response)
Exemplo n.º 5
0
    def get_experiment_job():
        try:
            response = PolyaxonClient().experiment_job.get_job(user,
                                                               project_name,
                                                               _experiment,
                                                               _job)
            cache.cache(config_manager=ExperimentJobManager, response=response)
        except (PolyaxonHTTPError, PolyaxonShouldExitError, PolyaxonClientException) as e:
            Printer.print_error('Could not get job `{}`.'.format(_job))
            Printer.print_error('Error message `{}`.'.format(e))
            sys.exit(1)

        if response.resources:
            get_resources(response.resources.to_dict(), header="Job resources:")

        response = Printer.add_status_color(response.to_light_dict(
            humanize_values=True,
            exclude_attrs=['uuid', 'definition', 'experiment', 'unique_name', 'resources']
        ))
        Printer.print_header("Job info:")
        dict_tabulate(response)