sparclclient 1.2.4b1__tar.gz → 1.2.4b3__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.4b1 → sparclclient-1.2.4b3}/PKG-INFO +1 -1
- {sparclclient-1.2.4b1 → sparclclient-1.2.4b3}/sparcl/Results.py +21 -3
- {sparclclient-1.2.4b1 → sparclclient-1.2.4b3}/sparcl/__init__.py +1 -1
- {sparclclient-1.2.4b1 → sparclclient-1.2.4b3}/sparcl/client.py +16 -2
- {sparclclient-1.2.4b1 → sparclclient-1.2.4b3}/tests/expected_pat.py +2 -1
- {sparclclient-1.2.4b1 → sparclclient-1.2.4b3}/tests/tests_api.py +9 -4
- {sparclclient-1.2.4b1 → sparclclient-1.2.4b3}/.github/workflows/django.yml +0 -0
- {sparclclient-1.2.4b1 → sparclclient-1.2.4b3}/.gitignore +0 -0
- {sparclclient-1.2.4b1 → sparclclient-1.2.4b3}/.pre-commit-config.yaml +0 -0
- {sparclclient-1.2.4b1 → sparclclient-1.2.4b3}/.readthedocs.yaml +0 -0
- {sparclclient-1.2.4b1 → sparclclient-1.2.4b3}/LICENSE +0 -0
- {sparclclient-1.2.4b1 → sparclclient-1.2.4b3}/Makefile +0 -0
- {sparclclient-1.2.4b1 → sparclclient-1.2.4b3}/README.md +0 -0
- {sparclclient-1.2.4b1 → sparclclient-1.2.4b3}/make.bat +0 -0
- {sparclclient-1.2.4b1 → sparclclient-1.2.4b3}/pyproject.toml +0 -0
- {sparclclient-1.2.4b1 → sparclclient-1.2.4b3}/requirements-client.txt +0 -0
- {sparclclient-1.2.4b1 → sparclclient-1.2.4b3}/requirements-internal.txt +0 -0
- {sparclclient-1.2.4b1 → sparclclient-1.2.4b3}/requirements.txt +0 -0
- {sparclclient-1.2.4b1 → sparclclient-1.2.4b3}/source/conf.py +0 -0
- {sparclclient-1.2.4b1 → sparclclient-1.2.4b3}/source/index.rst +0 -0
- {sparclclient-1.2.4b1 → sparclclient-1.2.4b3}/source/sparcl.rst +0 -0
- {sparclclient-1.2.4b1 → sparclclient-1.2.4b3}/sparcl/benchmarks/__init__.py +0 -0
- {sparclclient-1.2.4b1 → sparclclient-1.2.4b3}/sparcl/benchmarks/benchmarks.py +0 -0
- {sparclclient-1.2.4b1 → sparclclient-1.2.4b3}/sparcl/conf.py +0 -0
- {sparclclient-1.2.4b1 → sparclclient-1.2.4b3}/sparcl/exceptions.py +0 -0
- {sparclclient-1.2.4b1 → sparclclient-1.2.4b3}/sparcl/fields.py +0 -0
- {sparclclient-1.2.4b1 → sparclclient-1.2.4b3}/sparcl/gather_2d.py +0 -0
- {sparclclient-1.2.4b1 → sparclclient-1.2.4b3}/sparcl/notebooks/sparcl-examples.ipynb +0 -0
- {sparclclient-1.2.4b1 → sparclclient-1.2.4b3}/sparcl/resample_spectra.py +0 -0
- {sparclclient-1.2.4b1 → sparclclient-1.2.4b3}/sparcl/sparc.ini +0 -0
- {sparclclient-1.2.4b1 → sparclclient-1.2.4b3}/sparcl/type_conversion.py +0 -0
- {sparclclient-1.2.4b1 → sparclclient-1.2.4b3}/sparcl/unsupported.py +0 -0
- {sparclclient-1.2.4b1 → sparclclient-1.2.4b3}/sparcl/utils.py +0 -0
- {sparclclient-1.2.4b1 → sparclclient-1.2.4b3}/tests/expected_dev1.py +0 -0
- {sparclclient-1.2.4b1 → sparclclient-1.2.4b3}/tests/methods_tests.py +0 -0
- {sparclclient-1.2.4b1 → sparclclient-1.2.4b3}/tests/utils.py +0 -0
- {sparclclient-1.2.4b1 → sparclclient-1.2.4b3}/tox.ini +0 -0
|
@@ -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
|
|
|
@@ -115,7 +115,8 @@ all_all.sort()
|
|
|
115
115
|
privpub1 = [pub_all[0], priv[0]]
|
|
116
116
|
unauth = "test_user_2@noirlab.edu"
|
|
117
117
|
#
|
|
118
|
-
auth_find_1 =
|
|
118
|
+
auth_find_1 = privpub1
|
|
119
|
+
auth_find_2 = ['DESI-DR1', 'DESI-EDR']
|
|
119
120
|
auth_find_3 = auth_retrieve_3 = (f"[DSDENIED] uname='{unauth}' is declined "
|
|
120
121
|
f"access to datasets={[priv[0]]}; "
|
|
121
122
|
f"drs_requested={privpub1} "
|
|
@@ -921,7 +921,7 @@ class AuthTest(unittest.TestCase):
|
|
|
921
921
|
print(f"authorized_3: actual={actual}")
|
|
922
922
|
self.assertEqual(actual, exp.authorized_3, msg="Actual to Expected")
|
|
923
923
|
|
|
924
|
-
def auth_find(self, user, drs, expvar, limit=21000):
|
|
924
|
+
def auth_find(self, user, drs, expvar, cons={}, limit=21000):
|
|
925
925
|
expected = eval(expvar) # e.g. 'ep.retrieve_N'
|
|
926
926
|
#!print(f'{expvar}: {user=} {drs=} ')
|
|
927
927
|
self.silent_login(user, usrpw)
|
|
@@ -929,7 +929,11 @@ class AuthTest(unittest.TestCase):
|
|
|
929
929
|
out = self.outflds
|
|
930
930
|
try:
|
|
931
931
|
if drs is None:
|
|
932
|
-
found = self.client.find(
|
|
932
|
+
found = self.client.find(
|
|
933
|
+
outfields=out,
|
|
934
|
+
constraints=cons,
|
|
935
|
+
limit=limit
|
|
936
|
+
)
|
|
933
937
|
else:
|
|
934
938
|
found = self.client.find(
|
|
935
939
|
outfields=out,
|
|
@@ -983,7 +987,7 @@ class AuthTest(unittest.TestCase):
|
|
|
983
987
|
"""Test find method with authorized user; private data set specified.
|
|
984
988
|
Should find Authorized Private DR"""
|
|
985
989
|
exp = "exp.auth_find_1"
|
|
986
|
-
self.auth_find(self.auth_user, self.
|
|
990
|
+
self.auth_find(self.auth_user, self.PrivPub1, exp)
|
|
987
991
|
|
|
988
992
|
# | find | Auth | None | PASS |
|
|
989
993
|
# @skip("Does not return Priv") # @@@
|
|
@@ -991,7 +995,8 @@ class AuthTest(unittest.TestCase):
|
|
|
991
995
|
"""Test find method with authorized user; no data sets specified.
|
|
992
996
|
Should find Authorized Private DR"""
|
|
993
997
|
exp = "exp.auth_find_2"
|
|
994
|
-
|
|
998
|
+
constr = {'datasetgroup': ['DESI']}
|
|
999
|
+
self.auth_find(self.auth_user, None, exp, cons=constr)
|
|
995
1000
|
|
|
996
1001
|
# | find | Unauth | Priv,Pub | FAIL |
|
|
997
1002
|
def test_auth_find_3(self):
|
|
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
|