def submit_serving_with_pvc(capsys, namespace='default', pvc_name=None, pvc_mount_path=None): # pylint:disable=unused-argument fairing.config.set_builder( 'docker', registry=DOCKER_REGISTRY, base_image="seldonio/seldon-core-s2i-python3:0.4") if pvc_mount_path: pod_spec_mutators = [ mounting_pvc(pvc_name=pvc_name, pvc_mount_path=pvc_mount_path) ] else: pod_spec_mutators = [mounting_pvc(pvc_name=pvc_name)] expected_result = str(uuid.uuid4()) fairing.config.set_deployer('serving', serving_class="TestServe", labels={'pytest-id': expected_result}, service_type='ClusterIP', pod_spec_mutators=pod_spec_mutators) fairing.config.run() created_deployment = get_deployment_with_labels( namespace, 'pytest-id=' + expected_result) assert pvc_name == created_deployment.items[0].spec.template.spec.volumes[0]\ .persistent_volume_claim.claim_name if pvc_mount_path: assert pvc_mount_path == created_deployment.items[ 0].spec.template.spec.containers[0].volume_mounts[0].mount_path else: assert constants.PVC_DEFAULT_MOUNT_PATH == created_deployment.items[ 0].spec.template.spec.containers[0].volume_mounts[0].mount_path
def submit_jobs_with_pvc( capsys, cleanup=False, namespace="default", # pylint:disable=unused-argument pvc_name=None, pvc_mount_path=None): py_version = ".".join([str(x) for x in sys.version_info[0:3]]) base_image = 'registry.hub.docker.com/library/python:{}'.format(py_version) fairing.config.set_builder('append', base_image=base_image, registry=DOCKER_REGISTRY) if pvc_mount_path: pod_spec_mutators = [ mounting_pvc(pvc_name=pvc_name, pvc_mount_path=pvc_mount_path) ] else: pod_spec_mutators = [mounting_pvc(pvc_name=pvc_name)] expected_result = str(uuid.uuid4()) fairing.config.set_deployer('job', namespace=namespace, cleanup=cleanup, labels={'pytest-id': expected_result}, stream_log=False, pod_spec_mutators=pod_spec_mutators) remote_train = fairing.config.fn(lambda: train_fn(expected_result)) remote_train() created_job = get_job_with_labels(namespace, 'pytest-id=' + expected_result) assert pvc_name == created_job.items[0].spec.template.spec.volumes[0]\ .persistent_volume_claim.claim_name if pvc_mount_path: assert pvc_mount_path == created_job.items[0].spec.template.spec.containers[0]\ .volume_mounts[0].mount_path else: assert constants.PVC_DEFAULT_MOUNT_PATH == created_job.items[ 0].spec.template.spec.containers[0].volume_mounts[0].mount_path
if __name__ == '__main__': if os.getenv('FAIRING_RUNTIME', None) is None: from kubeflow import fairing from kubeflow.fairing.kubernetes import utils as k8s_utils DOCKER_REGISTRY = 'kubeflow-registry.default.svc.cluster.local:30000' fairing.config.set_builder( 'append', image_name='katib-job', base_image='brightfly/kubeflow-jupyter-lab:tf2.0-gpu', registry=DOCKER_REGISTRY, push=True) # cpu 2, memory 5GiB fairing.config.set_deployer( 'job', namespace='dudaji', pod_spec_mutators=[ k8s_utils.mounting_pvc(pvc_name="fashion-mnist", pvc_mount_path="/result"), k8s_utils.get_resource_mutator(cpu=2, memory=5) ]) fairing.config.run() else: remote_train = MyFashionMnist() remote_train.train() # In[ ]: # In[ ]:
"python", "tensorflow_mnist.py", "--model_path", "/mnt/pv/models/tensorflow/mnist" ] output_map = { "Dockerfile": "Dockerfile", "tensorflow_mnist.py": "tensorflow_mnist.py" } fairing.config.set_preprocessor('python', command=command, path_prefix="/app", output_map=output_map) fairing.config.set_builder('docker', registry=CONTAINER_REGISTRY, image_name="tensorflow-mnist", dockerfile_path="Dockerfile") fairing.config.set_deployer('job', namespace=namespace, job_name=job_name, pod_spec_mutators=[ k8s_utils.mounting_pvc( pvc_name='kfserving-models-pvc', pvc_mount_path='/mnt/pv') ], cleanup=True, stream_log=True) fairing.config.run()
if __name__ == '__main__': if os.getenv('FAIRING_RUNTIME', None) is None: from kubeflow import fairing from kubeflow.fairing.kubernetes import utils as k8s_utils DOCKER_REGISTRY = 'kubeflow-registry.default.svc.cluster.local:30000' fairing.config.set_builder('append', image_name='caltech-katib-job', base_image='brightfly/tf-fairing:2.0-gpu', registry=DOCKER_REGISTRY, push=True) # cpu 1, memory 1GiB fairing.config.set_deployer('job', namespace='dudaji', pod_spec_mutators=[ k8s_utils.mounting_pvc( pvc_name="caltech101", pvc_mount_path="/result") ]) # python3 import IPython ipy = IPython.get_ipython() if ipy is None: fairing.config.set_preprocessor('python', input_files=[__file__]) fairing.config.run() else: train = Caltech101() train.run() # In[4]:
if __name__ == '__main__': if os.getenv('FAIRING_RUNTIME', None) is None: from kubeflow import fairing from kubeflow.fairing.kubernetes import utils as k8s_utils DOCKER_REGISTRY = 'jaewoo201' fairing.config.set_builder( 'append', base_image='jaewoo201/kubeflow-jupyter-lab:tf2.0-cpu', registry=DOCKER_REGISTRY, push=True) # cpu 2, memory 5GiB fairing.config.set_deployer('job', namespace='kf-namespace', pod_spec_mutators=[ k8s_utils.mounting_pvc(pvc_name="azurefile", pvc_mount_path="/result"), k8s_utils.get_resource_mutator(cpu=1, memory=3)] ) fairing.config.run() else: remote_train = MyFashionMnist() remote_train.train() # In[ ]: