def run_pipeline(self, experiment_id, job_name, pipeline_package_path, params={}): """Run a specified pipeline. Args: experiment_id: The string id of an experiment. job_name: name of the job. pipeline_package_path: local path of the pipeline package(tar.gz file). params: a dictionary with key (string) as param name and value (string) as as param value. Returns: A run object. Most important field is id. """ import kfp_run pipeline_obj = self._extract_pipeline_yaml(pipeline_package_path) pipeline_json_string = json.dumps(pipeline_obj) api_params = [kfp_run.ApiParameter(name=k, value=str(v)) for k,v in six.iteritems(params)] key = kfp_run.models.ApiResourceKey(id=experiment_id, type=kfp_run.models.ApiResourceType.EXPERIMENT) reference = kfp_run.models.ApiResourceReference(key, kfp_run.models.ApiRelationship.OWNER) spec = kfp_run.models.ApiPipelineSpec( workflow_manifest=pipeline_json_string, parameters=api_params) run_body = kfp_run.models.ApiRun( pipeline_spec=spec, resource_references=[reference], name=job_name) response = self._run_api.create_run(body=run_body) if self._is_ipython(): import IPython html = ('Job link <a href="/pipeline/#/runs/details/%s" target="_blank" >here</a>' % response.run.id) IPython.display.display(IPython.display.HTML(html)) return response.run
def run_pipeline(self, experiment_id, job_name, pipeline_package_path=None, params={}, pipeline_id=None): """Run a specified pipeline. Args: experiment_id: The string id of an experiment. job_name: name of the job. pipeline_package_path: local path of the pipeline package(the filename should end with one of the following .tar.gz, .tgz, .zip, .yaml, .yml). params: a dictionary with key (string) as param name and value (string) as as param value. pipeline_id: the string ID of a pipeline. Returns: A run object. Most important field is id. """ import kfp_run pipeline_json_string = None if pipeline_package_path: pipeline_obj = self._extract_pipeline_yaml(pipeline_package_path) pipeline_json_string = json.dumps(pipeline_obj) api_params = [ kfp_run.ApiParameter( name=_k8s_helper.K8sHelper.sanitize_k8s_name(k), value=str(v)) for k, v in params.items() ] key = kfp_run.models.ApiResourceKey( id=experiment_id, type=kfp_run.models.ApiResourceType.EXPERIMENT) reference = kfp_run.models.ApiResourceReference( key, kfp_run.models.ApiRelationship.OWNER) spec = kfp_run.models.ApiPipelineSpec( pipeline_id=pipeline_id, workflow_manifest=pipeline_json_string, parameters=api_params) run_body = kfp_run.models.ApiRun(pipeline_spec=spec, resource_references=[reference], name=job_name) response = self._run_api.create_run(body=run_body) if self._is_ipython(): import IPython html = ( 'Run link <a href="%s/#/runs/details/%s" target="_blank" >here</a>' % (self._get_url_prefix(), response.run.id)) IPython.display.display(IPython.display.HTML(html)) return response.run