sparclclient 1.2.6b13__tar.gz → 1.2.7b1__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.6b13 → sparclclient-1.2.7b1}/PKG-INFO +1 -1
- {sparclclient-1.2.6b13 → sparclclient-1.2.7b1}/pyproject.toml +3 -0
- {sparclclient-1.2.6b13 → sparclclient-1.2.7b1}/requirements-client.txt +2 -1
- {sparclclient-1.2.6b13 → sparclclient-1.2.7b1}/source/conf.py +2 -2
- {sparclclient-1.2.6b13 → sparclclient-1.2.7b1}/sparcl/__init__.py +2 -1
- {sparclclient-1.2.6b13 → sparclclient-1.2.7b1}/sparcl/client.py +69 -62
- {sparclclient-1.2.6b13 → sparclclient-1.2.7b1}/sparcl/gather_2d.py +3 -5
- {sparclclient-1.2.6b13 → sparclclient-1.2.7b1}/sparcl/resample_spectra.py +3 -4
- {sparclclient-1.2.6b13 → sparclclient-1.2.7b1}/tests/expected_pat.py +7 -28
- {sparclclient-1.2.6b13 → sparclclient-1.2.7b1}/tests/tests_api.py +62 -76
- {sparclclient-1.2.6b13 → sparclclient-1.2.7b1}/.github/workflows/django.yml +0 -0
- {sparclclient-1.2.6b13 → sparclclient-1.2.7b1}/.gitignore +0 -0
- {sparclclient-1.2.6b13 → sparclclient-1.2.7b1}/.pre-commit-config.yaml +0 -0
- {sparclclient-1.2.6b13 → sparclclient-1.2.7b1}/.readthedocs.yaml +0 -0
- {sparclclient-1.2.6b13 → sparclclient-1.2.7b1}/LICENSE +0 -0
- {sparclclient-1.2.6b13 → sparclclient-1.2.7b1}/Makefile +0 -0
- {sparclclient-1.2.6b13 → sparclclient-1.2.7b1}/README.md +0 -0
- {sparclclient-1.2.6b13 → sparclclient-1.2.7b1}/make.bat +0 -0
- {sparclclient-1.2.6b13 → sparclclient-1.2.7b1}/requirements-internal.txt +0 -0
- {sparclclient-1.2.6b13 → sparclclient-1.2.7b1}/requirements.txt +0 -0
- {sparclclient-1.2.6b13 → sparclclient-1.2.7b1}/source/index.rst +0 -0
- {sparclclient-1.2.6b13 → sparclclient-1.2.7b1}/source/sparcl.rst +0 -0
- {sparclclient-1.2.6b13 → sparclclient-1.2.7b1}/sparcl/Results.py +0 -0
- {sparclclient-1.2.6b13 → sparclclient-1.2.7b1}/sparcl/benchmarks/Benchmark_SPARCL_example.ipynb +0 -0
- {sparclclient-1.2.6b13 → sparclclient-1.2.7b1}/sparcl/benchmarks/__init__.py +0 -0
- {sparclclient-1.2.6b13 → sparclclient-1.2.7b1}/sparcl/benchmarks/benchmarks.py +0 -0
- {sparclclient-1.2.6b13 → sparclclient-1.2.7b1}/sparcl/benchmarks/sparcl_benchmarking.ipynb +0 -0
- {sparclclient-1.2.6b13 → sparclclient-1.2.7b1}/sparcl/conf.py +0 -0
- {sparclclient-1.2.6b13 → sparclclient-1.2.7b1}/sparcl/exceptions.py +0 -0
- {sparclclient-1.2.6b13 → sparclclient-1.2.7b1}/sparcl/fields.py +0 -0
- {sparclclient-1.2.6b13 → sparclclient-1.2.7b1}/sparcl/notebooks/sparcl-examples.ipynb +0 -0
- {sparclclient-1.2.6b13 → sparclclient-1.2.7b1}/sparcl/sparc.ini +0 -0
- {sparclclient-1.2.6b13 → sparclclient-1.2.7b1}/sparcl/type_conversion.py +0 -0
- {sparclclient-1.2.6b13 → sparclclient-1.2.7b1}/sparcl/unsupported.py +0 -0
- {sparclclient-1.2.6b13 → sparclclient-1.2.7b1}/sparcl/utils.py +0 -0
- {sparclclient-1.2.6b13 → sparclclient-1.2.7b1}/tests/expected_dev1.py +0 -0
- {sparclclient-1.2.6b13 → sparclclient-1.2.7b1}/tests/methods_tests.py +0 -0
- {sparclclient-1.2.6b13 → sparclclient-1.2.7b1}/tests/utils.py +0 -0
- {sparclclient-1.2.6b13 → sparclclient-1.2.7b1}/tox.ini +0 -0
|
@@ -31,6 +31,9 @@ dependencies = ["requests==2.31.0", "numpy>=1.23.5,<1.26.4", "spectres", "pyjwt"
|
|
|
31
31
|
"Bug Tracker" = "https://github.com/pypa/sparclclient/issues"
|
|
32
32
|
"Documentation" = "https://sparclclient.readthedocs.io/en/latest/"
|
|
33
33
|
|
|
34
|
+
[tool.ruff.lint]
|
|
35
|
+
select = ["NPY201"]
|
|
36
|
+
|
|
34
37
|
[tool.flit.module]
|
|
35
38
|
name = "sparcl"
|
|
36
39
|
|
|
@@ -11,11 +11,11 @@
|
|
|
11
11
|
# add these directories to sys.path here. If the directory is relative to the
|
|
12
12
|
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
|
13
13
|
|
|
14
|
+
from sparcl import __version__
|
|
14
15
|
import os
|
|
15
16
|
import re
|
|
16
17
|
import sys
|
|
17
18
|
sys.path.insert(0, os.path.abspath(".."))
|
|
18
|
-
from sparcl import __version__
|
|
19
19
|
|
|
20
20
|
# -- Project information -----------------------------------------------------
|
|
21
21
|
|
|
@@ -26,7 +26,7 @@ author = "S.Pothier, A.Jacques"
|
|
|
26
26
|
#!version = client_version
|
|
27
27
|
sver = __version__
|
|
28
28
|
mo = re.match(
|
|
29
|
-
"^(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)(?:(?P<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$",
|
|
29
|
+
"^(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)(?:(?P<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$", # noqa: E501, W605
|
|
30
30
|
sver,
|
|
31
31
|
)
|
|
32
32
|
release = sver
|
|
@@ -163,7 +163,7 @@ class SparclClient: # was SparclApi()
|
|
|
163
163
|
Defaults to True.
|
|
164
164
|
|
|
165
165
|
Example:
|
|
166
|
-
>>> client = SparclClient()
|
|
166
|
+
>>> client = SparclClient(announcement=False)
|
|
167
167
|
|
|
168
168
|
Raises:
|
|
169
169
|
Exception: Object creation compares the version from the
|
|
@@ -199,7 +199,8 @@ class SparclClient: # was SparclApi()
|
|
|
199
199
|
#!self.internal_names = internal_names
|
|
200
200
|
self.c_timeout = min(MAX_CONNECT_TIMEOUT,
|
|
201
201
|
float(connect_timeout)) # seconds
|
|
202
|
-
self.r_timeout = min(MAX_READ_TIMEOUT,
|
|
202
|
+
self.r_timeout = min(MAX_READ_TIMEOUT,
|
|
203
|
+
float(read_timeout)) # seconds
|
|
203
204
|
|
|
204
205
|
# require response within this num seconds
|
|
205
206
|
# https://2.python-requests.org/en/master/user/advanced/#timeouts
|
|
@@ -214,7 +215,7 @@ class SparclClient: # was SparclApi()
|
|
|
214
215
|
if announcement:
|
|
215
216
|
ann = f"{self.apiurl}/announcement/"
|
|
216
217
|
annres = requests.get(ann, timeout=self.timeout)
|
|
217
|
-
annstr = annres.json()[
|
|
218
|
+
annstr = annres.json()["announcement"]
|
|
218
219
|
if annstr:
|
|
219
220
|
print(f"announcement={annstr}")
|
|
220
221
|
|
|
@@ -308,7 +309,7 @@ class SparclClient: # was SparclApi()
|
|
|
308
309
|
|
|
309
310
|
Example:
|
|
310
311
|
>>>
|
|
311
|
-
>> client = SparclClient()
|
|
312
|
+
>> client = SparclClient(announcement=False)
|
|
312
313
|
>> client.login('test_user@noirlab.edu', 'testpw')
|
|
313
314
|
Logged in successfully with email='test_user@noirlab.edu'
|
|
314
315
|
"""
|
|
@@ -343,8 +344,8 @@ class SparclClient: # was SparclApi()
|
|
|
343
344
|
self.renew_token = None
|
|
344
345
|
self.token_exp = None
|
|
345
346
|
msg = (
|
|
346
|
-
'Could not login with given credentials. '
|
|
347
|
-
'
|
|
347
|
+
'Could not login with given credentials. Reverted '
|
|
348
|
+
'to "Anonymous" user.'
|
|
348
349
|
)
|
|
349
350
|
return msg
|
|
350
351
|
|
|
@@ -372,7 +373,7 @@ class SparclClient: # was SparclApi()
|
|
|
372
373
|
None.
|
|
373
374
|
|
|
374
375
|
Example:
|
|
375
|
-
>>> client = SparclClient()
|
|
376
|
+
>>> client = SparclClient(announcement=False)
|
|
376
377
|
>>> client.logout()
|
|
377
378
|
Logged-out successfully. Previously logged-in with email None.
|
|
378
379
|
"""
|
|
@@ -412,16 +413,16 @@ class SparclClient: # was SparclApi()
|
|
|
412
413
|
parameter of client.retrieve().
|
|
413
414
|
|
|
414
415
|
Args:
|
|
415
|
-
dataset_list (:obj:`list
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
416
|
+
dataset_list (:obj:`list`, optional): List of data sets from
|
|
417
|
+
which to get the default fields. Defaults to None, which
|
|
418
|
+
will return the intersection of default fields in all
|
|
419
|
+
data sets hosted on the SPARCL database.
|
|
419
420
|
|
|
420
421
|
Returns:
|
|
421
422
|
List of fields tagged as 'default' from DATASET_LIST.
|
|
422
423
|
|
|
423
424
|
Example:
|
|
424
|
-
>>> client = SparclClient()
|
|
425
|
+
>>> client = SparclClient(announcement=False)
|
|
425
426
|
>>> client.get_default_fields()
|
|
426
427
|
['dec', 'flux', 'ra', 'sparcl_id', 'specid', 'wavelength']
|
|
427
428
|
"""
|
|
@@ -443,16 +444,16 @@ class SparclClient: # was SparclApi()
|
|
|
443
444
|
of client.retrieve().
|
|
444
445
|
|
|
445
446
|
Args:
|
|
446
|
-
dataset_list (:obj:`list
|
|
447
|
-
|
|
448
|
-
will return the intersection of all fields in all
|
|
449
|
-
hosted on the SPARCL database.
|
|
447
|
+
dataset_list (:obj:`list`, optional): List of data sets from
|
|
448
|
+
which to get all fields. Defaults to None, which
|
|
449
|
+
will return the intersection of all fields in all
|
|
450
|
+
data sets hosted on the SPARCL database.
|
|
450
451
|
|
|
451
452
|
Returns:
|
|
452
453
|
List of fields tagged as 'all' from DATASET_LIST.
|
|
453
454
|
|
|
454
455
|
Example:
|
|
455
|
-
>>> client = SparclClient()
|
|
456
|
+
>>> client = SparclClient(announcement=False)
|
|
456
457
|
>>> client.get_all_fields()
|
|
457
458
|
['data_release', 'datasetgroup', 'dateobs', 'dateobs_center', 'dec', 'exptime', 'flux', 'instrument', 'ivar', 'mask', 'model', 'ra', 'redshift', 'redshift_err', 'redshift_warning', 'site', 'sparcl_id', 'specid', 'specprimary', 'spectype', 'survey', 'targetid', 'telescope', 'wave_sigma', 'wavelength', 'wavemax', 'wavemin']
|
|
458
459
|
""" # noqa: E501
|
|
@@ -500,16 +501,16 @@ class SparclClient: # was SparclApi()
|
|
|
500
501
|
client.retreive().
|
|
501
502
|
|
|
502
503
|
Args:
|
|
503
|
-
dataset_list (:obj:`list
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
504
|
+
dataset_list (:obj:`list`, optional): List of data sets from
|
|
505
|
+
which to get available fields. Defaults to None, which
|
|
506
|
+
will return the intersection of all available fields in
|
|
507
|
+
all data sets hosted on the SPARCL database.
|
|
507
508
|
|
|
508
509
|
Returns:
|
|
509
510
|
Set of fields available from data sets in DATASET_LIST.
|
|
510
511
|
|
|
511
512
|
Example:
|
|
512
|
-
>>> client = SparclClient()
|
|
513
|
+
>>> client = SparclClient(announcement=False)
|
|
513
514
|
>>> sorted(client.get_available_fields())
|
|
514
515
|
['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']
|
|
515
516
|
|
|
@@ -529,7 +530,7 @@ class SparclClient: # was SparclApi()
|
|
|
529
530
|
API version (:obj:`float`).
|
|
530
531
|
|
|
531
532
|
Example:
|
|
532
|
-
>>> client = SparclClient()
|
|
533
|
+
>>> client = SparclClient(announcement=False)
|
|
533
534
|
>>> client.version
|
|
534
535
|
12.0
|
|
535
536
|
"""
|
|
@@ -556,10 +557,10 @@ class SparclClient: # was SparclApi()
|
|
|
556
557
|
"""Find records in the SPARCL database.
|
|
557
558
|
|
|
558
559
|
Args:
|
|
559
|
-
outfields (:obj:`list
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
560
|
+
outfields (:obj:`list`, optional): List of fields to return.
|
|
561
|
+
Only CORE fields may be passed to this parameter.
|
|
562
|
+
Defaults to None, which will return only the sparcl_id
|
|
563
|
+
and _dr fields.
|
|
563
564
|
|
|
564
565
|
constraints (:obj:`dict`, optional): Key-Value pairs of
|
|
565
566
|
constraints to place on the record selection. The Key
|
|
@@ -582,7 +583,7 @@ class SparclClient: # was SparclApi()
|
|
|
582
583
|
:class:`~sparcl.Results.Found`: Contains header and records.
|
|
583
584
|
|
|
584
585
|
Example:
|
|
585
|
-
>>> client = SparclClient()
|
|
586
|
+
>>> client = SparclClient(announcement=False)
|
|
586
587
|
>>> outs = ['sparcl_id', 'ra', 'dec']
|
|
587
588
|
>>> cons = {'spectype': ['GALAXY'], 'redshift': [0.5, 0.9]}
|
|
588
589
|
>>> found = client.find(outfields=outs, constraints=cons)
|
|
@@ -642,17 +643,22 @@ class SparclClient: # was SparclApi()
|
|
|
642
643
|
return found
|
|
643
644
|
|
|
644
645
|
def missing(
|
|
645
|
-
self,
|
|
646
|
+
self,
|
|
647
|
+
uuid_list,
|
|
648
|
+
*,
|
|
649
|
+
dataset_list=None,
|
|
650
|
+
countOnly=False,
|
|
651
|
+
verbose=False
|
|
646
652
|
):
|
|
647
653
|
"""Return the subset of sparcl_ids in the given uuid_list that are
|
|
648
654
|
NOT stored in the SPARCL database.
|
|
649
655
|
|
|
650
656
|
Args:
|
|
651
|
-
uuid_list (:obj:`list`
|
|
657
|
+
uuid_list (:obj:`list`): List of sparcl_ids.
|
|
652
658
|
|
|
653
|
-
dataset_list (:obj:`list
|
|
654
|
-
|
|
655
|
-
|
|
659
|
+
dataset_list (:obj:`list`, optional): List of data sets from
|
|
660
|
+
which to find missing sparcl_ids. Defaults to None, meaning
|
|
661
|
+
all data sets hosted on the SPARCL database.
|
|
656
662
|
|
|
657
663
|
countOnly (:obj:`bool`, optional): Set to True to return only
|
|
658
664
|
a count of the missing sparcl_ids from the uuid_list.
|
|
@@ -666,9 +672,9 @@ class SparclClient: # was SparclApi()
|
|
|
666
672
|
are NOT stored in the SPARCL database.
|
|
667
673
|
|
|
668
674
|
Example:
|
|
669
|
-
>>> client = SparclClient()
|
|
670
|
-
>>>
|
|
671
|
-
>>> client.missing(
|
|
675
|
+
>>> client = SparclClient(announcement=False)
|
|
676
|
+
>>> ids = ['ddbb57ee-8e90-4a0d-823b-0f5d97028076',]
|
|
677
|
+
>>> client.missing(ids)
|
|
672
678
|
['ddbb57ee-8e90-4a0d-823b-0f5d97028076']
|
|
673
679
|
"""
|
|
674
680
|
|
|
@@ -703,11 +709,11 @@ class SparclClient: # was SparclApi()
|
|
|
703
709
|
NOT stored in the SPARCL database.
|
|
704
710
|
|
|
705
711
|
Args:
|
|
706
|
-
specid_list (:obj:`list`
|
|
712
|
+
specid_list (:obj:`list`): List of specids.
|
|
707
713
|
|
|
708
|
-
dataset_list (:obj:`list
|
|
709
|
-
|
|
710
|
-
|
|
714
|
+
dataset_list (:obj:`list`, optional): List of data sets from
|
|
715
|
+
which to find missing specids. Defaults to None, meaning
|
|
716
|
+
all data sets hosted on the SPARCL database.
|
|
711
717
|
|
|
712
718
|
countOnly (:obj:`bool`, optional): Set to True to return only
|
|
713
719
|
a count of the missing specids from the specid_list.
|
|
@@ -721,10 +727,11 @@ class SparclClient: # was SparclApi()
|
|
|
721
727
|
are NOT stored in the SPARCL database.
|
|
722
728
|
|
|
723
729
|
Example:
|
|
724
|
-
>>> client = SparclClient()
|
|
725
|
-
>>>
|
|
726
|
-
>>>
|
|
727
|
-
[
|
|
730
|
+
>>> client = SparclClient(announcement=False)
|
|
731
|
+
>>> found = client.find(outfields=['specid'], limit=2)
|
|
732
|
+
>>> specids = [f.specid for f in found.records]
|
|
733
|
+
>>> client.missing_specids(specids + ['6802933904984788992'])
|
|
734
|
+
['6802933904984788992']
|
|
728
735
|
"""
|
|
729
736
|
if dataset_list is None:
|
|
730
737
|
dataset_list = self.fields.all_drs
|
|
@@ -790,15 +797,15 @@ class SparclClient: # was SparclApi()
|
|
|
790
797
|
sparcl_ids.
|
|
791
798
|
|
|
792
799
|
Args:
|
|
793
|
-
uuid_list (:obj:`list`
|
|
800
|
+
uuid_list (:obj:`list`): List of sparcl_ids.
|
|
794
801
|
|
|
795
|
-
include (:obj:`list
|
|
796
|
-
|
|
797
|
-
|
|
802
|
+
include (:obj:`list`, optional): List of field names to include
|
|
803
|
+
in each record. Defaults to 'DEFAULT', which will return
|
|
804
|
+
the fields tagged as 'default'.
|
|
798
805
|
|
|
799
|
-
dataset_list (:obj:`list
|
|
800
|
-
|
|
801
|
-
|
|
806
|
+
dataset_list (:obj:`list`, optional): List of data sets from
|
|
807
|
+
which to retrieve spectra data. Defaults to None, meaning all
|
|
808
|
+
data sets hosted on the SPARCL database.
|
|
802
809
|
|
|
803
810
|
limit (:obj:`int`, optional): Maximum number of records to
|
|
804
811
|
return. Defaults to 500. Maximum allowed is 24,000.
|
|
@@ -810,7 +817,7 @@ class SparclClient: # was SparclApi()
|
|
|
810
817
|
:class:`~sparcl.Results.Retrieved`: Contains header and records.
|
|
811
818
|
|
|
812
819
|
Example:
|
|
813
|
-
>>> client = SparclClient()
|
|
820
|
+
>>> client = SparclClient(announcement=False)
|
|
814
821
|
>>> ids = client.find(limit=1).ids
|
|
815
822
|
>>> inc = ['sparcl_id', 'flux', 'wavelength', 'model']
|
|
816
823
|
>>> ret = client.retrieve(uuid_list=ids, include=inc)
|
|
@@ -993,15 +1000,15 @@ class SparclClient: # was SparclApi()
|
|
|
993
1000
|
specids.
|
|
994
1001
|
|
|
995
1002
|
Args:
|
|
996
|
-
specid_list (:obj:`list`
|
|
1003
|
+
specid_list (:obj:`list`): List of specids.
|
|
997
1004
|
|
|
998
|
-
include (:obj:`list
|
|
999
|
-
|
|
1000
|
-
|
|
1005
|
+
include (:obj:`list`, optional): List of field names to include
|
|
1006
|
+
in each record. Defaults to 'DEFAULT', which will return
|
|
1007
|
+
the fields tagged as 'default'.
|
|
1001
1008
|
|
|
1002
|
-
dataset_list (:obj:`list
|
|
1003
|
-
|
|
1004
|
-
|
|
1009
|
+
dataset_list (:obj:`list`, optional): List of data sets from
|
|
1010
|
+
which to retrieve spectra data. Defaults to None, meaning all
|
|
1011
|
+
data sets hosted on the SPARCL database.
|
|
1005
1012
|
|
|
1006
1013
|
limit (:obj:`int`, optional): Maximum number of records to
|
|
1007
1014
|
return. Defaults to 500. Maximum allowed is 24,000.
|
|
@@ -1013,7 +1020,7 @@ class SparclClient: # was SparclApi()
|
|
|
1013
1020
|
:class:`~sparcl.Results.Retrieved`: Contains header and records.
|
|
1014
1021
|
|
|
1015
1022
|
Example:
|
|
1016
|
-
>>> client = SparclClient()
|
|
1023
|
+
>>> client = SparclClient(announcement=False)
|
|
1017
1024
|
>>> sids = [5840097619402313728, -8985592895187431424]
|
|
1018
1025
|
>>> inc = ['specid', 'flux', 'wavelength', 'model']
|
|
1019
1026
|
>>> ret = client.retrieve_by_specid(specid_list=sids, include=inc)
|
|
@@ -1052,9 +1059,9 @@ class SparclClient: # was SparclApi()
|
|
|
1052
1059
|
usrcount = len(specid_list)
|
|
1053
1060
|
dbcount = found.count
|
|
1054
1061
|
warn = (
|
|
1055
|
-
f"UserWarning: Some
|
|
1062
|
+
f"UserWarning: Some SPECIDs were not found. "
|
|
1056
1063
|
f"{usrcount - dbcount} out of the {usrcount} requested "
|
|
1057
|
-
f"
|
|
1064
|
+
f"uuids have no records available in the SPARCL database "
|
|
1058
1065
|
f"associated with DataSets {dr_list}."
|
|
1059
1066
|
)
|
|
1060
1067
|
print(warn)
|
|
@@ -39,9 +39,7 @@ def _wavelength_offsets(records):
|
|
|
39
39
|
set(records[0].wavelength).union(*[r.wavelength for r in records[1:]])
|
|
40
40
|
)
|
|
41
41
|
# offsets[ri] = index into WINDOW
|
|
42
|
-
offsets = {
|
|
43
|
-
ri: window.index(rec.wavelength[0]) for ri, rec in enumerate(records)
|
|
44
|
-
}
|
|
42
|
+
offsets = {ri: window.index(rec.wavelength[0]) for ri, rec in enumerate(records)} # noqa: E501
|
|
45
43
|
return (window, offsets)
|
|
46
44
|
|
|
47
45
|
|
|
@@ -89,7 +87,7 @@ def _align_wavelengths(records):
|
|
|
89
87
|
|
|
90
88
|
|
|
91
89
|
def _tt1(numrecs=20, dr="BOSS-DR16"):
|
|
92
|
-
client = sparcl.client.SparclClient()
|
|
90
|
+
client = sparcl.client.SparclClient(announcement=False)
|
|
93
91
|
found = client.find(constraints=dict(data_release=[dr]), limit=numrecs)
|
|
94
92
|
got = client.retrieve(found.ids)
|
|
95
93
|
records = got.records
|
|
@@ -188,7 +186,7 @@ def align_records(records, fields=["flux", "wavelength"], precision=7):
|
|
|
188
186
|
- grid(ndarray): 1D numpy array containing wavelength values.
|
|
189
187
|
|
|
190
188
|
Example:
|
|
191
|
-
>>> client = sparcl.client.SparclClient()
|
|
189
|
+
>>> client = sparcl.client.SparclClient(announcement=False)
|
|
192
190
|
>>> specflds = ['wavelength', 'model']
|
|
193
191
|
>>> cons = {"data_release": ['BOSS-DR16']}
|
|
194
192
|
>>> found = client.find(constraints=cons, limit=21)
|
|
@@ -32,10 +32,9 @@ def _resample_flux(records, wavstep=1):
|
|
|
32
32
|
|
|
33
33
|
|
|
34
34
|
def _tt0(numrecs=20):
|
|
35
|
-
client = sparcl.client.SparclClient()
|
|
36
|
-
found = client.find(
|
|
37
|
-
|
|
38
|
-
)
|
|
35
|
+
client = sparcl.client.SparclClient(announcement=False)
|
|
36
|
+
found = client.find(constraints=dict(data_release=["BOSS-DR16"]),
|
|
37
|
+
limit=numrecs)
|
|
39
38
|
got = client.retrieve(found.ids)
|
|
40
39
|
flux_2d, new_wavs = _resample_flux(got.records)
|
|
41
40
|
return flux_2d, new_wavs
|
|
@@ -40,19 +40,10 @@ retrieve_0b = ["_dr", "dec", "flux", "ra", "sparcl_id", "specid", "wavelength"]
|
|
|
40
40
|
|
|
41
41
|
retrieve_5 = 2
|
|
42
42
|
|
|
43
|
-
# OLD as of August 23, 2024
|
|
44
|
-
#find_0 = [
|
|
45
|
-
# {
|
|
46
|
-
# "_dr": "BOSS-DR16",
|
|
47
|
-
# "data_release": "BOSS-DR16",
|
|
48
|
-
# "specid": -6444532452352045056,
|
|
49
|
-
# }
|
|
50
|
-
#]
|
|
51
|
-
|
|
52
43
|
find_0 = [
|
|
53
44
|
{
|
|
54
|
-
'_dr': 'BOSS-
|
|
55
|
-
'data_release': 'BOSS-
|
|
45
|
+
'_dr': 'BOSS-DR17',
|
|
46
|
+
'data_release': 'BOSS-DR17',
|
|
56
47
|
'telescope': 'sloan25m'
|
|
57
48
|
}
|
|
58
49
|
]
|
|
@@ -67,13 +58,6 @@ find_1 = [
|
|
|
67
58
|
|
|
68
59
|
find_2 = 936894 # PAT
|
|
69
60
|
|
|
70
|
-
# OLD as of August 23, 2024
|
|
71
|
-
#find_3 = [
|
|
72
|
-
# {"_dr": "BOSS-DR16", "data_release": "BOSS-DR16"},
|
|
73
|
-
# {"_dr": "DESI-EDR", "data_release": "DESI-EDR"},
|
|
74
|
-
# {"_dr": "SDSS-DR16", "data_release": "SDSS-DR16"},
|
|
75
|
-
#]
|
|
76
|
-
|
|
77
61
|
find_4 = 36
|
|
78
62
|
|
|
79
63
|
find_5a = [
|
|
@@ -98,33 +82,28 @@ authorized_1 = {
|
|
|
98
82
|
|
|
99
83
|
authorized_2 = {
|
|
100
84
|
"Loggedin_As": "test_user_2@noirlab.edu",
|
|
101
|
-
"Authorized_Datasets": {"
|
|
85
|
+
"Authorized_Datasets": {"DESI-DR1", "SDSS-DR17", "DESI-EDR", "BOSS-DR17"},
|
|
102
86
|
}
|
|
103
87
|
|
|
104
88
|
authorized_3 = {
|
|
105
89
|
"Loggedin_As": "Anonymous",
|
|
106
|
-
"Authorized_Datasets": {"
|
|
90
|
+
"Authorized_Datasets": {"DESI-DR1", "SDSS-DR17", "DESI-EDR", "BOSS-DR17"},
|
|
107
91
|
}
|
|
108
92
|
|
|
109
93
|
# Private and Public
|
|
110
|
-
pub_1 = ["BOSS-
|
|
111
|
-
pub_all = ["BOSS-
|
|
112
|
-
priv = ["SDSS-DR17-test", "BOSS-
|
|
94
|
+
pub_1 = ["BOSS-DR17"]
|
|
95
|
+
pub_all = ["BOSS-DR17", "DESI-DR1", "DESI-EDR", "SDSS-DR17"]
|
|
96
|
+
priv = ["SDSS-DR17-test", "BOSS-DR16", "SDSS-DR16"]
|
|
113
97
|
all_all = pub_all + priv
|
|
114
98
|
all_all.sort()
|
|
115
99
|
privpub1 = [pub_all[0], priv[0]]
|
|
116
100
|
unauth = "test_user_2@noirlab.edu"
|
|
117
101
|
msg = "Find Results: 1000 records"
|
|
118
|
-
# OLD as of July 9, 2025
|
|
119
|
-
#auth_find_1 = privpub1
|
|
120
|
-
#auth_find_2 = ['DESI-DR1', 'DESI-EDR']
|
|
121
102
|
auth_find_1 = auth_find_2 = auth_find_4 = auth_find_6 = msg
|
|
122
103
|
auth_find_3 = auth_retrieve_3 = (f"[DSDENIED] uname='{unauth}' is declined "
|
|
123
104
|
f"access to datasets={[priv[0]]}; "
|
|
124
105
|
f"drs_requested={privpub1} "
|
|
125
106
|
f"my_auth={pub_all}")
|
|
126
|
-
# OLD as of July 9, 2025
|
|
127
|
-
#auth_find_4 = auth_find_6 = pub_all
|
|
128
107
|
auth_find_5 = auth_retrieve_6 = ("[DSDENIED] uname='ANONYMOUS' is declined "
|
|
129
108
|
f"access to datasets={[priv[0]]}; "
|
|
130
109
|
f"drs_requested={privpub1} "
|
|
@@ -72,7 +72,7 @@ import sparcl.gather_2d
|
|
|
72
72
|
|
|
73
73
|
DEFAULT = "DEFAULT"
|
|
74
74
|
ALL = "ALL"
|
|
75
|
-
drs = ["BOSS-
|
|
75
|
+
drs = ["BOSS-DR17"]
|
|
76
76
|
|
|
77
77
|
_DEV1 = "http://localhost:8050" # noqa: E221
|
|
78
78
|
_PAT1 = "https://sparc1.datalab.noirlab.edu" # noqa: E221
|
|
@@ -90,6 +90,9 @@ showall = False
|
|
|
90
90
|
showall = showall or os.environ.get("showall") == "1"
|
|
91
91
|
if showall:
|
|
92
92
|
showact = showcurl = clverb = True
|
|
93
|
+
# If running on dev environment:
|
|
94
|
+
devrun = False
|
|
95
|
+
devrun = devrun or os.environ.get("devrun") == "1"
|
|
93
96
|
|
|
94
97
|
usrpw = os.environ.get("usrpw") # password for test users
|
|
95
98
|
show_run_context = True # Print message about parameters of this test run
|
|
@@ -188,9 +191,8 @@ class SparclClientTest(unittest.TestCase):
|
|
|
188
191
|
show_run_context = False
|
|
189
192
|
|
|
190
193
|
# Get some id_lists to use in tests
|
|
191
|
-
found = cls.client.find(
|
|
192
|
-
|
|
193
|
-
)
|
|
194
|
+
found = cls.client.find(["sparcl_id", "specid"],
|
|
195
|
+
sort="sparcl_id", limit=5)
|
|
194
196
|
sparc_tups, spec_tups = list(
|
|
195
197
|
zip(*[(r["sparcl_id"], r["specid"]) for r in found.records])
|
|
196
198
|
)
|
|
@@ -212,9 +214,7 @@ class SparclClientTest(unittest.TestCase):
|
|
|
212
214
|
cls.uuid_list0 = sparc_ids[:3]
|
|
213
215
|
cls.uuid_list2 = sparc_ids[:3]
|
|
214
216
|
# two real UUIDs, one fake
|
|
215
|
-
cls.uuid_list3 = sparc_ids[:2] + [
|
|
216
|
-
"00001ebf-d030-4d59-97e5-060c47202897"
|
|
217
|
-
]
|
|
217
|
+
cls.uuid_list3 = sparc_ids[:2] + ["00001ebf-d030-4d59-97e5-060c47202897"] # noqa: E501
|
|
218
218
|
# two (probably) fake UUIDs
|
|
219
219
|
cls.uuid_list4 = [
|
|
220
220
|
"00001ebf-d030-4d59-97e5-060c47202897",
|
|
@@ -271,9 +271,8 @@ class SparclClientTest(unittest.TestCase):
|
|
|
271
271
|
"""Known missing"""
|
|
272
272
|
uuids = [99, 88, 777]
|
|
273
273
|
missing = self.client.missing(self.uuid_list0 + uuids)
|
|
274
|
-
self.assertEqual(
|
|
275
|
-
|
|
276
|
-
)
|
|
274
|
+
self.assertEqual(sorted(missing), sorted(uuids),
|
|
275
|
+
msg="Actual to Expected")
|
|
277
276
|
|
|
278
277
|
def test_missing_1(self):
|
|
279
278
|
"""None missing"""
|
|
@@ -298,8 +297,7 @@ class SparclClientTest(unittest.TestCase):
|
|
|
298
297
|
def test_retrieve_0(self):
|
|
299
298
|
"""Get spectra using small list of SPECIDS."""
|
|
300
299
|
res = self.client.retrieve_by_specid(
|
|
301
|
-
self.specid_list0,
|
|
302
|
-
include=["sparcl_id", "specid", "flux"]
|
|
300
|
+
self.specid_list0, include=["sparcl_id", "specid", "flux"]
|
|
303
301
|
)
|
|
304
302
|
actual = sorted(res.records[0].keys())
|
|
305
303
|
if showact:
|
|
@@ -348,7 +346,7 @@ class SparclClientTest(unittest.TestCase):
|
|
|
348
346
|
def test_retrieve_3(self):
|
|
349
347
|
"""Issue warning when some sids do not exist."""
|
|
350
348
|
uuids = self.uuid_list0
|
|
351
|
-
drs = ["SDSS-
|
|
349
|
+
drs = ["SDSS-DR17", "BOSS-DR17", "DESI-EDR"]
|
|
352
350
|
with self.assertWarns(Warning):
|
|
353
351
|
self.client.retrieve(uuids + [999], dataset_list=drs)
|
|
354
352
|
|
|
@@ -371,7 +369,7 @@ class SparclClientTest(unittest.TestCase):
|
|
|
371
369
|
outfields = ["data_release", "telescope"]
|
|
372
370
|
# To get suitable constraints (in sparc-shell on Server):
|
|
373
371
|
# list(FitsRecord.objects.all().values('ra','dec'))
|
|
374
|
-
constraints = {"data_release": [
|
|
372
|
+
constraints = {"data_release": ["BOSS-DR17"]}
|
|
375
373
|
found = self.client.find(outfields, constraints=constraints, limit=3)
|
|
376
374
|
actual = found.records[:1]
|
|
377
375
|
if showact:
|
|
@@ -385,7 +383,7 @@ class SparclClientTest(unittest.TestCase):
|
|
|
385
383
|
constraints = {
|
|
386
384
|
"redshift": [0.191, 0.192],
|
|
387
385
|
"exptime": [2100.2, 2100.31],
|
|
388
|
-
"data_release": ["SDSS-
|
|
386
|
+
"data_release": ["SDSS-DR17"],
|
|
389
387
|
}
|
|
390
388
|
found = self.client.find(
|
|
391
389
|
outfields, constraints=constraints, limit=1, sort="specid"
|
|
@@ -403,9 +401,7 @@ class SparclClientTest(unittest.TestCase):
|
|
|
403
401
|
def test_find_2(self):
|
|
404
402
|
"""Limit=None."""
|
|
405
403
|
outfields = ["sparcl_id", "ra", "dec"]
|
|
406
|
-
found = self.client.find(
|
|
407
|
-
outfields, limit=None, sort="sparcl_id"
|
|
408
|
-
) # @@@
|
|
404
|
+
found = self.client.find(outfields, limit=None, sort="sparcl_id")
|
|
409
405
|
actual = len(found.records)
|
|
410
406
|
if showact:
|
|
411
407
|
print(f"find_2: actual={pf(actual)}")
|
|
@@ -439,9 +435,8 @@ class SparclClientTest(unittest.TestCase):
|
|
|
439
435
|
@skip("Not implemented. Waiting for switch to ingest-time field naming ")
|
|
440
436
|
def test_find_5a(self):
|
|
441
437
|
"""Aux field values when they exists in all found records"""
|
|
442
|
-
found = self.client.find(
|
|
443
|
-
|
|
444
|
-
)
|
|
438
|
+
found = self.client.find(["data_release", "mjd"], limit=5,
|
|
439
|
+
sort="sparcl_id")
|
|
445
440
|
actual = found.records
|
|
446
441
|
if showact:
|
|
447
442
|
print(f"find_5a: actual={pf(actual)}")
|
|
@@ -451,7 +446,7 @@ class SparclClientTest(unittest.TestCase):
|
|
|
451
446
|
@skip("Not implemented. Waiting for switch to ingest-time field naming ")
|
|
452
447
|
def test_find_5b(self):
|
|
453
448
|
"""Aux field in one Data Set but not another. (proper subset)"""
|
|
454
|
-
cons = {"data_release": ["SDSS-
|
|
449
|
+
cons = {"data_release": ["SDSS-DR17", "DESI-EDR"]}
|
|
455
450
|
f0 = self.client.find(
|
|
456
451
|
["data_release"], constraints=cons, limit=5, sort="sparcl_id"
|
|
457
452
|
)
|
|
@@ -467,7 +462,7 @@ class SparclClientTest(unittest.TestCase):
|
|
|
467
462
|
@skip("Not implemented. Waiting for switch to ingest-time field naming ")
|
|
468
463
|
def test_find_5c(self):
|
|
469
464
|
"""Aux field values when they do not exist in any found records"""
|
|
470
|
-
cons = {"data_release": ["SDSS-
|
|
465
|
+
cons = {"data_release": ["SDSS-DR17", "DESI-EDR"]}
|
|
471
466
|
nsf = "NO_SUCH_FIELD"
|
|
472
467
|
f1 = self.client.find(
|
|
473
468
|
["data_release", nsf], constraints=cons, limit=5, sort="sparcl_id"
|
|
@@ -534,9 +529,8 @@ class SparclClientTest(unittest.TestCase):
|
|
|
534
529
|
actual = [f["specid"] for f in res_reorder.records]
|
|
535
530
|
if showact:
|
|
536
531
|
print(f"reorder_2b: actual={pf(actual)}")
|
|
537
|
-
self.assertEqual(
|
|
538
|
-
|
|
539
|
-
)
|
|
532
|
+
self.assertEqual(actual, specids[:2] + [None],
|
|
533
|
+
msg="Actual to Expected")
|
|
540
534
|
|
|
541
535
|
def test_reorder_3a(self):
|
|
542
536
|
"""Test for expected Exception when a list of sparcl_ids with
|
|
@@ -571,7 +565,7 @@ class SparclClientTest(unittest.TestCase):
|
|
|
571
565
|
ids = self.uuid_list4
|
|
572
566
|
|
|
573
567
|
tic()
|
|
574
|
-
drs = ["SDSS-
|
|
568
|
+
drs = ["SDSS-DR17", "BOSS-DR17", "DESI-EDR"]
|
|
575
569
|
with self.assertWarns(Warning):
|
|
576
570
|
res = self.client.retrieve(ids, dataset_list=drs)
|
|
577
571
|
self.timing[name] = toc()
|
|
@@ -585,7 +579,7 @@ class SparclClientTest(unittest.TestCase):
|
|
|
585
579
|
specids = self.specid_list4
|
|
586
580
|
|
|
587
581
|
tic()
|
|
588
|
-
drs = ["SDSS-
|
|
582
|
+
drs = ["SDSS-DR17", "BOSS-DR17", "DESI-EDR"]
|
|
589
583
|
res = self.client.retrieve_by_specid(specids, dataset_list=drs)
|
|
590
584
|
self.timing[name] = toc()
|
|
591
585
|
with self.assertRaises(ex.NoRecords):
|
|
@@ -593,12 +587,12 @@ class SparclClientTest(unittest.TestCase):
|
|
|
593
587
|
|
|
594
588
|
def test_dls_468(self):
|
|
595
589
|
idss = self.client.find(
|
|
596
|
-
constraints={"data_release": ["SDSS-
|
|
590
|
+
constraints={"data_release": ["SDSS-DR17"]}, limit=1
|
|
597
591
|
).ids
|
|
598
592
|
re = self.client.retrieve(
|
|
599
593
|
uuid_list=idss,
|
|
600
594
|
include=["ra", "dec"],
|
|
601
|
-
dataset_list=["SDSS-
|
|
595
|
+
dataset_list=["SDSS-DR17"],
|
|
602
596
|
verbose=False,
|
|
603
597
|
)
|
|
604
598
|
self.assertEqual(1, re.count)
|
|
@@ -618,11 +612,11 @@ class AlignRecordsTest(unittest.TestCase):
|
|
|
618
612
|
)
|
|
619
613
|
|
|
620
614
|
cls.client = sparcl.client.SparclClient(
|
|
621
|
-
url=serverurl, verbose=clverb, show_curl=showcurl
|
|
622
|
-
|
|
623
|
-
found = cls.client.find(
|
|
624
|
-
constraints={"data_release": ["BOSS-DR16"]}, limit=20
|
|
615
|
+
url=serverurl, verbose=clverb, show_curl=showcurl,
|
|
616
|
+
announcement=False
|
|
625
617
|
)
|
|
618
|
+
found = cls.client.find(constraints={"data_release": ["BOSS-DR17"]},
|
|
619
|
+
limit=20)
|
|
626
620
|
cls.found = found
|
|
627
621
|
cls.specflds = ["wavelength", "flux", "ivar", "mask", "model"]
|
|
628
622
|
cls.got = cls.client.retrieve(found.ids, include=cls.specflds)
|
|
@@ -654,18 +648,16 @@ class AlignRecordsTest(unittest.TestCase):
|
|
|
654
648
|
wavelength grid."""
|
|
655
649
|
|
|
656
650
|
#! print(f'Fields={list(self.got.records[0].keys())}')
|
|
657
|
-
ar_dict, grid = sg.align_records(
|
|
658
|
-
|
|
659
|
-
)
|
|
651
|
+
ar_dict, grid = sg.align_records(self.got.records,
|
|
652
|
+
fields=self.specflds)
|
|
660
653
|
self.assertEqual(sorted(ar_dict.keys()), sorted(self.specflds))
|
|
661
654
|
|
|
662
655
|
# Requirement #3 from DLS-280
|
|
663
656
|
def test_align_3(self):
|
|
664
657
|
"""Verify shapes of arrays"""
|
|
665
658
|
|
|
666
|
-
ar_dict, grid = sg.align_records(
|
|
667
|
-
|
|
668
|
-
)
|
|
659
|
+
ar_dict, grid = sg.align_records(self.got.records,
|
|
660
|
+
fields=self.specflds)
|
|
669
661
|
shape = list(ar_dict.values())[0].shape
|
|
670
662
|
self.assertEqual(shape, (20, 4621))
|
|
671
663
|
|
|
@@ -681,9 +673,8 @@ class AlignRecordsTest(unittest.TestCase):
|
|
|
681
673
|
"""Verify wavelength given."""
|
|
682
674
|
msg = 'You must provide "wavelength" spectra field'
|
|
683
675
|
with self.assertRaises(Exception, msg=msg):
|
|
684
|
-
ar_dict, grid = sg.align_records(
|
|
685
|
-
|
|
686
|
-
)
|
|
676
|
+
ar_dict, grid = sg.align_records(self.got.records,
|
|
677
|
+
fields=["flux", "model"])
|
|
687
678
|
|
|
688
679
|
# Requirement #6 from DLS-280
|
|
689
680
|
def test_align_6(self):
|
|
@@ -723,13 +714,12 @@ class AuthTest(unittest.TestCase):
|
|
|
723
714
|
@classmethod
|
|
724
715
|
def setUpClass(cls):
|
|
725
716
|
if clverb:
|
|
726
|
-
print(
|
|
727
|
-
|
|
728
|
-
f"{str(datetime.datetime.now())}"
|
|
729
|
-
)
|
|
717
|
+
print(f"\n# Running AuthTest:setUpClass() "
|
|
718
|
+
f"{str(datetime.datetime.now())}")
|
|
730
719
|
|
|
731
720
|
cls.client = sparcl.client.SparclClient(
|
|
732
721
|
url=serverurl, verbose=clverb, show_curl=showcurl,
|
|
722
|
+
announcement=False
|
|
733
723
|
)
|
|
734
724
|
|
|
735
725
|
global show_run_context
|
|
@@ -746,8 +736,8 @@ class AuthTest(unittest.TestCase):
|
|
|
746
736
|
cls.unauth_user = "test_user_2@noirlab.edu"
|
|
747
737
|
|
|
748
738
|
# Dataset lists
|
|
749
|
-
cls.Pub = ["BOSS-
|
|
750
|
-
cls.Priv = ["SDSS-DR17-test", "BOSS-
|
|
739
|
+
cls.Pub = ["BOSS-DR17", "DESI-DR1", "DESI-EDR", "SDSS-DR17"]
|
|
740
|
+
cls.Priv = ["SDSS-DR17-test", "BOSS-DR16", "SDSS-DR16"]
|
|
751
741
|
cls.PrivPub = cls.Priv + cls.Pub
|
|
752
742
|
cls.PrivPub.sort()
|
|
753
743
|
cls.PrivPub1 = [cls.Priv[0], cls.Pub[0]]
|
|
@@ -780,7 +770,7 @@ class AuthTest(unittest.TestCase):
|
|
|
780
770
|
cls.uuid_pub = (
|
|
781
771
|
cls.client.find(
|
|
782
772
|
outfields=out,
|
|
783
|
-
constraints={"data_release": ["BOSS-
|
|
773
|
+
constraints={"data_release": ["BOSS-DR17"]},
|
|
784
774
|
limit=2,
|
|
785
775
|
sort="sparcl_id",
|
|
786
776
|
)
|
|
@@ -838,7 +828,7 @@ class AuthTest(unittest.TestCase):
|
|
|
838
828
|
expected = 279
|
|
839
829
|
res = requests.post(f"{self.client.apiurl}/get_token/", json=json)
|
|
840
830
|
self.assertEqual(res.status_code, 200, res.content.decode())
|
|
841
|
-
token = res.json()[
|
|
831
|
+
token = res.json()["access"]
|
|
842
832
|
actual = len(token)
|
|
843
833
|
if showact:
|
|
844
834
|
print(f"test_get_token: ({len(token)}) {token=!s}")
|
|
@@ -848,8 +838,8 @@ class AuthTest(unittest.TestCase):
|
|
|
848
838
|
json = {"email": self.auth_user, "password": usrpw}
|
|
849
839
|
res = requests.post(f"{self.client.apiurl}/get_token/", json=json)
|
|
850
840
|
token = res.json()
|
|
851
|
-
self.client.token = token[
|
|
852
|
-
self.client.renew_token = token[
|
|
841
|
+
self.client.token = token["access"]
|
|
842
|
+
self.client.renew_token = token["refresh"]
|
|
853
843
|
|
|
854
844
|
def test_token_not_expired(self):
|
|
855
845
|
self.getToken()
|
|
@@ -867,11 +857,11 @@ class AuthTest(unittest.TestCase):
|
|
|
867
857
|
|
|
868
858
|
def test_token_expired_renew(self):
|
|
869
859
|
"""
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
860
|
+
POST http://localhost:8050/sparc/renew_token/
|
|
861
|
+
Content-Type: application/json
|
|
862
|
+
{
|
|
863
|
+
"token": "..."
|
|
864
|
+
}
|
|
875
865
|
|
|
876
866
|
"""
|
|
877
867
|
self.getToken()
|
|
@@ -919,11 +909,8 @@ class AuthTest(unittest.TestCase):
|
|
|
919
909
|
out = self.outflds
|
|
920
910
|
try:
|
|
921
911
|
if drs is None:
|
|
922
|
-
found = self.client.find(
|
|
923
|
-
|
|
924
|
-
constraints=cons,
|
|
925
|
-
limit=limit
|
|
926
|
-
)
|
|
912
|
+
found = self.client.find(outfields=out, constraints=cons,
|
|
913
|
+
limit=limit)
|
|
927
914
|
else:
|
|
928
915
|
found = self.client.find(
|
|
929
916
|
outfields=out,
|
|
@@ -933,17 +920,15 @@ class AuthTest(unittest.TestCase):
|
|
|
933
920
|
#!if showact:
|
|
934
921
|
#! print(f"{expvar}: {found.records=}")
|
|
935
922
|
|
|
936
|
-
#actual = sorted(set([r._dr for r in found.records]))
|
|
923
|
+
# actual = sorted(set([r._dr for r in found.records]))
|
|
937
924
|
actual = str(found)
|
|
938
925
|
except Exception as err:
|
|
939
926
|
actual = str(err)
|
|
940
927
|
finally:
|
|
941
928
|
self.silent_logout()
|
|
942
929
|
if showact:
|
|
943
|
-
print(
|
|
944
|
-
|
|
945
|
-
f" {self.client.authorized=} {user=} {drs=}"
|
|
946
|
-
)
|
|
930
|
+
print(f"{expvar}: {actual=} {self.client.authorized=} "
|
|
931
|
+
f"{user=} {drs=}")
|
|
947
932
|
self.assertEqual(actual, expected, msg="Actual to Expected")
|
|
948
933
|
|
|
949
934
|
def auth_retrieve(self, user, drs, expvar):
|
|
@@ -956,24 +941,22 @@ class AuthTest(unittest.TestCase):
|
|
|
956
941
|
if drs is None:
|
|
957
942
|
got = self.client.retrieve(uuid_list=ids, include=inc)
|
|
958
943
|
else:
|
|
959
|
-
got = self.client.retrieve(
|
|
960
|
-
|
|
961
|
-
)
|
|
944
|
+
got = self.client.retrieve(uuid_list=ids, include=inc,
|
|
945
|
+
dataset_list=drs)
|
|
962
946
|
actual = sorted(set([r._dr for r in got.records]))
|
|
963
947
|
except Exception as err:
|
|
964
948
|
actual = str(err)
|
|
965
949
|
finally:
|
|
966
950
|
self.silent_logout()
|
|
967
951
|
if showact:
|
|
968
|
-
print(
|
|
969
|
-
|
|
970
|
-
f" {self.client.authorized=} {user=} {drs=}"
|
|
971
|
-
)
|
|
952
|
+
print(f"{expvar}: {actual=} {self.client.authorized=} "
|
|
953
|
+
f"{user=} {drs=}")
|
|
972
954
|
self.assertEqual(actual, expected, msg="Actual to Expected")
|
|
973
955
|
|
|
974
956
|
# | METHOD | USER | DATASETS | OK? |
|
|
975
957
|
# | find | Auth | Priv,Pub | PASS |
|
|
976
958
|
# @skip("Does not return Priv") # @@@
|
|
959
|
+
@skipIf("devrun" in os.environ, "Running tests in dev environment")
|
|
977
960
|
def test_auth_find_1(self):
|
|
978
961
|
"""Test find method with authorized user; private data set specified.
|
|
979
962
|
Should find Authorized Private DR"""
|
|
@@ -982,11 +965,12 @@ class AuthTest(unittest.TestCase):
|
|
|
982
965
|
|
|
983
966
|
# | find | Auth | None | PASS |
|
|
984
967
|
# @skip("Does not return Priv") # @@@
|
|
968
|
+
@skipIf("devrun" in os.environ, "Running tests in dev environment")
|
|
985
969
|
def test_auth_find_2(self):
|
|
986
970
|
"""Test find method with authorized user; no data sets specified.
|
|
987
971
|
Should find Authorized Private DR"""
|
|
988
972
|
exp = "exp.auth_find_2"
|
|
989
|
-
constr = {
|
|
973
|
+
constr = {"datasetgroup": ["DESI"]}
|
|
990
974
|
self.auth_find(self.auth_user, None, exp, cons=constr)
|
|
991
975
|
|
|
992
976
|
# | find | Unauth | Priv,Pub | FAIL |
|
|
@@ -996,6 +980,7 @@ class AuthTest(unittest.TestCase):
|
|
|
996
980
|
self.auth_find(self.unauth_user, self.PrivPub1, exp)
|
|
997
981
|
|
|
998
982
|
# | find | Unauth | None | PASS |
|
|
983
|
+
@skipIf("devrun" in os.environ, "Running tests in dev environment")
|
|
999
984
|
def test_auth_find_4(self):
|
|
1000
985
|
"""Test find method with unauthorized user; no data sets specified"""
|
|
1001
986
|
exp = "exp.auth_find_4"
|
|
@@ -1009,6 +994,7 @@ class AuthTest(unittest.TestCase):
|
|
|
1009
994
|
self.auth_find(None, self.PrivPub1, exp)
|
|
1010
995
|
|
|
1011
996
|
# | find | Anon | None | PASS |
|
|
997
|
+
@skipIf("devrun" in os.environ, "Running tests in dev environment")
|
|
1012
998
|
def test_auth_find_6(self):
|
|
1013
999
|
"""Test find method with anonymous user; no data sets specified"""
|
|
1014
1000
|
exp = "exp.auth_find_6"
|
|
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
|
{sparclclient-1.2.6b13 → sparclclient-1.2.7b1}/sparcl/benchmarks/Benchmark_SPARCL_example.ipynb
RENAMED
|
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
|