Skip to content

Commit d910ff0

Browse files
authored
Prevent fetch from downloading unnecessary data and skipping data download for certain instruments (#175)
* fixes for over-extensive data downloads and skipping certain instruments * fixes based on PR feedback #175
1 parent ba2e901 commit d910ff0

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/virtualship/cli/_fetch.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ def _fetch(path: str | Path, username: str | None, password: str | None) -> None
3838
be provided on prompt, via command line arguments, or via a YAML config file. Run
3939
`virtualship fetch` on an expedition for more info.
4040
"""
41+
from virtualship.expedition.instrument_type import InstrumentType
42+
4143
if sum([username is None, password is None]) == 1:
4244
raise ValueError("Both username and password must be provided when using CLI.")
4345

@@ -88,10 +90,10 @@ def _fetch(path: str | Path, username: str | None, password: str | None) -> None
8890
{"XBT", "CTD", "SHIP_UNDERWATER_ST"}
8991
& set(instrument.name for instrument in instruments_in_schedule)
9092
)
91-
or hasattr(ship_config, "ship_underwater_st_config")
92-
or hasattr(ship_config, "adcp_config")
93+
or ship_config.ship_underwater_st_config is not None
94+
or ship_config.adcp_config is not None
9395
):
94-
print("Ship data will be downloaded")
96+
print("Ship data will be downloaded. Please wait...")
9597

9698
# Define all ship datasets to download, including bathymetry
9799
download_dict = {
@@ -145,8 +147,8 @@ def _fetch(path: str | Path, username: str | None, password: str | None) -> None
145147
complete_download(download_folder)
146148
click.echo("Ship data download based on space-time region completed.")
147149

148-
if "DRIFTER" in instruments_in_schedule:
149-
print("Drifter data will be downloaded")
150+
if InstrumentType.DRIFTER in instruments_in_schedule:
151+
print("Drifter data will be downloaded. Please wait...")
150152
drifter_download_dict = {
151153
"UVdata": {
152154
"dataset_id": "cmems_mod_glo_phy-cur_anfc_0.083deg_PT6H-i",
@@ -188,8 +190,8 @@ def _fetch(path: str | Path, username: str | None, password: str | None) -> None
188190
complete_download(download_folder)
189191
click.echo("Drifter data download based on space-time region completed.")
190192

191-
if "ARGO_FLOAT" in instruments_in_schedule:
192-
print("Argo float data will be downloaded")
193+
if InstrumentType.ARGO_FLOAT in instruments_in_schedule:
194+
print("Argo float data will be downloaded. Please wait...")
193195
argo_download_dict = {
194196
"UVdata": {
195197
"dataset_id": "cmems_mod_glo_phy-cur_anfc_0.083deg_PT6H-i",

0 commit comments

Comments
 (0)