def create_run(): click.echo("Creating a run.") try: compiled_operation = OperationSpecification.compile_operation( op_spec) run_name = compiled_operation.name or name resource = compiler.make( owner_name=owner, project_name=project_name, project_uuid=project_name, run_uuid=run_name, run_name=name, run_path=run_name, compiled_operation=compiled_operation, params=op_spec.params, default_sa=settings.AGENT_CONFIG.runs_sa, ) Spawner(namespace=settings.AGENT_CONFIG.namespace).create( run_uuid=run_name, run_kind=compiled_operation.get_run_kind(), resource=resource, ) # cache.cache(config_manager=RunConfigManager, response=response) run_job_uid = get_resource_name(run_name) Printer.print_success( "A new run `{}` was created".format(run_job_uid)) except (PolyaxonCompilerError, PolyaxonK8SError, PolypodException) as e: handle_cli_error(e, message="Could not create a run.") sys.exit(1)
def wait(uuid: str, kind: str, max_retries: int): """Delete an s3 subpath.""" from polyaxon import settings from polyaxon.agents.spawners.spawner import Spawner spawner = Spawner(namespace=settings.CLIENT_CONFIG.namespace, in_cluster=True) retry = 1 while retry < max_retries: try: k8s_operation = spawner.get(run_uuid=uuid, run_kind=kind) except: # noqa k8s_operation = None if k8s_operation: retry += 1 time.sleep(retry) else: return sys.exit(1)
def apply( content: str, owner_name: str, project_name: str, run_name: str, run_kind: str, run_uuid: str, namespace: str, in_cluster: bool = None, ): resource = converter.convert( owner_name=owner_name, project_name=project_name, run_name=run_name, run_uuid=run_uuid, content=content, ) Spawner(namespace=namespace, in_cluster=in_cluster).apply(run_uuid=run_uuid, run_kind=run_kind, resource=resource)
def start( content: str, owner_name: str, project_name: str, run_name: str, run_kind: str, run_uuid: str, namespace: str, in_cluster: bool = None, default_auth: bool = False, ): resource = converter.convert( owner_name=owner_name, project_name=project_name, run_name=run_name, run_uuid=run_uuid, content=content, default_auth=default_auth, ) Spawner(namespace=namespace, in_cluster=in_cluster).create( run_uuid=run_uuid, run_kind=run_kind, resource=resource )
def __init__(self, sleep_interval=None): self.sleep_interval = sleep_interval self.spawner = Spawner() self.client = PolyaxonClient() self._graceful_shutdown = False
def __init__(self, sleep_interval=None): self.sleep_interval = sleep_interval self.spawner = Spawner() self.client = PolyaxonClient() self._graceful_shutdown = False self.content = settings.AGENT_CONFIG.to_dict(dump=True)
def clean(run_kind: str, run_uuid: str, namespace: str, in_cluster: bool = None): Spawner(namespace=namespace, in_cluster=in_cluster).clean(run_uuid=run_uuid, run_kind=run_kind)
def setUp(self): self.spawner = Spawner() super().setUp()