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)
async def notify_run( namespace: str, owner: str, project: str, run_uuid: str, run_name: str, condition: V1StatusCondition, connections: List[str], ): spawner = AsyncSpawner(namespace=namespace) await spawner.k8s_manager.setup() for connection in connections: connection_type = settings.AGENT_CONFIG.connections_by_names.get( connection) if not connection_type: logger.warning( "Could not create notification using connection {}, " "the connection was not found or not set correctly.".format( connection_type)) continue operation = get_notifier_operation( connection=connection, backend=connection_type.kind, owner=owner, project=project, run_uuid=run_uuid, run_name=run_name, condition=condition.to_dict(), ) compiled_operation = OperationSpecification.compile_operation( operation) resource = compiler.make( owner_name=owner, project_name=project, project_uuid=project, run_uuid=run_uuid, run_name=run_name, run_path=run_uuid, compiled_operation=compiled_operation, params=operation.params, converters=PLATFORM_CONVERTERS, ) await spawner.create( run_uuid=run_uuid, run_kind=compiled_operation.get_run_kind(), resource=resource, )
def make_and_convert( owner_name: str, project_name: str, run_uuid: str, run_name: str, content: str, ): operation = OperationSpecification.read(content) compiled_operation = OperationSpecification.compile_operation(operation) return make( owner_name=owner_name, project_name=project_name, project_uuid=project_name, run_uuid=run_uuid, run_name=run_name, run_path=run_uuid, compiled_operation=compiled_operation, params=None, )
def make_and_convert( owner_name: str, project_name: str, run_uuid: str, run_name: str, content: str, default_auth: bool = False, ): operation = OperationSpecification.read(content) compiled_operation = OperationSpecification.compile_operation(operation) return make( owner_name=owner_name, project_name=project_name, project_uuid=project_name, run_uuid=run_uuid, run_name=run_name, run_path=run_uuid, compiled_operation=compiled_operation, params=operation.params, converters=PLATFORM_CONVERTERS, default_auth=default_auth, )
async def notify_run( namespace: str, owner: str, project: str, run_uuid: str, run_name: str, condition: V1StatusCondition, connections: List[str], ): spawner = AsyncSpawner(namespace=namespace) await spawner.k8s_manager.setup() for connection in connections: connection_type = settings.AGENT_CONFIG.notification_connections_by_names.get( connection ) if not connection_type: logger.warning( "Could not create notification using connection {}, " "the connection was not found or not set correctly.".format( connection_type ) ) continue operation = V1Operation( params={ "kind": connection_type.kind, "owner": owner, "project": project, "run_uuid": run_uuid, "run_name": run_name, "condition": ujson.dumps(condition.to_dict()), }, termination=V1Termination(max_retries=3), component=V1Component( name="slack-notification", plugins=V1Plugins( auth=False, collect_logs=False, collect_artifacts=False, collect_resources=False, sync_statuses=False, ), inputs=[ V1IO(name="kind", iotype=types.STR, is_optional=False), V1IO(name="owner", iotype=types.STR, is_optional=False), V1IO(name="project", iotype=types.STR, is_optional=False), V1IO(name="run_uuid", iotype=types.STR, is_optional=False), V1IO(name="run_name", iotype=types.STR, is_optional=True), V1IO(name="condition", iotype=types.STR, is_optional=True), V1IO(name="connection", iotype=types.STR, is_optional=True), ], run=V1Notifier( connections=[connection], container=get_default_notification_container(), ), ), ) compiled_operation = OperationSpecification.compile_operation(operation) resource = compiler.make( owner_name=owner, project_name=project, project_uuid=project, run_uuid=run_uuid, run_name=run_name, run_path=run_uuid, compiled_operation=compiled_operation, params=operation.params, ) await spawner.create( run_uuid=run_uuid, run_kind=compiled_operation.get_run_kind(), resource=resource, )