-
-
Notifications
You must be signed in to change notification settings - Fork 390
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
get_obs_products method supports product_type parameter as string or list #2995
base: main
Are you sure you want to change the base?
Changes from all commits
2d9d5d1
0d8d1fb
39a94cf
a041b27
e190e95
0b22266
04b61de
d7bcbbc
fabe812
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -965,10 +965,11 @@ def get_obs_products(self, *, observation_id=None, cal_level="ALL", | |
composite products based on level 2 products). To request upper | ||
levels, please use get_related_observations functions first. | ||
Possible values: 'ALL', 3, 2, 1, -1 | ||
product_type : str, optional, default None | ||
List only products of the given type. If None, all products are \ | ||
listed. Possible values: 'thumbnail', 'preview', 'auxiliary', \ | ||
'science'. | ||
product_type : str or list, optional, default None | ||
List only products of the given type. If None, empty or an element | ||
of the list is empty, all products are listed. | ||
Possible values: 'thumbnail', 'preview', 'auxiliary', | ||
'science', 'info', ['science', 'preview']... | ||
output_file : str, optional | ||
Output file. If no value is provided, a temporary one is created. | ||
|
||
|
@@ -978,6 +979,8 @@ def get_obs_products(self, *, observation_id=None, cal_level="ALL", | |
Returns the local path where the product(s) are saved. | ||
""" | ||
|
||
if (type(product_type) is list and '' in product_type) or not product_type: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. isinstance(product_type, list) is usually cleaner than what is there, but this is nitpicking. The bigger issue is that this will be True for a list that looks like: Howeverk duck-typing is real, and the documentation above is clear, so dropping these two lines should be enough. If the user provides a string, or a list that only contains There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With empty element, in the list or in the string, the code will download all products (product_type = None). In your example: ['', 'science', 'info'] is a malformed list so, all products will be downloaded. |
||
product_type = None | ||
if observation_id is None: | ||
raise ValueError(self.REQUESTED_OBSERVATION_ID) | ||
plane_ids, max_cal_level = self._get_plane_id(observation_id=observation_id) | ||
|
@@ -994,10 +997,16 @@ def get_obs_products(self, *, observation_id=None, cal_level="ALL", | |
max_cal_level=max_cal_level, | ||
is_url=True) | ||
params_dict['planeid'] = plane_ids | ||
|
||
if type(product_type) is list: | ||
tap_product_type = ",".join(str(elem) for elem in product_type) | ||
else: | ||
tap_product_type = product_type | ||
|
||
self.__set_additional_parameters(param_dict=params_dict, | ||
cal_level=cal_level, | ||
max_cal_level=max_cal_level, | ||
product_type=product_type) | ||
product_type=tap_product_type) | ||
output_file_full_path, output_dir = self.__set_dirs(output_file=output_file, | ||
observation_id=observation_id) | ||
# Get file name only | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are there any more options? If yes, and we know them, then please list, otherwise drop the
...
. No need to allow an empty list, the defaultNone
should cover that use case.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used ... because in the list you can provide any combination of 1, 2, 3, 4 or 5 elements, ['science', 'preview'] is just one example of all of them. If you want we can better express this idea.