Example #1
0
def resolve(
    owner_name: str,
    project_name: str,
    project_uuid: str,
    run_name: str,
    run_uuid: str,
    run_path: str,
    compiled_operation: V1CompiledOperation,
    params: Optional[Dict[str, Dict]],
    run=None,
    resolver_cls=None,
):
    resolver_cls = resolver_cls or CoreResolver
    run_kind = compiled_operation.get_run_kind()
    if run_kind not in resolver_cls.KINDS:
        raise PolyaxonCompilerError(
            "Specification with run kind: {} is not supported in this deployment version."
            .format(run_kind))

    resolver = resolver_cls(
        run=run,
        compiled_operation=compiled_operation,
        owner_name=owner_name,
        project_name=project_name,
        project_uuid=project_uuid,
        run_name=run_name,
        run_path=run_path,
        run_uuid=run_uuid,
        params=params,
    )
    if resolver:
        return resolver, resolver.resolve()
Example #2
0
def resolve_contexts(
    namespace: str,
    owner_name: str,
    project_name: str,
    project_uuid: str,
    run_uuid: str,
    run_name: str,
    run_path: str,
    compiled_operation: V1CompiledOperation,
    artifacts_store: V1ConnectionType,
    connection_by_names: Dict[str, V1ConnectionType],
    iteration: int,
    created_at: datetime,
    compiled_at: datetime,
    schedule_at: datetime = None,
    started_at: datetime = None,
    finished_at: datetime = None,
    duration: int = None,
    cloning_kind: V1CloningKind = None,
    original_uuid: str = None,
) -> Dict:
    run_kind = compiled_operation.get_run_kind()
    if run_kind not in CONTEXTS_MANAGERS:
        raise PolyaxonCompilerError(
            "Contexts manager Error. "
            "Specification with run kind: {} is not supported in this deployment version".format(
                run_kind
            )
        )

    resolved_contexts = resolve_globals_contexts(
        namespace=namespace,
        owner_name=owner_name,
        project_name=project_name,
        project_uuid=project_uuid,
        run_uuid=run_uuid,
        run_name=run_name,
        run_path=run_path,
        iteration=iteration,
        created_at=created_at,
        compiled_at=compiled_at,
        schedule_at=schedule_at,
        started_at=started_at,
        finished_at=finished_at,
        duration=duration,
        plugins=compiled_operation.plugins,
        artifacts_store=artifacts_store,
        cloning_kind=cloning_kind,
        original_uuid=original_uuid,
    )

    return CONTEXTS_MANAGERS[run_kind].resolve(
        namespace=namespace,
        owner_name=owner_name,
        project_name=project_name,
        run_uuid=run_uuid,
        contexts=resolved_contexts,
        compiled_operation=compiled_operation,
        connection_by_names=connection_by_names,
    )
Example #3
0
 def is_kind_supported(cls, compiled_operation: V1CompiledOperation):
     run_kind = compiled_operation.get_run_kind()
     if run_kind not in cls.KINDS:
         raise PolyaxonCompilerError(
             "Resolver Error. "
             "Specification with run kind: {} "
             "is not supported in this deployment version.".format(run_kind)
         )
Example #4
0
def convert(
    namespace: str,
    owner_name: str,
    project_name: str,
    run_name: str,
    run_uuid: str,
    run_path: str,
    compiled_operation: V1CompiledOperation,
    artifacts_store: Optional[V1ConnectionType],
    connection_by_names: Optional[Dict[str, V1ConnectionType]],
    secrets: Optional[Iterable[V1K8sResourceType]],
    config_maps: Optional[Iterable[V1K8sResourceType]],
    polyaxon_sidecar: V1PolyaxonSidecarContainer = None,
    polyaxon_init: V1PolyaxonInitContainer = None,
    default_sa: str = None,
    converters: Dict[str, Any] = CORE_CONVERTERS,
    internal_auth: bool = False,
    default_auth: bool = False,
) -> Dict:
    if compiled_operation.has_pipeline:
        raise PolyaxonCompilerError(
            "Converter Error. "
            "Specification with matrix/dag/schedule section is not supported in this function."
        )

    run_kind = compiled_operation.get_run_kind()
    if run_kind not in converters:
        raise PolyaxonCompilerError(
            "Converter Error. "
            "Specification with run kind: {} is not supported in this deployment version.".format(
                run_kind
            )
        )

    converter = converters[run_kind](
        owner_name=owner_name,
        project_name=project_name,
        run_name=run_name,
        run_uuid=run_uuid,
        namespace=namespace,
        polyaxon_init=polyaxon_init,
        polyaxon_sidecar=polyaxon_sidecar,
        internal_auth=internal_auth,
        run_path=run_path,
    )
    if converter:
        resource = converter.get_resource(
            compiled_operation=compiled_operation,
            artifacts_store=artifacts_store,
            connection_by_names=connection_by_names,
            secrets=secrets,
            config_maps=config_maps,
            default_sa=default_sa,
            default_auth=default_auth,
        )
        api = k8s_client.ApiClient()
        return api.sanitize_for_serialization(resource)