コード例 #1
0
def test_runs_sweeps(request_mocker):
    """Request a bunch of runs from different sweeps at the same time.
    Ensure each run's sweep attribute is set to the appropriate value.
    """
    api = Api()
    run_responses = [random_run_response() for _ in range(7)]
    sweep_a_response = random_sweep_response()
    sweep_b_response = random_sweep_response()
    run_responses[0]['sweepName'] = sweep_b_response['name']
    run_responses[1]['sweepName'] = sweep_a_response['name']
    run_responses[3]['sweepName'] = sweep_b_response['name']
    run_responses[4]['sweepName'] = sweep_a_response['name']
    run_responses[5]['sweepName'] = sweep_b_response['name']
    run_responses[6]['sweepName'] = sweep_b_response['name']

    runs_response = {
        'project': {
            'runCount': len(run_responses),
            'runs': {
                'pageInfo': {
                    'hasNextPage': False
                },
                'edges': [{
                    'node': r,
                    'cursor': 'cursor'
                } for r in run_responses],
            }
        }
    }
    mock_graphql_request(request_mocker,
                         runs_response,
                         body_match='query Runs')
    mock_graphql_request(request_mocker,
                         {'project': {
                             'sweep': sweep_a_response
                         }},
                         body_match=sweep_a_response['name'])
    mock_graphql_request(request_mocker,
                         {'project': {
                             'sweep': sweep_b_response
                         }},
                         body_match=sweep_b_response['name'])

    runs = list(api.runs('test/test'))
    sweep_a = runs[1].sweep
    sweep_b = runs[0].sweep
    assert len(runs) == len(run_responses)
    assert sweep_a.runs == [runs[1], runs[4]]
    assert sweep_b.runs == [runs[0], runs[3], runs[5], runs[6]]
    assert runs[0].sweep is sweep_b
    assert runs[1].sweep is sweep_a
    assert runs[2].sweep is None
    assert runs[3].sweep is sweep_b
    assert runs[4].sweep is sweep_a
    assert runs[5].sweep is sweep_b
    assert runs[6].sweep is sweep_b
コード例 #2
0
def arena_launcher_op(image,
                      command,
                      job_type="tfjob",
                      gpus=0,
                      env=[],
                      workers=1,
                      logdir=None,
                      parameter_servers=0,
                      ps_image=None,
                      timeout_minutes=10,
                      sync_source=None,
                      name=None,
                      namespace=None,
                      wandb_project=None,
                      wandb_run_id=None):
    from kfp import dsl
    from kubernetes import client as k8s_client
    options = []
    if name:
        options.append('--name=' + name)
    if logdir:
        options.append('--logdir=' + logdir)
    if sync_source:
        if not sync_source.startswith("http"):
            raise ValueError("sync_source must be an http git url")
        options.append('--syncMode=git')
        options.append('--syncSource=' + sync_source)
    if namespace:
        options.append('--namespace=' + namespace)
    if wandb_project:
        options.append('--wandb-project=' + wandb_project)
    if wandb_run_id:
        options.append('--wandb-run-id=' + wandb_run_id)
    if ps_image:
        options.append('--psImage=' + ps_image)
    if gpus:
        options.append('--gpus=' + str(gpus))
    for e in env:
        options.append('--env=' + e)
    op = dsl.ContainerOp(name=name or "wandb-arena",
                         image='wandb/arena',
                         arguments=[
                             "submit",
                             job_type,
                             '--workers=' + str(workers),
                             '--ps=' + str(parameter_servers),
                             '--timeout-minutes=' + str(timeout_minutes),
                             '--image=' + image,
                         ] + options + [" ".join(command)],
                         file_outputs={
                             'train': '/output.txt',
                             'wandb': '/wandb.txt'
                         })
    key = Api().api_key
    if key is None:
        raise ValueError("Not logged into W&B, run `wandb login`")
    op.add_env_variable(k8s_client.V1EnvVar(name='WANDB_API_KEY', value=key))
    return op
コード例 #3
0
def wait_pending_artifact(api: wandb.Api, name: str, type: str = None) -> wandb_api.Artifact:
    # Source: https://github.com/wandb/client/issues/1486
    while True:
        try:
            return api.artifact(name, type)
        except wandb.errors.error.CommError:
            # Back-off and retry
            time.sleep(5)
            pass
コード例 #4
0
def test_api_auto_login_no_tty(mocker):
    with pytest.raises(wandb.UsageError):
        Api()
コード例 #5
0
def api(runner):
    return Api()
コード例 #6
0
from wandb import Api
import pandas as pd
from tqdm import tqdm
import matplotlib.pyplot as plt
plt.rcParams.update({'font.size': 18, 'legend.fontsize': 14})

api = Api()

runs = api.runs(
    "jeppe742/language-of-molecules-graph", {
        '$and': [{
            'config.model': 'Transformer'
        }, {
            'config.num_layers': 4
        }, {
            'config.edge_encoding': 1
        }, {
            'config.dataset': 'qm9'
        }, {
            'tags': {
                "$ne": "old"
            }
        }]
    })

df = None
for run in tqdm(runs):
    df_temp = run.history()
    #df_temp['Attention'] = run.config['edge_encoding'] if isinstance(run.config['edge_encoding'], int) else run.config['edge_encoding']['value']
    df_temp['dataset'] = run.config['dataset']
    df_temp['epsilon_greedy'] = run.config['epsilon_greedy'] if isinstance(
コード例 #7
0
import pytest
import os
import yaml
import tempfile
from .api_mocks import *
from click.testing import CliRunner
import git
import json
from .utils import git_repo, runner
import h5py
import numpy as np

import wandb
from wandb import Api
from six import StringIO
api = Api()


def test_parse_path_simple():
    u, p, r = api._parse_path("user/proj/run")
    assert u == "user"
    assert p == "proj"
    assert r == "run"


def test_parse_path_leading():
    u, p, r = api._parse_path("/user/proj/run")
    assert u == "user"
    assert p == "proj"
    assert r == "run"
コード例 #8
0
ファイル: test_public_api.py プロジェクト: ayulockin/client
def test_base_url_sanitization(runner):
    api = Api({"base_url": "https://wandb.corp.net///"})
    assert api.settings["base_url"] == "https://wandb.corp.net"