Esempio n. 1
0
 def load_tool_from_config(self, repository_id, full_path):
     tool_source = get_tool_source(
         full_path,
         enable_beta_formats=getattr(self.app.config,
                                     "enable_beta_tool_formats", False),
         tool_location_fetcher=ToolLocationFetcher(),
     )
     try:
         tool = create_tool_from_source(config_file=full_path,
                                        app=self.app,
                                        tool_source=tool_source,
                                        repository_id=repository_id,
                                        allow_code_files=False)
         valid = True
         error_message = None
     except KeyError as e:
         tool = None
         valid = False
         error_message = 'This file requires an entry for "%s" in the tool_data_table_conf.xml file.  Upload a file ' % str(
             e)
         error_message += 'named tool_data_table_conf.xml.sample to the repository that includes the required entry to correct '
         error_message += 'this error.  '
         log.exception(error_message)
     except Exception as e:
         tool = None
         valid = False
         error_message = str(e)
         log.exception('Caught exception loading tool from %s:', full_path)
     return tool, valid, error_message
Esempio n. 2
0
 def __setup_tool(self):
     tool_source = get_tool_source(self.tool_file)
     self.tool = create_tool_from_source(self.app, tool_source, config_file=self.tool_file)
     self.tool.assert_finalized()
     if getattr(self, "tool_action", None):
         self.tool.tool_action = self.tool_action
     return self.tool
Esempio n. 3
0
 def __setup_tool(self):
     tool_source = get_tool_source(self.tool_file)
     try:
         self.tool = create_tool_from_source(self.app, tool_source, config_file=self.tool_file)
     except Exception:
         self.tool = None
     if getattr(self, "tool_action", None and self.tool):
         self.tool.tool_action = self.tool_action
     return self.tool
Esempio n. 4
0
 def __setup_tool(self):
     tool_source = get_tool_source(self.tool_file)
     try:
         self.tool = create_tool_from_source(self.app,
                                             tool_source,
                                             config_file=self.tool_file)
     except Exception:
         self.tool = None
     if getattr(self, "tool_action", None and self.tool):
         self.tool.tool_action = self.tool_action
     return self.tool
 def load_tool_from_config(self, repository_id, full_path):
     tool_source = get_tool_source(
         full_path,
         enable_beta_formats=getattr(self.app.config, "enable_beta_tool_formats", False),
         tool_location_fetcher=ToolLocationFetcher(),
     )
     try:
         tool = create_tool_from_source(config_file=full_path, app=self.app, tool_source=tool_source, repository_id=repository_id, allow_code_files=False)
         valid = True
         error_message = None
     except KeyError as e:
         tool = None
         valid = False
         error_message = 'This file requires an entry for "%s" in the tool_data_table_conf.xml file.  Upload a file ' % str(e)
         error_message += 'named tool_data_table_conf.xml.sample to the repository that includes the required entry to correct '
         error_message += 'this error.  '
     except Exception as e:
         tool = None
         valid = False
         error_message = str(e)
     return tool, valid, error_message
Esempio n. 6
0
def main(TMPDIR, WORKING_DIRECTORY, IMPORT_STORE_DIRECTORY):
    metadata_params = get_metadata_params(WORKING_DIRECTORY)
    datatypes_config = metadata_params["datatypes_config"]
    if not os.path.exists(datatypes_config):
        datatypes_config = os.path.join(WORKING_DIRECTORY, 'configs', datatypes_config)
    datatypes_registry = validate_and_load_datatypes_config(datatypes_config)
    object_store = get_object_store(WORKING_DIRECTORY)
    import_store = store.imported_store_for_metadata(IMPORT_STORE_DIRECTORY)
    # TODO: clean up random places from which we read files in the working directory
    job_io = JobIO.from_json(os.path.join(IMPORT_STORE_DIRECTORY, 'job_io.json'), sa_session=import_store.sa_session)
    tool_app_config = ToolAppConfig(
        name='tool_app',
        tool_data_path=job_io.tool_data_path,
        galaxy_data_manager_data_path=job_io.galaxy_data_manager_data_path,
        nginx_upload_path=TMPDIR,
        len_file_path=job_io.len_file_path,
        builds_file_path=job_io.builds_file_path,
        root=TMPDIR,
        is_admin_user=lambda _: job_io.user_context.is_admin)
    with open(os.path.join(IMPORT_STORE_DIRECTORY, 'tool_data_tables.json')) as data_tables_json:
        tdtm = ToolDataTableManager.from_dict(json.load(data_tables_json))
    app = ToolApp(
        sa_session=import_store.sa_session,
        tool_app_config=tool_app_config,
        datatypes_registry=datatypes_registry,
        object_store=object_store,
        tool_data_table_manager=tdtm,
        file_sources=job_io.file_sources,
    )
    # TODO: could try to serialize just a minimal tool variant instead of the whole thing ?
    tool_source = get_tool_source(tool_source_class=job_io.tool_source_class, raw_tool_source=job_io.tool_source)
    tool = create_tool_from_source(app, tool_source=tool_source, tool_dir=job_io.tool_dir)
    tool_evaluator = evaluation.RemoteToolEvaluator(app=app, tool=tool, job=job_io.job, local_working_directory=WORKING_DIRECTORY)
    tool_evaluator.set_compute_environment(compute_environment=SharedComputeEnvironment(job_io=job_io, job=job_io.job))
    with open(os.path.join(WORKING_DIRECTORY, 'tool_script.sh'), 'a') as out:
        command_line, version_command_line, extra_filenames, environment_variables = tool_evaluator.build()
        out.write(f'{version_command_line or ""}{command_line}')
Esempio n. 7
0
def _deserialize(app, tool_source_class, raw_tool_source):
    tool_source = get_tool_source(tool_source_class=tool_source_class,
                                  raw_tool_source=raw_tool_source)
    assert type(tool_source).__name__ == tool_source_class
    return create_tool_from_source(app, tool_source=tool_source)