Skip to content

Commit e6a6f74

Browse files
Jorge Fernandez HernandezJorge Fernandez Hernandez
authored andcommitted
GAIAPCR-1331 the output file name now include microsecod resolution
1 parent a17fdf6 commit e6a6f74

File tree

2 files changed

+28
-13
lines changed

2 files changed

+28
-13
lines changed

astroquery/gaia/core.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,13 +239,13 @@ def load_data(self, ids, *, data_release=None, data_structure='INDIVIDUAL', retr
239239

240240
now = datetime.datetime.now(datetime.timezone.utc)
241241
if not dump_to_file:
242-
now_formatted = now.strftime("%Y%m%d_%H%M%S")
242+
now_formatted = now.strftime("%Y%m%d_%H%M%S.%f")
243243
temp_dirname = "temp_" + now_formatted
244244
downloadname_formated = "download_" + now_formatted
245245
output_file = os.path.join(os.getcwd(), temp_dirname, downloadname_formated)
246246

247247
else:
248-
output_file = 'datalink_output_' + now.strftime("%Y%m%dT%H%M%S") + '.zip'
248+
output_file = 'datalink_output_' + now.strftime("%Y%m%dT%H%M%S.%f") + '.zip'
249249
output_file_specified = True
250250
output_file = os.path.abspath(output_file)
251251
log.info(f"DataLink products will be stored in the {output_file} file")

astroquery/gaia/tests/test_gaiatap.py

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
RADIUS = 1 * u.deg
8888
SKYCOORD = SkyCoord(ra=19 * u.deg, dec=20 * u.deg, frame="icrs")
8989

90-
FAKE_TIME = datetime.datetime(2024, 1, 1, 0, 0, 59)
90+
FAKE_TIME = datetime.datetime(2024, 1, 1, 0, 0, 59, 1)
9191

9292

9393
@pytest.fixture
@@ -999,9 +999,12 @@ def test_datalink_querier_load_data_fits(mock_datalink_querier_fits):
999999
assert not os.path.exists(datalink_output)
10001000

10011001

1002-
def test_load_data_vot(monkeypatch, tmp_path, tmp_path_factory):
1002+
def test_load_data_vot(monkeypatch, tmp_path, tmp_path_factory, patch_datetime_now):
1003+
1004+
assert datetime.datetime.now(datetime.timezone.utc) == FAKE_TIME
1005+
10031006
now = datetime.datetime.now(datetime.timezone.utc)
1004-
output_file = 'datalink_output_' + now.strftime("%Y%m%dT%H%M%S") + '.zip'
1007+
output_file = 'datalink_output_' + now.strftime("%Y%m%dT%H%M%S.%f") + '.zip'
10051008

10061009
path = Path(os.getcwd(), output_file)
10071010

@@ -1076,9 +1079,12 @@ def load_data_monkeypatched(self, params_dict, output_file, verbose):
10761079
path.unlink()
10771080

10781081

1079-
def test_load_data_csv(monkeypatch, tmp_path, tmp_path_factory):
1082+
def test_load_data_csv(monkeypatch, tmp_path, tmp_path_factory, patch_datetime_now):
1083+
1084+
assert datetime.datetime.now(datetime.timezone.utc) == FAKE_TIME
1085+
10801086
now = datetime.datetime.now(datetime.timezone.utc)
1081-
output_file = 'datalink_output_' + now.strftime("%Y%m%dT%H%M%S") + '.zip'
1087+
output_file = 'datalink_output_' + now.strftime("%Y%m%dT%H%M%S.%f") + '.zip'
10821088

10831089
path = Path(os.getcwd(), output_file)
10841090

@@ -1112,9 +1118,12 @@ def load_data_monkeypatched(self, params_dict, output_file, verbose):
11121118
path.unlink()
11131119

11141120

1115-
def test_load_data_ecsv(monkeypatch, tmp_path, tmp_path_factory):
1121+
def test_load_data_ecsv(monkeypatch, tmp_path, tmp_path_factory, patch_datetime_now):
1122+
1123+
assert datetime.datetime.now(datetime.timezone.utc) == FAKE_TIME
1124+
11161125
now = datetime.datetime.now(datetime.timezone.utc)
1117-
output_file = 'datalink_output_' + now.strftime("%Y%m%dT%H%M%S") + '.zip'
1126+
output_file = 'datalink_output_' + now.strftime("%Y%m%dT%H%M%S.%f") + '.zip'
11181127

11191128
path = Path(os.getcwd(), output_file)
11201129

@@ -1148,9 +1157,12 @@ def load_data_monkeypatched(self, params_dict, output_file, verbose):
11481157
path.unlink()
11491158

11501159

1151-
def test_load_data_linking_parameter(monkeypatch, tmp_path):
1160+
def test_load_data_linking_parameter(monkeypatch, tmp_path, patch_datetime_now):
1161+
1162+
assert datetime.datetime.now(datetime.timezone.utc) == FAKE_TIME
1163+
11521164
now = datetime.datetime.now(datetime.timezone.utc)
1153-
output_file = 'datalink_output_' + now.strftime("%Y%m%dT%H%M%S") + '.zip'
1165+
output_file = 'datalink_output_' + now.strftime("%Y%m%dT%H%M%S.%f") + '.zip'
11541166

11551167
path = Path(os.getcwd(), output_file)
11561168

@@ -1185,9 +1197,12 @@ def load_data_monkeypatched(self, params_dict, output_file, verbose):
11851197

11861198

11871199
@pytest.mark.parametrize("linking_param", ['TRANSIT_ID', 'IMAGE_ID'])
1188-
def test_load_data_linking_parameter_with_values(monkeypatch, tmp_path, linking_param):
1200+
def test_load_data_linking_parameter_with_values(monkeypatch, tmp_path, linking_param, patch_datetime_now):
1201+
1202+
assert datetime.datetime.now(datetime.timezone.utc) == FAKE_TIME
1203+
11891204
now = datetime.datetime.now(datetime.timezone.utc)
1190-
output_file = 'datalink_output_' + now.strftime("%Y%m%dT%H%M%S") + '.zip'
1205+
output_file = 'datalink_output_' + now.strftime("%Y%m%dT%H%M%S.%f") + '.zip'
11911206

11921207
path = Path(os.getcwd(), output_file)
11931208

0 commit comments

Comments
 (0)