sparclclient 1.2.2b7__py2.py3-none-any.whl → 1.2.2b9__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sparcl/__init__.py +1 -1
- sparcl/client.py +24 -14
- sparcl/exceptions.py +7 -1
- sparcl/gather_2d.py +1 -1
- sparcl/notebooks/sparcl-examples.ipynb +823 -435
- {sparclclient-1.2.2b7.dist-info → sparclclient-1.2.2b9.dist-info}/METADATA +1 -1
- sparclclient-1.2.2b9.dist-info/RECORD +19 -0
- sparcl/notebooks/UNPUBLISHED/SPARCL_client_method_tests.ipynb +0 -2177
- sparcl/notebooks/UNPUBLISHED/sparcl_auth_cases.ipynb +0 -621
- sparclclient-1.2.2b7.dist-info/RECORD +0 -21
- {sparclclient-1.2.2b7.dist-info → sparclclient-1.2.2b9.dist-info}/LICENSE +0 -0
- {sparclclient-1.2.2b7.dist-info → sparclclient-1.2.2b9.dist-info}/WHEEL +0 -0
sparcl/__init__.py
CHANGED
sparcl/client.py
CHANGED
|
@@ -250,17 +250,19 @@ class SparclClient: # was SparclApi()
|
|
|
250
250
|
email (:obj:`str`): User login email.
|
|
251
251
|
|
|
252
252
|
password (:obj:`str`, optional): User SSO password.
|
|
253
|
-
If not given, the output will
|
|
254
|
-
|
|
253
|
+
If not given, the output will prompt the user
|
|
254
|
+
to enter in their SSO password.
|
|
255
255
|
|
|
256
256
|
Returns:
|
|
257
257
|
None.
|
|
258
258
|
|
|
259
259
|
Example:
|
|
260
|
-
>>>
|
|
261
|
-
|
|
260
|
+
>>>
|
|
261
|
+
>> client = SparclClient()
|
|
262
|
+
>> client.login('test_user@noirlab.edu', 'testpw')
|
|
262
263
|
Logged in successfully with email='test_user@noirlab.edu'
|
|
263
264
|
"""
|
|
265
|
+
|
|
264
266
|
if email is None: # "logout"
|
|
265
267
|
old_email = self.session.auth[0] if self.session.auth else None
|
|
266
268
|
self.session.auth = None
|
|
@@ -308,9 +310,9 @@ class SparclClient: # was SparclApi()
|
|
|
308
310
|
Example:
|
|
309
311
|
>>> client = SparclClient()
|
|
310
312
|
>>> client.logout()
|
|
311
|
-
Logged-out successfully.
|
|
312
|
-
Previously logged-in with email test_user@noirlab.edu.
|
|
313
|
+
Logged-out successfully. Previously logged-in with email None.
|
|
313
314
|
"""
|
|
315
|
+
|
|
314
316
|
return self.login(None)
|
|
315
317
|
|
|
316
318
|
@property
|
|
@@ -322,8 +324,8 @@ class SparclClient: # was SparclApi()
|
|
|
322
324
|
auth_status = response.json()
|
|
323
325
|
#! print(f"DBG authorized: {auth_status=}")
|
|
324
326
|
|
|
325
|
-
username = auth_status.get(
|
|
326
|
-
all_private_drs = set(auth_status.get("All_Private_Datasets"))
|
|
327
|
+
username = auth_status.get("Loggedin_User")
|
|
328
|
+
#! all_private_drs = set(auth_status.get("All_Private_Datasets"))
|
|
327
329
|
all_public_drs = set(auth_status.get("All_Public_Datasets"))
|
|
328
330
|
auth_drs = set(auth_status.get("Authorized_Private_Datasets"))
|
|
329
331
|
res = dict(
|
|
@@ -446,7 +448,8 @@ class SparclClient: # was SparclApi()
|
|
|
446
448
|
Example:
|
|
447
449
|
>>> client = SparclClient()
|
|
448
450
|
>>> sorted(client.get_available_fields())
|
|
449
|
-
['data_release', 'datasetgroup', 'dateobs', 'dateobs_center', 'dec', '
|
|
451
|
+
['data_release', 'datasetgroup', 'dateobs', 'dateobs_center', 'dec', 'exptime', 'extra_files', 'file', 'flux', 'instrument', 'ivar', 'mask', 'model', 'ra', 'redshift', 'redshift_err', 'redshift_warning', 'site', 'sparcl_id', 'specid', 'specprimary', 'spectype', 'survey', 'targetid', 'telescope', 'updated', 'wave_sigma', 'wavelength', 'wavemax', 'wavemin']
|
|
452
|
+
|
|
450
453
|
""" # noqa: E501
|
|
451
454
|
|
|
452
455
|
drs = self.fields.all_drs if dataset_list is None else dataset_list
|
|
@@ -465,7 +468,7 @@ class SparclClient: # was SparclApi()
|
|
|
465
468
|
Example:
|
|
466
469
|
>>> client = SparclClient()
|
|
467
470
|
>>> client.version
|
|
468
|
-
|
|
471
|
+
11.0
|
|
469
472
|
"""
|
|
470
473
|
|
|
471
474
|
if self.apiversion is None:
|
|
@@ -655,8 +658,9 @@ class SparclClient: # was SparclApi()
|
|
|
655
658
|
are NOT stored in the SPARCL database.
|
|
656
659
|
|
|
657
660
|
Example:
|
|
658
|
-
>>> client = SparclClient(url=
|
|
659
|
-
>>>
|
|
661
|
+
>>> client = SparclClient(url=_DEV)
|
|
662
|
+
>>> found = client.find(outfields=['specid'], limit=2)
|
|
663
|
+
>>> specids = [f.specid for f in found.records]
|
|
660
664
|
>>> client.missing_specids(specids + ['bad_id'])
|
|
661
665
|
['bad_id']
|
|
662
666
|
"""
|
|
@@ -743,7 +747,7 @@ class SparclClient: # was SparclApi()
|
|
|
743
747
|
|
|
744
748
|
Example:
|
|
745
749
|
>>> client = SparclClient()
|
|
746
|
-
>>> ids =
|
|
750
|
+
>>> ids = client.find(limit=1).ids
|
|
747
751
|
>>> inc = ['sparcl_id', 'flux', 'wavelength', 'model']
|
|
748
752
|
>>> ret = client.retrieve(uuid_list=ids, include=inc)
|
|
749
753
|
>>> type(ret.records[0].wavelength)
|
|
@@ -766,6 +770,7 @@ class SparclClient: # was SparclApi()
|
|
|
766
770
|
format = "pkl" # 'json',
|
|
767
771
|
chunk = 500
|
|
768
772
|
|
|
773
|
+
orig_dataset_list = dataset_list
|
|
769
774
|
if dataset_list is None:
|
|
770
775
|
dataset_list = self.fields.all_drs
|
|
771
776
|
assert isinstance(
|
|
@@ -807,8 +812,13 @@ class SparclClient: # was SparclApi()
|
|
|
807
812
|
#! "chunk_len": chunk,
|
|
808
813
|
"format": format,
|
|
809
814
|
#! "1thread": "yes", # @@@ 7.3.2023
|
|
810
|
-
"dataset_list": ",".join(dataset_list),
|
|
815
|
+
#!"dataset_list": ",".join(dataset_list),
|
|
811
816
|
}
|
|
817
|
+
# Do not put dataset_list in server call if it wasn't in client call.
|
|
818
|
+
# Else will interfer with defaulting behavior of AUTH (DLS-504).
|
|
819
|
+
if orig_dataset_list is not None:
|
|
820
|
+
uparams["dataset_list"] = ",".join(dataset_list)
|
|
821
|
+
|
|
812
822
|
qstr = urlencode(uparams)
|
|
813
823
|
|
|
814
824
|
#!url = f'{self.apiurl}/retrieve/?{qstr}'
|
sparcl/exceptions.py
CHANGED
|
@@ -21,6 +21,8 @@ def genSparclException(response, verbose=False):
|
|
|
21
21
|
return UnknownField(status.get("errorMessage"))
|
|
22
22
|
elif status.get("errorCode") == "BADCONST":
|
|
23
23
|
return BadSearchConstraint(status.get("errorMessage"))
|
|
24
|
+
elif status.get("errorCode") == "NODRACCESS":
|
|
25
|
+
return AccessNotAllowed(status.get("errorMessage"))
|
|
24
26
|
else:
|
|
25
27
|
return UnknownServerError(
|
|
26
28
|
f"{status.get('errorMessage')} "
|
|
@@ -34,7 +36,7 @@ class BaseSparclException(Exception):
|
|
|
34
36
|
|
|
35
37
|
error_code = "UNKNOWN"
|
|
36
38
|
error_message = "<NA>"
|
|
37
|
-
traceback =
|
|
39
|
+
traceback = True
|
|
38
40
|
|
|
39
41
|
def get_subclass_name(self):
|
|
40
42
|
return self.__class__.__name__
|
|
@@ -140,4 +142,8 @@ class NoIDs(BaseSparclException):
|
|
|
140
142
|
error_code = "NOIDS"
|
|
141
143
|
|
|
142
144
|
|
|
145
|
+
class AccessNotAllowed(BaseSparclException):
|
|
146
|
+
error_code = "DSDENIED"
|
|
147
|
+
|
|
148
|
+
|
|
143
149
|
# error_code values should be no bigger than 8 characters 12345678
|
sparcl/gather_2d.py
CHANGED
|
@@ -195,7 +195,7 @@ def align_records(records, fields=["flux", "wavelength"], precision=7):
|
|
|
195
195
|
>>> got = client.retrieve(found.ids, include=specflds)
|
|
196
196
|
>>> ar_dict, grid = align_records(got.records, fields=specflds)
|
|
197
197
|
>>> ar_dict['model'].shape
|
|
198
|
-
(21,
|
|
198
|
+
(21, 4669)
|
|
199
199
|
|
|
200
200
|
"""
|
|
201
201
|
# Report Garbage In
|