Example #1
0
def get_mpi_job_custom_resource(
    resource_name: str,
    namespace: str,
    launcher: Optional[ReplicaSpec],
    worker: Optional[ReplicaSpec],
    termination: V1Termination,
    collect_logs: bool,
    sync_statuses: bool,
    notifications: List[V1Notification],
    clean_pod_policy: Optional[str],
    slots_per_worker: Optional[int],
    labels: Dict[str, str],
    annotations: Dict[str, str],
) -> Dict:
    template_spec = {}

    get_kf_replicas_template(
        replica_name="Launcher",
        replica=launcher,
        namespace=namespace,
        resource_name=resource_name,
        labels=labels,
        annotations=annotations,
        template_spec=template_spec,
    )
    get_kf_replicas_template(
        replica_name="Worker",
        replica=worker,
        namespace=namespace,
        resource_name=resource_name,
        labels=labels,
        annotations=annotations,
        template_spec=template_spec,
    )
    template_spec = {"replicaSpecs": template_spec}

    template_spec = set_clean_pod_policy(template_spec=template_spec,
                                         clean_pod_policy=clean_pod_policy)
    template_spec = set_slots_per_worker(template_spec=template_spec,
                                         slots_per_worker=slots_per_worker)

    custom_object = {"mpiJobSpec": template_spec}
    custom_object = set_termination(custom_object=custom_object,
                                    termination=termination)
    custom_object = set_collect_logs(custom_object=custom_object,
                                     collect_logs=collect_logs)
    custom_object = set_sync_statuses(custom_object=custom_object,
                                      sync_statuses=sync_statuses)
    custom_object = set_notify(custom_object=custom_object,
                               notifications=notifications)

    return get_operation_custom_object(
        namespace=namespace,
        resource_name=resource_name,
        labels=labels,
        annotations=annotations,
        custom_object=custom_object,
    )
Example #2
0
def get_pytorch_job_custom_resource(
    resource_name: str,
    namespace: str,
    master: Optional[ReplicaSpec],
    worker: Optional[ReplicaSpec],
    termination: V1Termination,
    collect_logs: bool,
    sync_statuses: bool,
    notifications: List[V1Notification],
    clean_pod_policy: Optional[str],
    labels: Dict[str, str],
) -> Dict:
    template_spec = {}

    get_kf_replicas_template(
        replica_name="Master",
        replica=master,
        namespace=namespace,
        resource_name=resource_name,
        labels=labels,
        template_spec=template_spec,
    )
    get_kf_replicas_template(
        replica_name="Worker",
        replica=worker,
        namespace=namespace,
        resource_name=resource_name,
        labels=labels,
        template_spec=template_spec,
    )

    template_spec = set_clean_pod_policy(
        template_spec=template_spec, clean_pod_policy=clean_pod_policy
    )

    custom_object = {"pytorchJobSpec": template_spec}
    custom_object = set_termination(
        custom_object=custom_object, termination=termination
    )
    custom_object = set_collect_logs(
        custom_object=custom_object, collect_logs=collect_logs
    )
    custom_object = set_sync_statuses(
        custom_object=custom_object, sync_statuses=sync_statuses
    )
    custom_object = set_notify(custom_object=custom_object, notifications=notifications)

    return get_operation_custom_object(
        namespace=namespace,
        resource_name=resource_name,
        labels=labels,
        custom_object=custom_object,
    )
Example #3
0
def get_tf_job_custom_resource(
    resource_name: str,
    namespace: str,
    chief: Optional[ReplicaSpec],
    worker: Optional[ReplicaSpec],
    ps: Optional[ReplicaSpec],
    evaluator: Optional[ReplicaSpec],
    termination: V1Termination,
    collect_logs: bool,
    sync_statuses: bool,
    notifications: List[V1Notification],
    clean_pod_policy: Optional[str],
    labels: Dict[str, str],
    annotations: Dict[str, str],
) -> Dict:
    template_spec = {}

    get_kf_replicas_template(
        replica_name="Chief",
        replica=chief,
        namespace=namespace,
        resource_name=resource_name,
        labels=labels,
        template_spec=template_spec,
    )
    get_kf_replicas_template(
        replica_name="Worker",
        replica=worker,
        namespace=namespace,
        resource_name=resource_name,
        labels=labels,
        template_spec=template_spec,
    )
    get_kf_replicas_template(
        replica_name="PS",
        replica=ps,
        namespace=namespace,
        resource_name=resource_name,
        labels=labels,
        template_spec=template_spec,
    )
    get_kf_replicas_template(
        replica_name="Evaluator",
        replica=evaluator,
        namespace=namespace,
        resource_name=resource_name,
        labels=labels,
        template_spec=template_spec,
    )
    template_spec = {"replicaSpecs": template_spec}

    template_spec = set_clean_pod_policy(
        template_spec=template_spec, clean_pod_policy=clean_pod_policy
    )

    custom_object = {"tfJobSpec": template_spec}
    custom_object = set_termination(
        custom_object=custom_object, termination=termination
    )
    custom_object = set_collect_logs(
        custom_object=custom_object, collect_logs=collect_logs
    )
    custom_object = set_sync_statuses(
        custom_object=custom_object, sync_statuses=sync_statuses
    )
    custom_object = set_notify(custom_object=custom_object, notifications=notifications)

    return get_operation_custom_object(
        namespace=namespace,
        resource_name=resource_name,
        labels=labels,
        annotations=annotations,
        custom_object=custom_object,
    )