sparclclient 1.2.3b8__tar.gz → 1.2.4b2__tar.gz
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.
- {sparclclient-1.2.3b8 → sparclclient-1.2.4b2}/PKG-INFO +2 -2
- {sparclclient-1.2.3b8 → sparclclient-1.2.4b2}/sparcl/Results.py +21 -3
- {sparclclient-1.2.3b8 → sparclclient-1.2.4b2}/sparcl/__init__.py +2 -1
- {sparclclient-1.2.3b8 → sparclclient-1.2.4b2}/sparcl/client.py +16 -2
- {sparclclient-1.2.3b8 → sparclclient-1.2.4b2}/tests/expected_pat.py +11 -7
- {sparclclient-1.2.3b8 → sparclclient-1.2.4b2}/tests/tests_api.py +17 -11
- {sparclclient-1.2.3b8 → sparclclient-1.2.4b2}/.github/workflows/django.yml +0 -0
- {sparclclient-1.2.3b8 → sparclclient-1.2.4b2}/.gitignore +0 -0
- {sparclclient-1.2.3b8 → sparclclient-1.2.4b2}/.pre-commit-config.yaml +0 -0
- {sparclclient-1.2.3b8 → sparclclient-1.2.4b2}/.readthedocs.yaml +0 -0
- {sparclclient-1.2.3b8 → sparclclient-1.2.4b2}/LICENSE +0 -0
- {sparclclient-1.2.3b8 → sparclclient-1.2.4b2}/Makefile +0 -0
- {sparclclient-1.2.3b8 → sparclclient-1.2.4b2}/README.md +0 -0
- {sparclclient-1.2.3b8 → sparclclient-1.2.4b2}/make.bat +0 -0
- {sparclclient-1.2.3b8 → sparclclient-1.2.4b2}/pyproject.toml +0 -0
- {sparclclient-1.2.3b8 → sparclclient-1.2.4b2}/requirements-client.txt +0 -0
- {sparclclient-1.2.3b8 → sparclclient-1.2.4b2}/requirements-internal.txt +0 -0
- {sparclclient-1.2.3b8 → sparclclient-1.2.4b2}/requirements.txt +0 -0
- {sparclclient-1.2.3b8 → sparclclient-1.2.4b2}/source/conf.py +0 -0
- {sparclclient-1.2.3b8 → sparclclient-1.2.4b2}/source/index.rst +0 -0
- {sparclclient-1.2.3b8 → sparclclient-1.2.4b2}/source/sparcl.rst +0 -0
- {sparclclient-1.2.3b8 → sparclclient-1.2.4b2}/sparcl/benchmarks/__init__.py +0 -0
- {sparclclient-1.2.3b8 → sparclclient-1.2.4b2}/sparcl/benchmarks/benchmarks.py +0 -0
- {sparclclient-1.2.3b8 → sparclclient-1.2.4b2}/sparcl/conf.py +0 -0
- {sparclclient-1.2.3b8 → sparclclient-1.2.4b2}/sparcl/exceptions.py +0 -0
- {sparclclient-1.2.3b8 → sparclclient-1.2.4b2}/sparcl/fields.py +0 -0
- {sparclclient-1.2.3b8 → sparclclient-1.2.4b2}/sparcl/gather_2d.py +0 -0
- {sparclclient-1.2.3b8 → sparclclient-1.2.4b2}/sparcl/notebooks/sparcl-examples.ipynb +0 -0
- {sparclclient-1.2.3b8 → sparclclient-1.2.4b2}/sparcl/resample_spectra.py +0 -0
- {sparclclient-1.2.3b8 → sparclclient-1.2.4b2}/sparcl/sparc.ini +0 -0
- {sparclclient-1.2.3b8 → sparclclient-1.2.4b2}/sparcl/type_conversion.py +0 -0
- {sparclclient-1.2.3b8 → sparclclient-1.2.4b2}/sparcl/unsupported.py +0 -0
- {sparclclient-1.2.3b8 → sparclclient-1.2.4b2}/sparcl/utils.py +0 -0
- {sparclclient-1.2.3b8 → sparclclient-1.2.4b2}/tests/expected_dev1.py +0 -0
- {sparclclient-1.2.3b8 → sparclclient-1.2.4b2}/tests/methods_tests.py +0 -0
- {sparclclient-1.2.3b8 → sparclclient-1.2.4b2}/tests/utils.py +0 -0
- {sparclclient-1.2.3b8 → sparclclient-1.2.4b2}/tox.ini +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
2
|
Name: sparclclient
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.4b2
|
|
4
4
|
Summary: A client for getting spectra and meta-data from NOIRLab.
|
|
5
5
|
Author-email: "S. Pothier" <datalab-spectro@noirlab.edu>
|
|
6
6
|
Description-Content-Type: text/markdown
|
|
@@ -10,7 +10,7 @@ from sparcl.utils import _AttrDict
|
|
|
10
10
|
# from sparcl.gather_2d import bin_spectra_records
|
|
11
11
|
import sparcl.exceptions as ex
|
|
12
12
|
from warnings import warn
|
|
13
|
-
|
|
13
|
+
import re
|
|
14
14
|
|
|
15
15
|
class Results(UserList):
|
|
16
16
|
def __init__(self, dict_list, client=None):
|
|
@@ -18,7 +18,7 @@ class Results(UserList):
|
|
|
18
18
|
self.hdr = dict_list[0]
|
|
19
19
|
self.recs = dict_list[1:]
|
|
20
20
|
self.client = client
|
|
21
|
-
self.fields = client.fields
|
|
21
|
+
self.fields = client.fields if client else []
|
|
22
22
|
self.to_science_fields()
|
|
23
23
|
|
|
24
24
|
# HACK 12/14/2023 -sp- to fix UUID problem presumably
|
|
@@ -41,7 +41,25 @@ class Results(UserList):
|
|
|
41
41
|
def info(self):
|
|
42
42
|
"""Info about this collection.
|
|
43
43
|
e.g. Warnings, parameters used to get the collection, etc."""
|
|
44
|
-
|
|
44
|
+
# Consolodate "Successfully found...." messages
|
|
45
|
+
cln_hdr = self.hdr.copy()
|
|
46
|
+
count = 0
|
|
47
|
+
success_msg = ""
|
|
48
|
+
info = []
|
|
49
|
+
for msg in cln_hdr['status']['info']:
|
|
50
|
+
if "Successfully" in msg:
|
|
51
|
+
matches = re.search('Successfully found ([0-9]*)', msg)
|
|
52
|
+
count += int(matches.groups()[0]) if len(matches.groups()) > 0 else 0 # noqa: E501
|
|
53
|
+
success_msg = msg
|
|
54
|
+
else:
|
|
55
|
+
info.append(msg)
|
|
56
|
+
|
|
57
|
+
if count > 0:
|
|
58
|
+
msg = re.sub(r'[0-9]+', str(count), success_msg, count=1)
|
|
59
|
+
info.append(msg)
|
|
60
|
+
|
|
61
|
+
cln_hdr['status']['info'] = info
|
|
62
|
+
return cln_hdr
|
|
45
63
|
|
|
46
64
|
@property
|
|
47
65
|
def count(self):
|
|
@@ -25,6 +25,7 @@ from warnings import warn
|
|
|
25
25
|
import pickle
|
|
26
26
|
import getpass
|
|
27
27
|
import datetime
|
|
28
|
+
import re
|
|
28
29
|
|
|
29
30
|
#!from pathlib import Path
|
|
30
31
|
import tempfile
|
|
@@ -223,7 +224,8 @@ class SparclClient: # was SparclApi()
|
|
|
223
224
|
msg = (
|
|
224
225
|
f"The SPARCL Client you are running expects an older "
|
|
225
226
|
f"version of the API services. "
|
|
226
|
-
f'Please upgrade to the latest "sparclclient"
|
|
227
|
+
f'Please upgrade to the latest "sparclclient" using '
|
|
228
|
+
f'"pip install --upgrade sparclclient". '
|
|
227
229
|
f"The Client you are using expected version "
|
|
228
230
|
f"{SparclClient.KNOWN_GOOD_API_VERSION} but got "
|
|
229
231
|
f"{self.apiversion} from the SPARCL Server "
|
|
@@ -944,7 +946,19 @@ class SparclClient: # was SparclApi()
|
|
|
944
946
|
print(f'{meta["status"]}')
|
|
945
947
|
|
|
946
948
|
if len(meta["status"].get("warnings", [])) > 0:
|
|
947
|
-
|
|
949
|
+
warnings = meta["status"].get("warnings")
|
|
950
|
+
if verbose:
|
|
951
|
+
print(f"There are {len(warnings)} warnings")
|
|
952
|
+
missingcount = 0
|
|
953
|
+
missing_message = re.sub(r' [0-9]+ ', ' %s ', warnings[0])
|
|
954
|
+
for i in warnings:
|
|
955
|
+
matches = re.match(r'.* ([0-9]+) out of the ([0-9]+).*', i)
|
|
956
|
+
if matches:
|
|
957
|
+
missingcount += int(matches.groups()[0])
|
|
958
|
+
|
|
959
|
+
# using old style substitution to avoid issue with the {} in the message # noqa: E501
|
|
960
|
+
warning_message = missing_message % (missingcount, limit, missingcount) # noqa: E501
|
|
961
|
+
warn(warning_message, stacklevel=2)
|
|
948
962
|
|
|
949
963
|
return Retrieved(results, client=self)
|
|
950
964
|
|
|
@@ -87,9 +87,11 @@ authorized_1 = {
|
|
|
87
87
|
"Loggedin_As": "test_user_1@noirlab.edu",
|
|
88
88
|
"Authorized_Datasets": {
|
|
89
89
|
"BOSS-DR16",
|
|
90
|
+
"BOSS-DR17",
|
|
90
91
|
"DESI-DR1",
|
|
91
92
|
"DESI-EDR",
|
|
92
93
|
"SDSS-DR16",
|
|
94
|
+
"SDSS-DR17",
|
|
93
95
|
"SDSS-DR17-test",
|
|
94
96
|
},
|
|
95
97
|
}
|
|
@@ -107,20 +109,22 @@ authorized_3 = {
|
|
|
107
109
|
# Private and Public
|
|
108
110
|
pub_1 = ["BOSS-DR16"]
|
|
109
111
|
pub_all = ["BOSS-DR16", "DESI-EDR", "SDSS-DR16"]
|
|
110
|
-
priv = ["DESI-DR1", "SDSS-DR17-test"]
|
|
112
|
+
priv = ["DESI-DR1", "SDSS-DR17-test", "BOSS-DR17", "SDSS-DR17"]
|
|
111
113
|
all_all = pub_all + priv
|
|
112
114
|
all_all.sort()
|
|
115
|
+
privpub1 = [pub_all[0], priv[0]]
|
|
113
116
|
unauth = "test_user_2@noirlab.edu"
|
|
114
117
|
#
|
|
115
|
-
auth_find_1 =
|
|
118
|
+
auth_find_1 = privpub1
|
|
119
|
+
auth_find_2 = ['DESI-DR1', 'DESI-EDR']
|
|
116
120
|
auth_find_3 = auth_retrieve_3 = (f"[DSDENIED] uname='{unauth}' is declined "
|
|
117
|
-
f"access to datasets={priv}; "
|
|
118
|
-
f"drs_requested={
|
|
121
|
+
f"access to datasets={[priv[0]]}; "
|
|
122
|
+
f"drs_requested={privpub1} "
|
|
119
123
|
f"my_auth={pub_all}")
|
|
120
124
|
auth_find_4 = auth_find_6 = pub_all
|
|
121
125
|
auth_find_5 = auth_retrieve_6 = ("[DSDENIED] uname='ANONYMOUS' is declined "
|
|
122
|
-
f"access to datasets={priv}; "
|
|
123
|
-
f"drs_requested={
|
|
126
|
+
f"access to datasets={[priv[0]]}; "
|
|
127
|
+
f"drs_requested={privpub1} "
|
|
124
128
|
f"my_auth={pub_all}")
|
|
125
|
-
auth_retrieve_1 = auth_retrieve_2 =
|
|
129
|
+
auth_retrieve_1 = auth_retrieve_2 = privpub1
|
|
126
130
|
auth_retrieve_4 = auth_retrieve_5 = auth_retrieve_7 = auth_retrieve_8 = pub_1
|
|
@@ -757,9 +757,10 @@ class AuthTest(unittest.TestCase):
|
|
|
757
757
|
|
|
758
758
|
# Dataset lists
|
|
759
759
|
cls.Pub = ["BOSS-DR16", "DESI-EDR", "SDSS-DR16"]
|
|
760
|
-
cls.Priv = ["DESI-DR1", "SDSS-DR17-test"]
|
|
760
|
+
cls.Priv = ["DESI-DR1", "SDSS-DR17-test", "BOSS-DR17", "SDSS-DR17"]
|
|
761
761
|
cls.PrivPub = cls.Priv + cls.Pub
|
|
762
762
|
cls.PrivPub.sort()
|
|
763
|
+
cls.PrivPub1 = [cls.Priv[0], cls.Pub[0]]
|
|
763
764
|
|
|
764
765
|
# Sample list of sparcl_ids from each data set
|
|
765
766
|
out = ["sparcl_id"]
|
|
@@ -773,7 +774,7 @@ class AuthTest(unittest.TestCase):
|
|
|
773
774
|
cls.uuid_priv = (
|
|
774
775
|
cls.client.find(
|
|
775
776
|
outfields=out,
|
|
776
|
-
constraints={"data_release": cls.Priv},
|
|
777
|
+
constraints={"data_release": [cls.Priv[0]]},
|
|
777
778
|
limit=2,
|
|
778
779
|
sort="sparcl_id",
|
|
779
780
|
)
|
|
@@ -920,7 +921,7 @@ class AuthTest(unittest.TestCase):
|
|
|
920
921
|
print(f"authorized_3: actual={actual}")
|
|
921
922
|
self.assertEqual(actual, exp.authorized_3, msg="Actual to Expected")
|
|
922
923
|
|
|
923
|
-
def auth_find(self, user, drs, expvar, limit=21000):
|
|
924
|
+
def auth_find(self, user, drs, expvar, cons={}, limit=21000):
|
|
924
925
|
expected = eval(expvar) # e.g. 'ep.retrieve_N'
|
|
925
926
|
#!print(f'{expvar}: {user=} {drs=} ')
|
|
926
927
|
self.silent_login(user, usrpw)
|
|
@@ -928,7 +929,11 @@ class AuthTest(unittest.TestCase):
|
|
|
928
929
|
out = self.outflds
|
|
929
930
|
try:
|
|
930
931
|
if drs is None:
|
|
931
|
-
found = self.client.find(
|
|
932
|
+
found = self.client.find(
|
|
933
|
+
outfields=out,
|
|
934
|
+
constraints=cons,
|
|
935
|
+
limit=limit
|
|
936
|
+
)
|
|
932
937
|
else:
|
|
933
938
|
found = self.client.find(
|
|
934
939
|
outfields=out,
|
|
@@ -982,7 +987,7 @@ class AuthTest(unittest.TestCase):
|
|
|
982
987
|
"""Test find method with authorized user; private data set specified.
|
|
983
988
|
Should find Authorized Private DR"""
|
|
984
989
|
exp = "exp.auth_find_1"
|
|
985
|
-
self.auth_find(self.auth_user, self.
|
|
990
|
+
self.auth_find(self.auth_user, self.PrivPub1, exp)
|
|
986
991
|
|
|
987
992
|
# | find | Auth | None | PASS |
|
|
988
993
|
# @skip("Does not return Priv") # @@@
|
|
@@ -990,13 +995,14 @@ class AuthTest(unittest.TestCase):
|
|
|
990
995
|
"""Test find method with authorized user; no data sets specified.
|
|
991
996
|
Should find Authorized Private DR"""
|
|
992
997
|
exp = "exp.auth_find_2"
|
|
993
|
-
|
|
998
|
+
constr = {'datasetgroup': ['DESI']}
|
|
999
|
+
self.auth_find(self.auth_user, None, exp, cons=constr)
|
|
994
1000
|
|
|
995
1001
|
# | find | Unauth | Priv,Pub | FAIL |
|
|
996
1002
|
def test_auth_find_3(self):
|
|
997
1003
|
"""Test find method with unauthorized user; private data set"""
|
|
998
1004
|
exp = "exp.auth_find_3"
|
|
999
|
-
self.auth_find(self.unauth_user, self.
|
|
1005
|
+
self.auth_find(self.unauth_user, self.PrivPub1, exp)
|
|
1000
1006
|
|
|
1001
1007
|
# | find | Unauth | None | PASS |
|
|
1002
1008
|
def test_auth_find_4(self):
|
|
@@ -1009,7 +1015,7 @@ class AuthTest(unittest.TestCase):
|
|
|
1009
1015
|
"""Test find method with anonymous user; private data set
|
|
1010
1016
|
specified"""
|
|
1011
1017
|
exp = "exp.auth_find_5"
|
|
1012
|
-
self.auth_find(None, self.
|
|
1018
|
+
self.auth_find(None, self.PrivPub1, exp)
|
|
1013
1019
|
|
|
1014
1020
|
# | find | Anon | None | PASS |
|
|
1015
1021
|
def test_auth_find_6(self):
|
|
@@ -1022,7 +1028,7 @@ class AuthTest(unittest.TestCase):
|
|
|
1022
1028
|
def test_auth_retrieve_1(self):
|
|
1023
1029
|
"""Retrieve method with authorized user; private data set specified"""
|
|
1024
1030
|
exp = "exp.auth_retrieve_1"
|
|
1025
|
-
self.auth_retrieve(self.auth_user, self.
|
|
1031
|
+
self.auth_retrieve(self.auth_user, self.PrivPub1, exp)
|
|
1026
1032
|
|
|
1027
1033
|
# | retrieve | Auth | None | PASS |
|
|
1028
1034
|
# @skip("Does not return Priv") # @@@
|
|
@@ -1036,7 +1042,7 @@ class AuthTest(unittest.TestCase):
|
|
|
1036
1042
|
def test_auth_retrieve_3(self):
|
|
1037
1043
|
"""Retrieve method with unauthorized user; private dataset specified"""
|
|
1038
1044
|
exp = "exp.auth_retrieve_3"
|
|
1039
|
-
self.auth_retrieve(self.unauth_user, self.
|
|
1045
|
+
self.auth_retrieve(self.unauth_user, self.PrivPub1, exp)
|
|
1040
1046
|
|
|
1041
1047
|
# | retrieve | Unauth | None | PASS |
|
|
1042
1048
|
# Should PASS since default (no data sets) means only
|
|
@@ -1059,7 +1065,7 @@ class AuthTest(unittest.TestCase):
|
|
|
1059
1065
|
"""Retrieve method with anonymous user; private data set specified"""
|
|
1060
1066
|
self.silent_logout()
|
|
1061
1067
|
exp = "exp.auth_retrieve_6"
|
|
1062
|
-
self.auth_retrieve(None, self.
|
|
1068
|
+
self.auth_retrieve(None, self.PrivPub1, exp)
|
|
1063
1069
|
#!# Replace exception name below once real one is created
|
|
1064
1070
|
|
|
1065
1071
|
# | retrieve | Anon | None | PASS |
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|