def queue_job(self, job_wrapper): job_destination = job_wrapper.job_destination self._populate_parameter_defaults(job_destination) command_line, client, remote_job_config, compute_environment = self.__prepare_job( job_wrapper, job_destination) if not command_line: return try: dependencies_description = PulsarJobRunner.__dependencies_description( client, job_wrapper) rewrite_paths = not PulsarJobRunner.__rewrite_parameters(client) unstructured_path_rewrites = {} output_names = [] if compute_environment: unstructured_path_rewrites = compute_environment.unstructured_path_rewrites output_names = compute_environment.output_names() if self.app.config.metadata_strategy == "legacy": # Drop this branch in 19.09. metadata_directory = job_wrapper.working_directory else: metadata_directory = os.path.join( job_wrapper.working_directory, "metadata") client_job_description = ClientJobDescription( command_line=command_line, input_files=self.get_input_files(job_wrapper), client_outputs=self.__client_outputs(client, job_wrapper), working_directory=job_wrapper.tool_working_directory, metadata_directory=metadata_directory, tool=job_wrapper.tool, config_files=job_wrapper.extra_filenames, dependencies_description=dependencies_description, env=client.env, rewrite_paths=rewrite_paths, arbitrary_files=unstructured_path_rewrites, touch_outputs=output_names, ) job_id = pulsar_submit_job(client, client_job_description, remote_job_config) log.info("Pulsar job submitted with job_id %s" % job_id) job_wrapper.set_job_destination(job_destination, job_id) job_wrapper.change_state(model.Job.states.QUEUED) except Exception: job_wrapper.fail("failure running job", exception=True) log.exception("failure running job %d", job_wrapper.job_id) return pulsar_job_state = AsynchronousJobState() pulsar_job_state.job_wrapper = job_wrapper pulsar_job_state.job_id = job_id pulsar_job_state.old_state = True pulsar_job_state.running = False pulsar_job_state.job_destination = job_destination self.monitor_job(pulsar_job_state)
def queue_job(self, job_wrapper): job_destination = job_wrapper.job_destination self._populate_parameter_defaults(job_destination) command_line, client, remote_job_config, compute_environment = self.__prepare_job(job_wrapper, job_destination) if not command_line: return try: dependencies_description = PulsarJobRunner.__dependencies_description(client, job_wrapper) rewrite_paths = not PulsarJobRunner.__rewrite_parameters(client) unstructured_path_rewrites = {} output_names = [] if compute_environment: unstructured_path_rewrites = compute_environment.unstructured_path_rewrites output_names = compute_environment.output_names() client_job_description = ClientJobDescription( command_line=command_line, input_files=self.get_input_files(job_wrapper), client_outputs=self.__client_outputs(client, job_wrapper), working_directory=job_wrapper.tool_working_directory, metadata_directory=job_wrapper.working_directory, tool=job_wrapper.tool, config_files=job_wrapper.extra_filenames, dependencies_description=dependencies_description, env=client.env, rewrite_paths=rewrite_paths, arbitrary_files=unstructured_path_rewrites, touch_outputs=output_names, ) job_id = pulsar_submit_job(client, client_job_description, remote_job_config) log.info("Pulsar job submitted with job_id %s" % job_id) job_wrapper.set_job_destination(job_destination, job_id) job_wrapper.change_state(model.Job.states.QUEUED) except Exception: job_wrapper.fail("failure running job", exception=True) log.exception("failure running job %d", job_wrapper.job_id) return pulsar_job_state = AsynchronousJobState() pulsar_job_state.job_wrapper = job_wrapper pulsar_job_state.job_id = job_id pulsar_job_state.old_state = True pulsar_job_state.running = False pulsar_job_state.job_destination = job_destination self.monitor_job(pulsar_job_state)
def queue_job(self, job_wrapper): job_destination = job_wrapper.job_destination self._populate_parameter_defaults(job_destination) command_line, client, remote_job_config, compute_environment, remote_container = self.__prepare_job(job_wrapper, job_destination) if not command_line: return try: dependencies_description = PulsarJobRunner.__dependencies_description(client, job_wrapper) rewrite_paths = not PulsarJobRunner.__rewrite_parameters(client) path_rewrites_unstructured = {} output_names = [] if compute_environment: path_rewrites_unstructured = compute_environment.path_rewrites_unstructured output_names = compute_environment.output_names() client_inputs_list = [] for input_dataset_wrapper in job_wrapper.get_input_paths(): # str here to resolve false_path if set on a DatasetPath object. path = str(input_dataset_wrapper) object_store_ref = { "dataset_id": input_dataset_wrapper.dataset_id, "dataset_uuid": str(input_dataset_wrapper.dataset_uuid), "object_store_id": input_dataset_wrapper.object_store_id, } client_inputs_list.append(ClientInput(path, CLIENT_INPUT_PATH_TYPES.INPUT_PATH, object_store_ref=object_store_ref)) for input_extra_path in compute_environment.path_rewrites_input_extra.keys(): # TODO: track dataset for object_Store_ref... client_inputs_list.append(ClientInput(input_extra_path, CLIENT_INPUT_PATH_TYPES.INPUT_EXTRA_FILES_PATH)) for input_metadata_path in compute_environment.path_rewrites_input_metadata.keys(): # TODO: track dataset for object_Store_ref... client_inputs_list.append(ClientInput(input_metadata_path, CLIENT_INPUT_PATH_TYPES.INPUT_METADATA_PATH)) input_files = None client_inputs = ClientInputs(client_inputs_list) else: input_files = self.get_input_files(job_wrapper) client_inputs = None if self.app.config.metadata_strategy == "legacy": # Drop this branch in 19.09. metadata_directory = job_wrapper.working_directory else: metadata_directory = os.path.join(job_wrapper.working_directory, "metadata") remote_pulsar_app_config = job_destination.params.get("pulsar_app_config", {}) job_directory_files = [] config_files = job_wrapper.extra_filenames tool_script = os.path.join(job_wrapper.working_directory, "tool_script.sh") if os.path.exists(tool_script): log.debug("Registering tool_script for Pulsar transfer [%s]" % tool_script) job_directory_files.append(tool_script) client_job_description = ClientJobDescription( command_line=command_line, input_files=input_files, client_inputs=client_inputs, # Only one of these input defs should be non-None client_outputs=self.__client_outputs(client, job_wrapper), working_directory=job_wrapper.tool_working_directory, metadata_directory=metadata_directory, tool=job_wrapper.tool, config_files=config_files, dependencies_description=dependencies_description, env=client.env, rewrite_paths=rewrite_paths, arbitrary_files=path_rewrites_unstructured, touch_outputs=output_names, remote_pulsar_app_config=remote_pulsar_app_config, job_directory_files=job_directory_files, container=None if not remote_container else remote_container.container_id, ) job_id = pulsar_submit_job(client, client_job_description, remote_job_config) log.info("Pulsar job submitted with job_id %s" % job_id) job_wrapper.set_job_destination(job_destination, job_id) job_wrapper.change_state(model.Job.states.QUEUED) except Exception: job_wrapper.fail("failure running job", exception=True) log.exception("failure running job %d", job_wrapper.job_id) return pulsar_job_state = AsynchronousJobState() pulsar_job_state.job_wrapper = job_wrapper pulsar_job_state.job_id = job_id pulsar_job_state.old_state = True pulsar_job_state.running = False pulsar_job_state.job_destination = job_destination self.monitor_job(pulsar_job_state)