From a17fdf68df4ba10f0b555b451264886723d92baa Mon Sep 17 00:00:00 2001 From: Jorge Fernandez Hernandez Date: Fri, 18 Oct 2024 09:23:06 +0200 Subject: [PATCH 1/4] GAIAMNGT-1700 the path will be empty if it represents a file --- astroquery/gaia/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/astroquery/gaia/core.py b/astroquery/gaia/core.py index 601590a054..be020010d0 100644 --- a/astroquery/gaia/core.py +++ b/astroquery/gaia/core.py @@ -258,7 +258,7 @@ def load_data(self, ids, *, data_release=None, data_structure='INDIVIDUAL', retr log.debug(f"Directory where the data will be saved: {path}") - if path != '': + if path: if not os.path.isdir(path): try: os.mkdir(path) From e6a6f74a2a239218ec152ebd70c9f7b2aa943494 Mon Sep 17 00:00:00 2001 From: Jorge Fernandez Hernandez Date: Sat, 9 Nov 2024 08:05:34 +0100 Subject: [PATCH 2/4] GAIAPCR-1331 the output file name now include microsecod resolution --- astroquery/gaia/core.py | 4 +-- astroquery/gaia/tests/test_gaiatap.py | 37 +++++++++++++++++++-------- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/astroquery/gaia/core.py b/astroquery/gaia/core.py index be020010d0..e455068e48 100644 --- a/astroquery/gaia/core.py +++ b/astroquery/gaia/core.py @@ -239,13 +239,13 @@ def load_data(self, ids, *, data_release=None, data_structure='INDIVIDUAL', retr now = datetime.datetime.now(datetime.timezone.utc) if not dump_to_file: - now_formatted = now.strftime("%Y%m%d_%H%M%S") + now_formatted = now.strftime("%Y%m%d_%H%M%S.%f") temp_dirname = "temp_" + now_formatted downloadname_formated = "download_" + now_formatted output_file = os.path.join(os.getcwd(), temp_dirname, downloadname_formated) else: - output_file = 'datalink_output_' + now.strftime("%Y%m%dT%H%M%S") + '.zip' + output_file = 'datalink_output_' + now.strftime("%Y%m%dT%H%M%S.%f") + '.zip' output_file_specified = True output_file = os.path.abspath(output_file) log.info(f"DataLink products will be stored in the {output_file} file") diff --git a/astroquery/gaia/tests/test_gaiatap.py b/astroquery/gaia/tests/test_gaiatap.py index ac315d1874..a202e28556 100644 --- a/astroquery/gaia/tests/test_gaiatap.py +++ b/astroquery/gaia/tests/test_gaiatap.py @@ -87,7 +87,7 @@ RADIUS = 1 * u.deg SKYCOORD = SkyCoord(ra=19 * u.deg, dec=20 * u.deg, frame="icrs") -FAKE_TIME = datetime.datetime(2024, 1, 1, 0, 0, 59) +FAKE_TIME = datetime.datetime(2024, 1, 1, 0, 0, 59, 1) @pytest.fixture @@ -999,9 +999,12 @@ def test_datalink_querier_load_data_fits(mock_datalink_querier_fits): assert not os.path.exists(datalink_output) -def test_load_data_vot(monkeypatch, tmp_path, tmp_path_factory): +def test_load_data_vot(monkeypatch, tmp_path, tmp_path_factory, patch_datetime_now): + + assert datetime.datetime.now(datetime.timezone.utc) == FAKE_TIME + now = datetime.datetime.now(datetime.timezone.utc) - output_file = 'datalink_output_' + now.strftime("%Y%m%dT%H%M%S") + '.zip' + output_file = 'datalink_output_' + now.strftime("%Y%m%dT%H%M%S.%f") + '.zip' path = Path(os.getcwd(), output_file) @@ -1076,9 +1079,12 @@ def load_data_monkeypatched(self, params_dict, output_file, verbose): path.unlink() -def test_load_data_csv(monkeypatch, tmp_path, tmp_path_factory): +def test_load_data_csv(monkeypatch, tmp_path, tmp_path_factory, patch_datetime_now): + + assert datetime.datetime.now(datetime.timezone.utc) == FAKE_TIME + now = datetime.datetime.now(datetime.timezone.utc) - output_file = 'datalink_output_' + now.strftime("%Y%m%dT%H%M%S") + '.zip' + output_file = 'datalink_output_' + now.strftime("%Y%m%dT%H%M%S.%f") + '.zip' path = Path(os.getcwd(), output_file) @@ -1112,9 +1118,12 @@ def load_data_monkeypatched(self, params_dict, output_file, verbose): path.unlink() -def test_load_data_ecsv(monkeypatch, tmp_path, tmp_path_factory): +def test_load_data_ecsv(monkeypatch, tmp_path, tmp_path_factory, patch_datetime_now): + + assert datetime.datetime.now(datetime.timezone.utc) == FAKE_TIME + now = datetime.datetime.now(datetime.timezone.utc) - output_file = 'datalink_output_' + now.strftime("%Y%m%dT%H%M%S") + '.zip' + output_file = 'datalink_output_' + now.strftime("%Y%m%dT%H%M%S.%f") + '.zip' path = Path(os.getcwd(), output_file) @@ -1148,9 +1157,12 @@ def load_data_monkeypatched(self, params_dict, output_file, verbose): path.unlink() -def test_load_data_linking_parameter(monkeypatch, tmp_path): +def test_load_data_linking_parameter(monkeypatch, tmp_path, patch_datetime_now): + + assert datetime.datetime.now(datetime.timezone.utc) == FAKE_TIME + now = datetime.datetime.now(datetime.timezone.utc) - output_file = 'datalink_output_' + now.strftime("%Y%m%dT%H%M%S") + '.zip' + output_file = 'datalink_output_' + now.strftime("%Y%m%dT%H%M%S.%f") + '.zip' path = Path(os.getcwd(), output_file) @@ -1185,9 +1197,12 @@ def load_data_monkeypatched(self, params_dict, output_file, verbose): @pytest.mark.parametrize("linking_param", ['TRANSIT_ID', 'IMAGE_ID']) -def test_load_data_linking_parameter_with_values(monkeypatch, tmp_path, linking_param): +def test_load_data_linking_parameter_with_values(monkeypatch, tmp_path, linking_param, patch_datetime_now): + + assert datetime.datetime.now(datetime.timezone.utc) == FAKE_TIME + now = datetime.datetime.now(datetime.timezone.utc) - output_file = 'datalink_output_' + now.strftime("%Y%m%dT%H%M%S") + '.zip' + output_file = 'datalink_output_' + now.strftime("%Y%m%dT%H%M%S.%f") + '.zip' path = Path(os.getcwd(), output_file) From 03c77ffa09d125d6919ca117df3076ea9b65df12 Mon Sep 17 00:00:00 2001 From: Jorge Fernandez Hernandez Date: Sat, 9 Nov 2024 08:19:35 +0100 Subject: [PATCH 3/4] GAIAPCR-1331 Include PR --- CHANGES.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index 14a278fd84..352e73a41e 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -185,6 +185,8 @@ gaia - New retrieval types for datalink (Gaia DR4 release). [#3110] +- The output file name built by the method load_data, includes microsecond resolution. This is based on the previous PR [#3014]. [#3130] + jplhorizons ^^^^^^^^^^^ From ce1615748a26b5c34845832557c510e8fa8d849f Mon Sep 17 00:00:00 2001 From: Jorge Fernandez Hernandez Date: Mon, 11 Nov 2024 08:46:14 +0100 Subject: [PATCH 4/4] GAIAPCR-1331 Include Update description of the parameter dump_to_file --- astroquery/gaia/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/astroquery/gaia/core.py b/astroquery/gaia/core.py index e455068e48..87947c7ad6 100644 --- a/astroquery/gaia/core.py +++ b/astroquery/gaia/core.py @@ -224,7 +224,7 @@ def load_data(self, ids, *, data_release=None, data_structure='INDIVIDUAL', retr dump_to_file: boolean, optional, default False. If it is true, a compressed directory named "datalink_output_.zip" with all the DataLink files is made in the current working directory. The format follows the ISO 8601 standard: - "yyyymmddThhmmss". + "YYYYMMDD_HHMMSS.mmmmmm". overwrite_output_file : boolean, optional, default False To overwrite the output file ("datalink_output.zip") if it already exists. verbose : bool, optional, default 'False'