Loading
Fix jobs API not allowing dates for ``date_range_min`` and ``date_range_max``
Dates (without time) are specifically mentioned in our parameters' documentation: `Limit listing of jobs to those that are updated after specified date (e.g. '2014-01-01')` Follow-up on https://github.com/galaxyproject/galaxy/pull/14281 , which broke backward compatibility as shown in this traceback: ``` _________________________ TestGalaxyJobs.test_get_jobs _________________________ has_gi = <bioblend._tests.TestGalaxyJobs.TestGalaxyJobs testMethod=test_get_jobs> args = (), kwargs = {} tools = [{'config_file': '/home/runner/work/bioblend/bioblend/galaxy-release_22.05/tools/data_source/upload.xml', 'description...ata_source/ebi_sra.xml', 'description': 'ENA SRA', 'edam_operations': ['operation_0224'], 'edam_topics': [], ...}, ...] tool_ids = ['upload1', 'ucsc_table_direct1', 'ucsc_table_direct_archaea1', 'ncbi_datasets_source', 'sra_source', 'ebi_sra_main', ...] def wrapped_method(has_gi, *args, **kwargs): tools = has_gi.gi.tools.get_tools() # In panels by default, so flatten out sections... tool_ids = [_["id"] for _ in tools] if tool_id not in tool_ids: raise unittest.SkipTest(MISSING_TOOL_MESSAGE % tool_id) > return method(has_gi, *args, **kwargs) bioblend/_tests/test_util.py:113: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ bioblend/_tests/TestGalaxyJobs.py:46: in test_get_jobs jobs = self.gi.jobs.get_jobs(date_range_max=yesterday.strftime("%Y-%m-%d"), history_id=self.history_id) bioblend/galaxy/jobs/__init__.py:136: in get_jobs return self._get(params=params) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <bioblend.galaxy.jobs.JobsClient object at 0x7f36a493a250>, id = None deleted = False, contents = False, url = 'http://localhost:8080/api/jobs' params = {'date_range_max': '2022-07-11', 'history_id': '915ae9a80309f157', 'limit': 500, 'offset': 0} json = True def _get( self, id: Optional[str] = None, deleted: bool = False, contents: bool = False, url: Optional[str] = None, params=None, json: bool = True, ): """ Do a GET request, composing the URL from ``id``, ``deleted`` and ``contents``. Alternatively, an explicit ``url`` can be provided. If ``json`` is set to ``True``, return a decoded JSON object (and treat an empty or undecodable response as an error). The request will optionally be retried as configured by ``max_get_retries`` and ``get_retry_delay``: this offers some resilience in the presence of temporary failures. :return: The decoded response if ``json`` is set to ``True``, otherwise the response object """ if not url: url = self._make_url(module_id=id, deleted=deleted, contents=contents) attempts_left = self.max_get_retries() retry_delay = self.get_retry_delay() bioblend.log.debug("GET - attempts left: %s; retry delay: %s", attempts_left, retry_delay) msg = "" while attempts_left > 0: attempts_left -= 1 try: r = self.gi.make_get_request(url, params=params) except requests.exceptions.ConnectionError as e: msg = str(e) r = requests.Response() # empty Response object used when raising ConnectionError else: if r.status_code == 200: if not json: return r elif not r.content: msg = "GET: empty response" else: try: return r.json() except ValueError: msg = f"GET: invalid JSON : {r.content!r}" else: msg = f"GET: error {r.status_code}: {r.content!r}" msg = f"{msg}, {attempts_left} attempts left" if attempts_left <= 0: bioblend.log.error(msg) raise ConnectionError( msg, body=r.text, > status_code=r.status_code, ) E bioblend.ConnectionError: GET: error 400: b'{"err_msg":"1 validation error for Request\\nquery -> date_range_max\\n invalid datetime format (type=value_error.datetime)","err_code":400008,"validation_errors":[{"loc":["query","date_range_max"],"msg":"invalid datetime format","type":"value_error.datetime"}]}', 0 attempts left: {"err_msg":"1 validation error for Request\nquery -> date_range_max\n invalid datetime format (type=value_error.datetime)","err_code":400008,"validation_errors":[{"loc":["query","date_range_max"],"msg":"invalid datetime format","type":"value_error.datetime"}]} bioblend/galaxy/client.py:166: ConnectionError ``` from BioBlend CI tests: https://github.com/galaxyproject/bioblend/runs/7292858519?check_suite_focus=true