示例#1
0
 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)
示例#2
0
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)
示例#3
0
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)
示例#4
0
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
    )
示例#5
0
 def __init__(self, sleep_interval=None):
     self.sleep_interval = sleep_interval
     self.spawner = Spawner()
     self.client = PolyaxonClient()
     self._graceful_shutdown = False
示例#6
0
 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)
示例#7
0
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)
示例#8
0
    def setUp(self):

        self.spawner = Spawner()
        super().setUp()