diff --git a/client/galaxy/scripts/components/User/UserPreferences.vue b/client/galaxy/scripts/components/User/UserPreferences.vue index 5d7a3b86730..6a294d9fc97 100644 --- a/client/galaxy/scripts/components/User/UserPreferences.vue +++ b/client/galaxy/scripts/components/User/UserPreferences.vue @@ -90,9 +90,6 @@ export default { case "custom_builds": activeLinks[key]["onclick"] = this.openManageCustomBuilds; break; - case "genomespace": - activeLinks[key]["onclick"] = this.requestGenomeSpace; - break; case "logout": activeLinks[key]["onclick"] = this.signOut; break; @@ -138,9 +135,6 @@ export default { }); } }, - requestGenomeSpace() { - window.location.href = `${getAppRoot()}openid/openid_auth?openid_provider=genomespace`; - }, signOut() { const Galaxy = getGalaxyInstance(); Galaxy.modal.show({ diff --git a/client/galaxy/scripts/components/User/UserPreferencesModel.js b/client/galaxy/scripts/components/User/UserPreferencesModel.js index 3a8ac11ac3e..5078266abf4 100644 --- a/client/galaxy/scripts/components/User/UserPreferencesModel.js +++ b/client/galaxy/scripts/components/User/UserPreferencesModel.js @@ -73,11 +73,6 @@ export const getUserPreferencesModel = () => { description: _l("Add or remove custom builds using history datasets."), icon: "fa-cubes" }, - genomespace: { - title: _l("Request GenomeSpace token"), - description: _l("Requests token through OpenID."), - icon: "fa-openid" - }, logout: { title: _l("Sign out"), description: _l("Click here to sign out of all sessions."), diff --git a/client/galaxy/scripts/mvc/form/form-parameters.js b/client/galaxy/scripts/mvc/form/form-parameters.js index 35e48d6063b..076c42bf8bf 100644 --- a/client/galaxy/scripts/mvc/form/form-parameters.js +++ b/client/galaxy/scripts/mvc/form/form-parameters.js @@ -9,7 +9,6 @@ import Ui from "mvc/ui/ui-misc"; import SelectContent from "mvc/ui/ui-select-content"; import SelectLibrary from "mvc/ui/ui-select-library"; import SelectFtp from "mvc/ui/ui-select-ftp"; -import SelectGenomeSpace from "mvc/ui/ui-select-genomespace"; import RulesEdit from "mvc/ui/ui-rules-edit"; import ColorPicker from "mvc/ui/ui-color-picker"; import DataPicker from "mvc/ui/ui-data-picker"; @@ -38,7 +37,6 @@ export default Backbone.Model.extend({ ftpfile: "_fieldFtp", upload: "_fieldUpload", rules: "_fieldRulesEdit", - genomespacefile: "_fieldGenomeSpace", data_dialog: "_fieldDialog" }, @@ -237,15 +235,6 @@ export default Backbone.Model.extend({ }); }, - /** GenomeSpace file select field - */ - _fieldGenomeSpace: function(input_def) { - return new SelectGenomeSpace.View({ - id: `field-${input_def.id}`, - onchange: input_def.onchange - }); - }, - _fieldRulesEdit: function(input_def) { return new RulesEdit.View({ id: `field-${input_def.id}`, diff --git a/client/galaxy/scripts/mvc/tool/tool-genomespace.js b/client/galaxy/scripts/mvc/tool/tool-genomespace.js deleted file mode 100644 index a4523fac27a..00000000000 --- a/client/galaxy/scripts/mvc/tool/tool-genomespace.js +++ /dev/null @@ -1,27 +0,0 @@ -// Provides support for interacting with the GenomeSpace File Browser popup dialogue -import { getGalaxyInstance } from "app"; - -// tool form templates -export default { - openFileBrowser: function(options) { - const Galaxy = getGalaxyInstance(); - var GS_UI_URL = Galaxy.config.genomespace_ui_url; - var GS_UPLOAD_URL = `${GS_UI_URL}upload/loadUrlToGenomespace.html?getLocation=true`; - - var newWin = window.open(GS_UPLOAD_URL, "GenomeSpace File Browser", "height=360px,width=600px"); - - window.addEventListener( - "message", - e => { - if (options.successCallback && e.data.destination) { - options.successCallback(e.data); - } - }, - false - ); - - newWin.focus(); - - if (options["errorCallback"] != null) newWin.setCallbackOnGSUploadError = Galaxy.config["errorCallback"]; - } -}; diff --git a/client/galaxy/scripts/mvc/ui/ui-select-genomespace.js b/client/galaxy/scripts/mvc/ui/ui-select-genomespace.js deleted file mode 100644 index 64b0a232f0f..00000000000 --- a/client/galaxy/scripts/mvc/ui/ui-select-genomespace.js +++ /dev/null @@ -1,79 +0,0 @@ -import Backbone from "backbone"; -import _l from "utils/localization"; -import Ui from "mvc/ui/ui-misc"; -import GenomespaceBrowser from "mvc/tool/tool-genomespace"; -/** - * GenomeSpace file selector - */ -var View = Backbone.View.extend({ - // initialize - initialize: function(options) { - // link this - var self = this; - this.options = options; - - // create insert new list element button - this.browse_button = new Ui.Button({ - title: _l("Browse"), - icon: "fa fa-sign-in", - cls: "btn btn-secondary float-left", - tooltip: _l("Browse GenomeSpace"), - onclick: function() { - self.browseGenomeSpace(options); - } - }); - - // create genomespace filepath textbox - this.filename_textbox = new Ui.Input(); - - // create elements - this.setElement(this._template(options)); - this.$(".ui-browse-button").append(this.browse_button.$el); - this.$(".ui-filename-textbox").append(this.filename_textbox.$el); - }, - - /** Browse GenomeSpace */ - browseGenomeSpace: function(options) { - var self = this; - GenomespaceBrowser.openFileBrowser({ - successCallback: function(data) { - self.value(data.destination); - } - }); - }, - - /** Main Template */ - _template: function(options) { - return `
-
-
-
`; - }, - - /** Return/Set currently selected genomespace filename */ - value: function(new_value) { - // check if new_value is defined - if (new_value !== undefined) { - this._setValue(new_value); - } else { - return this._getValue(); - } - }, - - // get value - _getValue: function() { - return this.filename_textbox.value(); - }, - - // set value - _setValue: function(new_value) { - if (new_value) { - this.filename_textbox.value(new_value); - } - this.options.onchange && this.options.onchange(new_value); - } -}); - -export default { - View: View -}; diff --git a/client/galaxy/scripts/nls/fr/locale.js b/client/galaxy/scripts/nls/fr/locale.js index 3e0f8c1ad91..df0eb2a39fb 100644 --- a/client/galaxy/scripts/nls/fr/locale.js +++ b/client/galaxy/scripts/nls/fr/locale.js @@ -339,9 +339,6 @@ define({ "Delete this repeat block": false, placeholder: false, Repeat: false, - // ---------------------------------------------------------------------------- ui-select-genomespace - "Browse GenomeSpace": false, - Browse: false, // ---------------------------------------------------------------------------- ui-frames Error: false, Close: false, diff --git a/client/galaxy/scripts/nls/locale.js b/client/galaxy/scripts/nls/locale.js index bd635ce8e4b..afb604e5a03 100644 --- a/client/galaxy/scripts/nls/locale.js +++ b/client/galaxy/scripts/nls/locale.js @@ -339,9 +339,6 @@ define({ "Delete this repeat block": false, placeholder: false, Repeat: false, - // ---------------------------------------------------------------------------- ui-select-genomespace - "Browse GenomeSpace": false, - Browse: false, // ---------------------------------------------------------------------------- ui-frames Error: false, Close: false, diff --git a/doc/source/admin/galaxy_options.rst b/doc/source/admin/galaxy_options.rst index 40d9919ae41..8fa39190080 100644 --- a/doc/source/admin/galaxy_options.rst +++ b/doc/source/admin/galaxy_options.rst @@ -1584,17 +1584,6 @@ :Type: str -~~~~~~~~~~~~~~~~~~~~~~ -``genomespace_ui_url`` -~~~~~~~~~~~~~~~~~~~~~~ - -:Description: - Points to the GenomeSpace UI service which will be used by the - GenomeSpace importer and exporter tools -:Default: ``https://gsui.genomespace.org/jsui/`` -:Type: str - - ~~~~~~~~~~~~~ ``terms_url`` ~~~~~~~~~~~~~ diff --git a/lib/galaxy/config/sample/galaxy.yml.sample b/lib/galaxy/config/sample/galaxy.yml.sample index 977f49bbb13..620e61b3ad3 100644 --- a/lib/galaxy/config/sample/galaxy.yml.sample +++ b/lib/galaxy/config/sample/galaxy.yml.sample @@ -837,10 +837,6 @@ galaxy: # The URL linked by the "Videos" link in the "Help" menu. #screencasts_url: https://vimeo.com/galaxyproject - # Points to the GenomeSpace UI service which will be used by the - # GenomeSpace importer and exporter tools - #genomespace_ui_url: https://gsui.genomespace.org/jsui/ - # The URL linked by the "Terms and Conditions" link in the "Help" # menu, as well as on the user registration and login forms and in the # activation emails. diff --git a/lib/galaxy/config/sample/tool_conf.xml.main b/lib/galaxy/config/sample/tool_conf.xml.main index 99aa2052798..7569b7ad0d7 100644 --- a/lib/galaxy/config/sample/tool_conf.xml.main +++ b/lib/galaxy/config/sample/tool_conf.xml.main @@ -16,12 +16,9 @@ - -
-
diff --git a/lib/galaxy/config/sample/tool_conf.xml.sample b/lib/galaxy/config/sample/tool_conf.xml.sample index a1f35da1733..fd6f80066f5 100644 --- a/lib/galaxy/config/sample/tool_conf.xml.sample +++ b/lib/galaxy/config/sample/tool_conf.xml.sample @@ -20,12 +20,9 @@ - -
-
diff --git a/lib/galaxy/dependencies/pipfiles/default/Pipfile b/lib/galaxy/dependencies/pipfiles/default/Pipfile index 48114734ccc..3c3ce61385a 100644 --- a/lib/galaxy/dependencies/pipfiles/default/Pipfile +++ b/lib/galaxy/dependencies/pipfiles/default/Pipfile @@ -78,7 +78,7 @@ svgwrite = "*" pyparsing = "*" "Fabric3" = "*" paramiko = "*" -python-genomespaceclient = "<2.0" +cloudbridge = "*" social_auth_core = {version = "==3.1.0+gx0", extras = ['openidconnect']} cloudauthz = "==0.6.0" gxformat2 = "*" diff --git a/lib/galaxy/dependencies/pipfiles/default/pinned-dev-requirements.txt b/lib/galaxy/dependencies/pipfiles/default/pinned-dev-requirements.txt index 536f8e30e89..7388ad1a691 100644 --- a/lib/galaxy/dependencies/pipfiles/default/pinned-dev-requirements.txt +++ b/lib/galaxy/dependencies/pipfiles/default/pinned-dev-requirements.txt @@ -44,21 +44,20 @@ pytest-postgresql==1.4.1 pytest-pythonpath==0.7.3 pytest==4.6.6 pytz==2019.3 -pyyaml==5.2 recommonmark==0.6.0 requests==2.22.0 scandir==1.10.0 ; python_version < '3.5' selenium==3.141.0 six==1.11.0 snowballstemmer==2.0.0 -sphinx-markdown-tables==0.0.10 +sphinx-markdown-tables==0.0.12 sphinx-rtd-theme==0.4.3 sphinx==1.8.5 sphinxcontrib-websupport==1.1.2 testfixtures==6.10.3 twill==0.9.1 ; python_version < '3' typing==3.7.4.1 ; python_version < '3.5' -urllib3==1.25.7 ; python_version == '2.7' +urllib3==1.25.7 watchdog==0.9.0 -wcwidth==0.1.7 ; sys_platform != 'win32' +wcwidth==0.1.7 zipp==0.6.0 diff --git a/lib/galaxy/dependencies/pipfiles/default/pinned-requirements.txt b/lib/galaxy/dependencies/pipfiles/default/pinned-requirements.txt index 2104230a1a2..1807fb9ba43 100644 --- a/lib/galaxy/dependencies/pipfiles/default/pinned-requirements.txt +++ b/lib/galaxy/dependencies/pipfiles/default/pinned-requirements.txt @@ -60,7 +60,7 @@ funcsigs==1.0.2 ; python_version < '3.3' functools32==3.2.3.post2 ; python_version < '3.2' future==0.18.2 futures==3.3.0 ; python_version == '2.6' or python_version == '2.7' -galaxy-sequence-utils==1.1.3 +galaxy-sequence-utils==1.1.4 google-api-python-client==1.7.8 google-auth-httplib2==0.0.3 google-auth==1.7.1 @@ -127,7 +127,7 @@ pulsar-galaxy-lib==0.14.0.dev1 pyasn1-modules==0.2.7 pyasn1==0.4.8 pycparser==2.19 -pycryptodome==3.9.4 +pycryptodome==3.9.6 pyeventsystem==0.1.0 pyinotify==0.9.6 ; sys_platform != 'win32' and sys_platform != 'darwin' and sys_platform != 'sunos5' pyjwt==1.7.1 @@ -141,7 +141,6 @@ pysam==0.15.2 pysftp==0.2.9 python-cinderclient==4.0.0 python-dateutil==2.8.1 -python-genomespaceclient==1.2.0 python-glanceclient==2.12.0 python-jose==3.0.1 python-keystoneclient==3.17.0 @@ -187,7 +186,7 @@ typing==3.7.4.1 ; python_version < '3.5' tzlocal==2.0.0 unicodecsv==0.14.1 ; python_version < '3.0' uritemplate==3.0.0 -urllib3==1.25.7 ; python_version == '2.7' +urllib3==1.25.7 vine==1.3.0 warlock==1.3.3 wcwidth==0.1.7 ; sys_platform != 'win32' diff --git a/lib/galaxy/dependencies/pipfiles/update.sh b/lib/galaxy/dependencies/pipfiles/update.sh index 93b7dac5b4c..ea2cf862b38 100755 --- a/lib/galaxy/dependencies/pipfiles/update.sh +++ b/lib/galaxy/dependencies/pipfiles/update.sh @@ -73,6 +73,7 @@ for env in $ENVS; do -e "s/^\(python-dateutil==[^ ;]\{1,\}\).*$/\1/" \ -e "s/^\(subprocess32==[^ ;]\{1,\}\).*$/\1 ; python_version < '3.0'/" \ -e "s/^\(typing==[^ ;]\{1,\}\).*$/\1 ; python_version < '3.5'/" \ + -e "s/^\(urllib3==[^ ;]\{1,\}\).*$/\1/" \ pinned-requirements.txt pinned-dev-requirements.txt if ! grep '==' pinned-dev-requirements.txt ; then rm -f pinned-dev-requirements.txt diff --git a/lib/galaxy/managers/configuration.py b/lib/galaxy/managers/configuration.py index b5ddd1e1ec1..4e5d1ec363a 100644 --- a/lib/galaxy/managers/configuration.py +++ b/lib/galaxy/managers/configuration.py @@ -51,7 +51,6 @@ class ConfigSerializer(base.ModelSerializer): 'search_url' : _required_attribute, 'mailing_lists' : _defaults_to(self.app.config.mailing_lists_url), 'screencasts_url' : _required_attribute, - 'genomespace_ui_url' : _required_attribute, 'citation_url' : _required_attribute, 'support_url' : _required_attribute, 'helpsite_url' : _required_attribute, diff --git a/lib/galaxy/openid/genomespace.xml b/lib/galaxy/openid/genomespace.xml deleted file mode 100644 index 65bf95ecbc5..00000000000 --- a/lib/galaxy/openid/genomespace.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - https://identity.genomespace.org/identityServer/xrd.jsp - - - - - - - - - - - - - diff --git a/lib/galaxy/openid/openid_conf.xml b/lib/galaxy/openid/openid_conf.xml index 7a1e3dd9909..5730ae4dd86 100644 --- a/lib/galaxy/openid/openid_conf.xml +++ b/lib/galaxy/openid/openid_conf.xml @@ -1,4 +1,3 @@ - diff --git a/lib/galaxy/tools/__init__.py b/lib/galaxy/tools/__init__.py index 4dabd33e329..686e4ce796b 100755 --- a/lib/galaxy/tools/__init__.py +++ b/lib/galaxy/tools/__init__.py @@ -177,8 +177,6 @@ GALAXY_LIB_TOOLS_UNVERSIONED = [ "gd_phylogenetic_tree", "gd_population_structure", "gd_prepare_population_structure", - # Datasources - "genomespace_importer" ] # Tools that needed galaxy on the PATH in the past but no longer do along # with the version at which they were fixed. diff --git a/lib/galaxy/tools/parameters/basic.py b/lib/galaxy/tools/parameters/basic.py index 43d65298a36..5dc7379af03 100644 --- a/lib/galaxy/tools/parameters/basic.py +++ b/lib/galaxy/tools/parameters/basic.py @@ -648,19 +648,6 @@ class FTPFileToolParameter(ToolParameter): return d -class GenomespaceFileToolParameter(ToolParameter): - """ - Parameter that takes one of two values. - """ - - def __init__(self, tool, input_source): - super(GenomespaceFileToolParameter, self).__init__(tool, input_source) - self.value = input_source.get('value') - - def get_initial_value(self, trans, other_values): - return self.value - - class HiddenToolParameter(ToolParameter): """ Parameter that takes one of two values. @@ -2351,7 +2338,6 @@ parameter_types = dict( baseurl=BaseURLToolParameter, file=FileToolParameter, ftpfile=FTPFileToolParameter, - genomespacefile=GenomespaceFileToolParameter, data=DataToolParameter, data_collection=DataCollectionToolParameter, library_data=LibraryDatasetToolParameter, diff --git a/lib/galaxy/webapps/galaxy/config_schema.yml b/lib/galaxy/webapps/galaxy/config_schema.yml index 772fce1a3b9..db3be55aa3e 100644 --- a/lib/galaxy/webapps/galaxy/config_schema.yml +++ b/lib/galaxy/webapps/galaxy/config_schema.yml @@ -1179,14 +1179,6 @@ mapping: desc: | The URL linked by the "Videos" link in the "Help" menu. - genomespace_ui_url: - type: str - default: https://gsui.genomespace.org/jsui/ - required: false - desc: | - Points to the GenomeSpace UI service which will be used by - the GenomeSpace importer and exporter tools - terms_url: type: str required: false diff --git a/test/integration/test_config_defaults.py b/test/integration/test_config_defaults.py index 87e0b46d777..ca928d2814e 100644 --- a/test/integration/test_config_defaults.py +++ b/test/integration/test_config_defaults.py @@ -1,13 +1,3 @@ -import os -from collections import namedtuple -from datetime import timedelta - -import pytest - -from galaxy.util import listify -from galaxy_test.driver.driver_util import GalaxyTestDriver - - """ This tests: (1) automatic creation of configuration properties; and (2) assignment of default values that are specified in the schema and, in @@ -35,9 +25,16 @@ Configuration options NOT tested: - job_config (no obvious testable defaults) """ +import os +from collections import namedtuple +from datetime import timedelta -OptionData = namedtuple('OptionData', 'key, expected, loaded') +import pytest +from galaxy.util import listify +from galaxy_test.driver.driver_util import GalaxyTestDriver + +OptionData = namedtuple('OptionData', ('key', 'expected', 'loaded')) # Configuration properties that are paths should be absolute paths, by default resolved w.r.t root. PATH_CONFIG_PROPERTIES = [ @@ -155,6 +152,7 @@ DO_NOT_TEST = [ 'allow_user_deletion', # broken: default overridden 'amqp_internal_connection', # may or may not be testable; refactor config/ 'api_allow_run_as', # may or may not be testable: test value assigned + 'build_sites_config_file', # broken: remove 'config/' prefix from schema 'chunk_upload_size', # broken: default overridden 'cleanup_job', # broken: default overridden 'conda_auto_init', # broken: default overridden @@ -203,7 +201,7 @@ DO_NOT_TEST = [ 'user_tool_label_filters', # broken: default overridden 'user_tool_section_filters', # broken: default overridden 'webhooks_dir', # broken; also remove 'config/' prefix from schema - 'workflow_resource_params_mapper', # broken + 'workflow_resource_params_mapper', # broken: remove 'config/' prefix from schema ] diff --git a/tools/genomespace/genomespace_exporter.py b/tools/genomespace/genomespace_exporter.py deleted file mode 100644 index bca99e5e009..00000000000 --- a/tools/genomespace/genomespace_exporter.py +++ /dev/null @@ -1,38 +0,0 @@ -import argparse -import binascii -import os -import sys - -from genomespaceclient import GenomeSpaceClient - - -def upload_to_genomespace(token, input_file, target_url): - token = token or os.environ.get('GS_TOKEN') - gs_client = GenomeSpaceClient(token=token) - gs_client.copy(input_file, target_url) - print("File successfully copied.") - - -def process_args(args): - parser = argparse.ArgumentParser() - parser.add_argument('-i', '--input_file', type=str, - help="File to export", required=True) - parser.add_argument('-o', '--target_url', type=str, - help="GenomeSpace output target folder location", required=True) - parser.add_argument('-t', '--token', type=str, - help="Optional OpenID/GenomeSpace token if not passed in as part of the URL as URLs^Token." - " If none, the environment variable GS_TOKEN will be respected.", required=False) - - args = parser.parse_args(args[1:]) - return args - - -def main(): - args = process_args(sys.argv) - upload_to_genomespace(args.token, - binascii.unhexlify(args.input_file).decode('utf-8'), - binascii.unhexlify(args.target_url).decode('utf-8')) - - -if __name__ == "__main__": - sys.exit(main()) diff --git a/tools/genomespace/genomespace_exporter.xml b/tools/genomespace/genomespace_exporter.xml deleted file mode 100644 index 392d3eef55c..00000000000 --- a/tools/genomespace/genomespace_exporter.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - send data to GenomeSpace - - - #set $token = $__user__.preferences.get('genomespace_token', None) - #assert $token, Exception('Invalid token. You must be logged into GenomeSpace through OpenID.') - $token - - - python $__tool_directory__/genomespace_exporter.py - #set $target_folder = $genomespace_browser.split('^')[0] - #assert $target_folder, Exception('You must select a valid target folder.') - - #import binascii - --input_file '${ binascii.hexlify(str($input1).encode("utf8")) }' - #if $filename: - --target_url '${ binascii.hexlify(str($target_folder + "/" + str($filename)).encode("utf8") ) }' - #else: - --target_url '${ binascii.hexlify(($target_folder + "/" + "Galaxy History Item %s (%s) - %s: %s.%s" % ($__app__.security.encode_id($input1.id), $__app__.security.encode_id($output_log.id), $input1.hid, $input1.element_identifier.replace("/", "_"), $input1.ext)).encode("utf8")) }' - #end if - - - - - - - - - - - -This Tool allows you to export data to GenomeSpace. Click the Browse button to select a file to export. - -To use this tool, you must have logged in using your GenomeSpace OpenID. -You can associate your OpenID credentials under the User Preferences panel. -Click here_ to refresh your GenomeSpace token. - -.. _here: ${static_path}/../user/openid_auth?openid_provider=genomespace&auto_associate=True - - diff --git a/tools/genomespace/genomespace_file_browser.py b/tools/genomespace/genomespace_file_browser.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tools/genomespace/genomespace_importer.py b/tools/genomespace/genomespace_importer.py deleted file mode 100644 index 8ecf787dbc6..00000000000 --- a/tools/genomespace/genomespace_importer.py +++ /dev/null @@ -1,260 +0,0 @@ -import argparse -import json -import os -import sys -import uuid - -from genomespaceclient import GenomeSpaceClient - -import galaxy -from galaxy.datatypes import sniff -from galaxy.datatypes.registry import Registry - - -# Mappings for known genomespace formats to galaxy formats -GENOMESPACE_EXT_TO_GALAXY_EXT = {'rifles': 'rifles', - 'lifes': 'lifes', - 'cn': 'cn', - 'gtf': 'gtf', - 'res': 'res', - 'xcn': 'xcn', - 'lowercasetxt': 'lowercasetxt', - 'bed': 'bed', - 'cbs': 'cbs', - 'genomicatab': 'genomicatab', - 'gxp': 'gxp', - 'reversedtxt': 'reversedtxt', - 'nowhitespace': 'nowhitespace', - 'unknown': 'unknown', - 'txt': 'txt', - 'uppercasetxt': 'uppercasetxt', - 'gistic': 'gistic', - 'gff': 'gff', - 'gmt': 'gmt', - 'gct': 'gct'} - - -def _prepare_json_list(param_list): - """ - JSON serialization Support functions for exec_before_job hook - """ - rval = [] - for value in param_list: - if isinstance(value, dict): - rval.append(_prepare_json_param_dict(value)) - elif isinstance(value, list): - rval.append(_prepare_json_list(value)) - else: - rval.append(str(value)) - return rval - - -def _prepare_json_param_dict(param_dict): - """ - JSON serialization Support functions for exec_before_job hook - """ - rval = {} - for key, value in param_dict.items(): - if isinstance(value, dict): - rval[key] = _prepare_json_param_dict(value) - elif isinstance(value, list): - rval[key] = _prepare_json_list(value) - else: - rval[key] = str(value) - return rval - - -def exec_before_job(app, inp_data, out_data, param_dict=None, tool=None): - """ - Galaxy override hook - See: https://wiki.galaxyproject.org/Admin/Tools/ToolConfigSyntax#A.3Ccode.3E_tag_set - Since only tools with tool_type="data_source" provides functionality for having a JSON param file such as this: - https://wiki.galaxyproject.org/Admin/Tools/DataManagers/DataManagerJSONSyntax#Example_JSON_input_to_tool, - this hook is used to manually create a similar JSON file. - However, this hook does not provide access to GALAXY_DATATYPES_CONF_FILE and GALAXY_ROOT_DIR - properties, so these must be passed in as commandline params. - """ - if param_dict is None: - param_dict = {} - json_params = {} - json_params['param_dict'] = _prepare_json_param_dict(param_dict) - json_params['output_data'] = [] - json_params['job_config'] = dict(GALAXY_DATATYPES_CONF_FILE=param_dict.get('GALAXY_DATATYPES_CONF_FILE'), - GALAXY_ROOT_DIR=param_dict.get('GALAXY_ROOT_DIR'), - TOOL_PROVIDED_JOB_METADATA_FILE=galaxy.jobs.TOOL_PROVIDED_JOB_METADATA_FILE) - json_filename = None - for i, (out_name, data) in enumerate(out_data.items()): - file_name = data.get_file_name() - data_dict = dict(out_data_name=out_name, - ext=data.ext, - dataset_id=data.dataset.id, - hda_id=data.id, - file_name=file_name) - json_params['output_data'].append(data_dict) - if json_filename is None: - json_filename = file_name - with open(json_filename, 'w') as out: - out.write(json.dumps(json_params)) - - -def get_galaxy_ext_from_genomespace_format(format): - return GENOMESPACE_EXT_TO_GALAXY_EXT.get(format, None) - - -def get_galaxy_ext_from_file_ext(filename): - if not filename: - return None - filename = filename.lower() - ext = filename.rsplit('.', 1)[-1] - return get_galaxy_ext_from_genomespace_format(ext) - - -def sniff_and_handle_data_type(json_params, output_file): - """ - The sniff.handle_uploaded_dataset_file() method in Galaxy performs dual - functions: it sniffs the filetype and if it's a compressed archive for - a non compressed datatype such as fasta, it will be unpacked. - """ - try: - datatypes_registry = Registry() - datatypes_registry.load_datatypes( - root_dir=json_params['job_config']['GALAXY_ROOT_DIR'], - config=json_params['job_config']['GALAXY_DATATYPES_CONF_FILE']) - file_type = sniff.handle_uploaded_dataset_file( - output_file, - datatypes_registry) - return file_type - except Exception: - return None - - -def determine_output_filename(input_url, metadata, json_params, primary_dataset): - """ - Determines the output file name. If only a single output file, the dataset name - is used. If multiple files are being downloaded, each file is given a unique dataset - name - """ - output_filename = json_params['output_data'][0]['file_name'] - - if not primary_dataset or not output_filename: - hda_id = json_params['output_data'][0]['hda_id'] - output_filename = 'primary_%i_%s_visible_%s' % (hda_id, metadata.name, uuid.uuid4()) - - return os.path.join(os.getcwd(), output_filename) - - -def determine_file_type(input_url, output_filename, metadata, json_params, sniffed_type): - """ - Determine the Galaxy data format for this file. - """ - # Use genomespace metadata to map type - file_format = metadata.data_format.name if metadata.data_format else None - file_type = get_galaxy_ext_from_genomespace_format(file_format) - - # If genomespace metadata has no identifiable format, attempt to sniff type - if not file_type: - file_type = sniffed_type - - # Still no type? Attempt to use filename extension to determine a type - if not file_type: - file_type = get_galaxy_ext_from_file_ext(metadata.name) - - # Nothing works, use default - if not file_type: - file_type = "data" - - return file_type - - -def save_result_metadata(output_filename, file_type, metadata, json_params, - primary_dataset=False): - """ - Generates a new job metadata file (typically galaxy.json) with details of - all downloaded files, which Galaxy can read and use to display history items - and associated metadata - """ - dataset_id = json_params['output_data'][0]['dataset_id'] - with open(json_params['job_config']['TOOL_PROVIDED_JOB_METADATA_FILE'], 'ab') as metadata_parameter_file: - if primary_dataset: - metadata_parameter_file.write("%s\n" % json.dumps(dict(type='dataset', - dataset_id=dataset_id, - ext=file_type, - name="GenomeSpace importer on %s" % (metadata.name)))) - else: - metadata_parameter_file.write("%s\n" % json.dumps(dict(type='new_primary_dataset', - base_dataset_id=dataset_id, - ext=file_type, - filename=output_filename, - name="GenomeSpace importer on %s" % (metadata.name)))) - - -def download_single_file(gs_client, input_url, json_params, - primary_dataset=False): - # 1. Get file metadata - metadata = gs_client.get_metadata(input_url) - - # 2. Determine output file name - output_filename = determine_output_filename(input_url, metadata, json_params, primary_dataset) - - # 3. Download file - gs_client.copy(input_url, output_filename) - - # 4. Decompress file if compressed and sniff type - sniffed_type = sniff_and_handle_data_type(json_params, output_filename) - - # 5. Determine file type from available metadata - file_type = determine_file_type(input_url, output_filename, metadata, json_params, sniffed_type) - - # 6. Write job output metadata - save_result_metadata(output_filename, file_type, metadata, json_params, - primary_dataset=primary_dataset) - - -def download_from_genomespace_importer(json_parameter_file, root, data_conf, custom_token): - with open(json_parameter_file, 'r') as param_file: - json_params = json.load(param_file) - - # Add in missing job config properties that could not be set in the exec_before_job hook - json_params['job_config']['GALAXY_ROOT_DIR'] = root - json_params['job_config']['GALAXY_DATATYPES_CONF_FILE'] = data_conf - - # Extract input_urls and token (format is input_urls^token). If a custom_token is - # provided, use that instead. - url_with_token = json_params.get('param_dict', {}).get("URL", "") - if custom_token: - input_urls = url_with_token.split('^')[0] - token = custom_token - else: - input_urls, token = url_with_token.split('^') - input_url_list = input_urls.split(",") - - gs_client = GenomeSpaceClient(token=token) - - for idx, input_url in enumerate(input_url_list): - download_single_file(gs_client, input_url, json_params, - primary_dataset=(idx == 0)) - - -def process_args(args): - parser = argparse.ArgumentParser() - parser.add_argument('-p', '--json_parameter_file', type=str, - help="JSON parameter file", required=True) - parser.add_argument('-r', '--galaxy_root', type=str, - help="Galaxy root dir", required=True) - parser.add_argument('-c', '--data_conf', type=str, - help="Galaxy data types conf file for mapping file types", required=True) - parser.add_argument('-t', '--token', type=str, - help="Optional OpenID/GenomeSpace token if not passed in as part of the URL as URLs^Token." - " If none, the environment variable GS_TOKEN will be respected.", required=False) - - args = parser.parse_args(args[1:]) - return args - - -def main(): - args = process_args(sys.argv) - download_from_genomespace_importer(args.json_parameter_file, args.galaxy_root, args.data_conf, args.token or os.environ.get("GS_TOKEN")) - - -if __name__ == "__main__": - sys.exit(main()) diff --git a/tools/genomespace/genomespace_importer.xml b/tools/genomespace/genomespace_importer.xml deleted file mode 100644 index 543a540a3e2..00000000000 --- a/tools/genomespace/genomespace_importer.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - receive data from GenomeSpace - - - #set $token = $__user__.preferences.get('genomespace_token', None) - #assert $token, Exception('Invalid token. You must be logged into GenomeSpace through OpenID.') - $token - - - - - - - - - - - -This tool allows you to import data from GenomeSpace. Click the Browse button to select a file to import. - -To use this tool, you must have logged in using your GenomeSpace OpenID. -You can associate your OpenID credentials under the User Preferences panel. -Click here_ to refresh your GenomeSpace token. - -.. _here: ${static_path}/../user/openid_auth?openid_provider=genomespace&auto_associate=True - - - - diff --git a/tools/genomespace/genomespace_push.xml b/tools/genomespace/genomespace_push.xml deleted file mode 100644 index ce978e9c6af..00000000000 --- a/tools/genomespace/genomespace_push.xml +++ /dev/null @@ -1,36 +0,0 @@ - -