Skip to content

Commit d78af7b

Browse files
authored
Merge pull request #3059 from esdc-esac-esa-int/ESA_ehst_show_warning_no_volume
Include warning in get_datalabs_path method for ehst when the data volume is not mounted in DataLabs
2 parents 0002370 + 0b6a016 commit d78af7b

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

CHANGES.rst

+5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ alma
1515

1616
- Added support for frequency_resolution in KHz [#3035]
1717

18+
ehst
19+
^^^^
20+
21+
- Include warning in get_datalabs_path method for ehst when the data volume is not mounted in DataLabs [#3059]
22+
1823
gama
1924
^^^^
2025

astroquery/esa/hubble/core.py

+24-3
Original file line numberDiff line numberDiff line change
@@ -1027,17 +1027,38 @@ def get_datalabs_path(self, filename, default_volume=None):
10271027
if job is None:
10281028
return None
10291029

1030+
query2 = f"select observation_id from ehst.artifact where file_name = '{filename}'"
1031+
job2 = self.query_tap(query=query2)
1032+
if job2 is None:
1033+
return None
1034+
1035+
observation_id = job2["observation_id"][0]
1036+
query3 = f"select instrument_name from ehst.observation where observation_id = '{observation_id}'"
1037+
job3 = self.query_tap(query=query3)
1038+
if job3 is None:
1039+
return None
1040+
1041+
instrument_name = job3["instrument_name"][0]
1042+
10301043
# Output example for path: /hstdata/hstdata_i/i/b4x/04, or hstdata_i/i/b4x/04 for path_parsed
10311044
path = self._get_decoded_string(string=job["file_path"][0])
10321045
path_parsed = path.split("hstdata/", 1)[1]
10331046

10341047
# Automatic fill: convert /hstdata/hstdata_i/i/b4x/04 to /data/user/hub_hstdata_i/i/b4x/04
10351048
if default_volume is None:
1036-
return "/data/user/hub_" + path_parsed + "/" + filename
1049+
full_path = "/data/user/hub_" + path_parsed + "/" + filename
1050+
file_exists = os.path.exists(full_path)
10371051

10381052
# Use the path provided by the user: convert /hstdata/hstdata_i/i/b4x/04 to /data/user/myPath/i/b4x/04
1039-
path_parsed = path_parsed.split("/", 1)[1]
1040-
return "/data/user/" + default_volume + "/" + path_parsed + "/" + filename
1053+
else:
1054+
path_parsed = path_parsed.split("/", 1)[1]
1055+
full_path = "/data/user/" + default_volume + "/" + path_parsed + "/" + filename
1056+
file_exists = os.path.exists(full_path)
1057+
1058+
if not file_exists:
1059+
warnings.warn(f"File {filename} is not accessible. Please ensure the {instrument_name} "
1060+
"volume is mounted in your ESA Datalabs instance.")
1061+
return full_path
10411062

10421063

10431064
ESAHubble = ESAHubbleClass()

0 commit comments

Comments
 (0)