def agent(sweep_id, function=None, entity=None, project=None, count=None): """Generic agent entrypoint, used for CLI or jupyter. Args: sweep_id (dict): Sweep ID generated by CLI or sweep API function (func, optional): A function to call instead of the "program" specifed in the config entity (str, optional): W&B Entity project (str, optional): W&B Project count (int, optional): the number of trials to run. """ in_jupyter = wandb._get_python_type() != "python" if in_jupyter: os.environ[wandb.env.JUPYTER] = "true" _api0 = InternalApi() if not _api0.api_key: wandb._jupyter_login(api=_api0) _ = wandb.Settings() return run_agent( sweep_id, function=function, in_jupyter=in_jupyter, entity=entity, project=project, count=count, )
def sweep(sweep, entity=None, project=None): from wandb.sweeps.config import SweepConfig import types if isinstance(sweep, types.FunctionType): sweep = sweep() if isinstance(sweep, SweepConfig): sweep = dict(sweep) """Sweep create for controller api and jupyter (eventually for cli).""" in_jupyter = wandb._get_python_type() != "python" if in_jupyter: os.environ[env.JUPYTER] = "true" _api0 = InternalApi() if not _api0.api_key: wandb._jupyter_login(api=_api0) if entity: env.set_entity(entity) if project: env.set_project(project) api = InternalApi() sweep_id = api.upsert_sweep(sweep) print('Create sweep with ID:', sweep_id) sweep_url = _get_sweep_url(api, sweep_id) if sweep_url: print('Sweep URL:', sweep_url) return sweep_id
def agent(sweep_id, function=None, entity=None, project=None): """Generic agent entrypoint, used for CLI or jupyter. Args: sweep_id (dict): Sweep ID generated by CLI or sweep API entity (str, optional): W&B Entity project (str, optional): W&B Project function (dict, optional): Configure sweep function """ in_jupyter = wandb._get_python_type() != "python" if in_jupyter: os.environ[env.JUPYTER] = "true" _api0 = InternalApi() if not _api0.api_key: wandb._jupyter_login(api=_api0) return run_agent(sweep_id, function=function, in_jupyter=in_jupyter, entity=entity, project=project)