sparclclient 1.2.6b12__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.
Files changed (39) hide show
  1. {sparclclient-1.2.6b12 → sparclclient-1.2.7b1}/PKG-INFO +1 -1
  2. {sparclclient-1.2.6b12 → sparclclient-1.2.7b1}/pyproject.toml +3 -0
  3. {sparclclient-1.2.6b12 → sparclclient-1.2.7b1}/requirements-client.txt +2 -1
  4. {sparclclient-1.2.6b12 → sparclclient-1.2.7b1}/source/conf.py +2 -2
  5. {sparclclient-1.2.6b12 → sparclclient-1.2.7b1}/sparcl/__init__.py +2 -1
  6. {sparclclient-1.2.6b12 → sparclclient-1.2.7b1}/sparcl/client.py +34 -22
  7. {sparclclient-1.2.6b12 → sparclclient-1.2.7b1}/sparcl/gather_2d.py +3 -5
  8. {sparclclient-1.2.6b12 → sparclclient-1.2.7b1}/sparcl/resample_spectra.py +3 -4
  9. {sparclclient-1.2.6b12 → sparclclient-1.2.7b1}/tests/expected_pat.py +7 -28
  10. {sparclclient-1.2.6b12 → sparclclient-1.2.7b1}/tests/tests_api.py +63 -77
  11. {sparclclient-1.2.6b12 → sparclclient-1.2.7b1}/.github/workflows/django.yml +0 -0
  12. {sparclclient-1.2.6b12 → sparclclient-1.2.7b1}/.gitignore +0 -0
  13. {sparclclient-1.2.6b12 → sparclclient-1.2.7b1}/.pre-commit-config.yaml +0 -0
  14. {sparclclient-1.2.6b12 → sparclclient-1.2.7b1}/.readthedocs.yaml +0 -0
  15. {sparclclient-1.2.6b12 → sparclclient-1.2.7b1}/LICENSE +0 -0
  16. {sparclclient-1.2.6b12 → sparclclient-1.2.7b1}/Makefile +0 -0
  17. {sparclclient-1.2.6b12 → sparclclient-1.2.7b1}/README.md +0 -0
  18. {sparclclient-1.2.6b12 → sparclclient-1.2.7b1}/make.bat +0 -0
  19. {sparclclient-1.2.6b12 → sparclclient-1.2.7b1}/requirements-internal.txt +0 -0
  20. {sparclclient-1.2.6b12 → sparclclient-1.2.7b1}/requirements.txt +0 -0
  21. {sparclclient-1.2.6b12 → sparclclient-1.2.7b1}/source/index.rst +0 -0
  22. {sparclclient-1.2.6b12 → sparclclient-1.2.7b1}/source/sparcl.rst +0 -0
  23. {sparclclient-1.2.6b12 → sparclclient-1.2.7b1}/sparcl/Results.py +0 -0
  24. {sparclclient-1.2.6b12 → sparclclient-1.2.7b1}/sparcl/benchmarks/Benchmark_SPARCL_example.ipynb +0 -0
  25. {sparclclient-1.2.6b12 → sparclclient-1.2.7b1}/sparcl/benchmarks/__init__.py +0 -0
  26. {sparclclient-1.2.6b12 → sparclclient-1.2.7b1}/sparcl/benchmarks/benchmarks.py +0 -0
  27. {sparclclient-1.2.6b12 → sparclclient-1.2.7b1}/sparcl/benchmarks/sparcl_benchmarking.ipynb +0 -0
  28. {sparclclient-1.2.6b12 → sparclclient-1.2.7b1}/sparcl/conf.py +0 -0
  29. {sparclclient-1.2.6b12 → sparclclient-1.2.7b1}/sparcl/exceptions.py +0 -0
  30. {sparclclient-1.2.6b12 → sparclclient-1.2.7b1}/sparcl/fields.py +0 -0
  31. {sparclclient-1.2.6b12 → sparclclient-1.2.7b1}/sparcl/notebooks/sparcl-examples.ipynb +0 -0
  32. {sparclclient-1.2.6b12 → sparclclient-1.2.7b1}/sparcl/sparc.ini +0 -0
  33. {sparclclient-1.2.6b12 → sparclclient-1.2.7b1}/sparcl/type_conversion.py +0 -0
  34. {sparclclient-1.2.6b12 → sparclclient-1.2.7b1}/sparcl/unsupported.py +0 -0
  35. {sparclclient-1.2.6b12 → sparclclient-1.2.7b1}/sparcl/utils.py +0 -0
  36. {sparclclient-1.2.6b12 → sparclclient-1.2.7b1}/tests/expected_dev1.py +0 -0
  37. {sparclclient-1.2.6b12 → sparclclient-1.2.7b1}/tests/methods_tests.py +0 -0
  38. {sparclclient-1.2.6b12 → sparclclient-1.2.7b1}/tests/utils.py +0 -0
  39. {sparclclient-1.2.6b12 → sparclclient-1.2.7b1}/tox.ini +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: sparclclient
3
- Version: 1.2.6b12
3
+ Version: 1.2.7b1
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
@@ -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
 
@@ -1,4 +1,5 @@
1
1
  requests==2.31.0 # 2.26.0
2
- numpy>=1.23.5,<1.26.4
2
+ #numpy>=1.23.5,<1.26.4
3
+ numpy>=2.3.0
3
4
  spectres
4
5
  pyjwt
@@ -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
@@ -35,4 +35,5 @@ __all__ = ["client", "align_records"]
35
35
  #__version__ = "1.2.3"
36
36
  #__version__ = "1.2.4"
37
37
  #__version__ = "1.2.5"
38
- __version__ = "1.2.6b12"
38
+ #__version__ = "1.2.6"
39
+ __version__ = "1.2.7b1"
@@ -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
@@ -197,8 +197,10 @@ class SparclClient: # was SparclApi()
197
197
  self.verbose = verbose
198
198
  self.show_curl = show_curl # Show CURL equivalent of client method
199
199
  #!self.internal_names = internal_names
200
- self.c_timeout = min(MAX_CONNECT_TIMEOUT, float(connect_timeout)) # seconds
201
- self.r_timeout = min(MAX_READ_TIMEOUT, float(read_timeout)) # seconds
200
+ self.c_timeout = min(MAX_CONNECT_TIMEOUT,
201
+ float(connect_timeout)) # seconds
202
+ self.r_timeout = min(MAX_READ_TIMEOUT,
203
+ float(read_timeout)) # seconds
202
204
 
203
205
  # require response within this num seconds
204
206
  # https://2.python-requests.org/en/master/user/advanced/#timeouts
@@ -213,7 +215,7 @@ class SparclClient: # was SparclApi()
213
215
  if announcement:
214
216
  ann = f"{self.apiurl}/announcement/"
215
217
  annres = requests.get(ann, timeout=self.timeout)
216
- annstr = annres.json()['announcement']
218
+ annstr = annres.json()["announcement"]
217
219
  if annstr:
218
220
  print(f"announcement={annstr}")
219
221
 
@@ -307,7 +309,7 @@ class SparclClient: # was SparclApi()
307
309
 
308
310
  Example:
309
311
  >>>
310
- >> client = SparclClient()
312
+ >> client = SparclClient(announcement=False)
311
313
  >> client.login('test_user@noirlab.edu', 'testpw')
312
314
  Logged in successfully with email='test_user@noirlab.edu'
313
315
  """
@@ -342,7 +344,8 @@ class SparclClient: # was SparclApi()
342
344
  self.renew_token = None
343
345
  self.token_exp = None
344
346
  msg = (
345
- 'Could not login with given credentials. Reverted to "Anonymous" user.'
347
+ 'Could not login with given credentials. Reverted '
348
+ 'to "Anonymous" user.'
346
349
  )
347
350
  return msg
348
351
 
@@ -370,7 +373,7 @@ class SparclClient: # was SparclApi()
370
373
  None.
371
374
 
372
375
  Example:
373
- >>> client = SparclClient()
376
+ >>> client = SparclClient(announcement=False)
374
377
  >>> client.logout()
375
378
  Logged-out successfully. Previously logged-in with email None.
376
379
  """
@@ -419,7 +422,7 @@ class SparclClient: # was SparclApi()
419
422
  List of fields tagged as 'default' from DATASET_LIST.
420
423
 
421
424
  Example:
422
- >>> client = SparclClient()
425
+ >>> client = SparclClient(announcement=False)
423
426
  >>> client.get_default_fields()
424
427
  ['dec', 'flux', 'ra', 'sparcl_id', 'specid', 'wavelength']
425
428
  """
@@ -450,7 +453,7 @@ class SparclClient: # was SparclApi()
450
453
  List of fields tagged as 'all' from DATASET_LIST.
451
454
 
452
455
  Example:
453
- >>> client = SparclClient()
456
+ >>> client = SparclClient(announcement=False)
454
457
  >>> client.get_all_fields()
455
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']
456
459
  """ # noqa: E501
@@ -477,7 +480,8 @@ class SparclClient: # was SparclApi()
477
480
  return True
478
481
 
479
482
  def _common_internal(self, *, science_fields=None, dataset_list=None):
480
- self._validate_science_fields(science_fields, dataset_list=dataset_list)
483
+ self._validate_science_fields(science_fields,
484
+ dataset_list=dataset_list)
481
485
 
482
486
  if dataset_list is None:
483
487
  dataset_list = self.fields.all_drs
@@ -506,7 +510,7 @@ class SparclClient: # was SparclApi()
506
510
  Set of fields available from data sets in DATASET_LIST.
507
511
 
508
512
  Example:
509
- >>> client = SparclClient()
513
+ >>> client = SparclClient(announcement=False)
510
514
  >>> sorted(client.get_available_fields())
511
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']
512
516
 
@@ -526,7 +530,7 @@ class SparclClient: # was SparclApi()
526
530
  API version (:obj:`float`).
527
531
 
528
532
  Example:
529
- >>> client = SparclClient()
533
+ >>> client = SparclClient(announcement=False)
530
534
  >>> client.version
531
535
  12.0
532
536
  """
@@ -579,7 +583,7 @@ class SparclClient: # was SparclApi()
579
583
  :class:`~sparcl.Results.Found`: Contains header and records.
580
584
 
581
585
  Example:
582
- >>> client = SparclClient()
586
+ >>> client = SparclClient(announcement=False)
583
587
  >>> outs = ['sparcl_id', 'ra', 'dec']
584
588
  >>> cons = {'spectype': ['GALAXY'], 'redshift': [0.5, 0.9]}
585
589
  >>> found = client.find(outfields=outs, constraints=cons)
@@ -601,9 +605,10 @@ class SparclClient: # was SparclApi()
601
605
  #! dataset_list=dataset_list) # DLS-401
602
606
  dr = list(dataset_list)[0]
603
607
  if len(constraints) > 0:
604
- self._validate_science_fields(constraints.keys(), dataset_list=dataset_list)
608
+ self._validate_science_fields(constraints.keys(),
609
+ dataset_list=dataset_list)
605
610
  constraints = {
606
- self.fields._internal_name(k, dr): v for k, v in constraints.items()
611
+ self.fields._internal_name(k, dr): v for k, v in constraints.items() # noqa: E501
607
612
  }
608
613
  uparams = dict(
609
614
  limit=limit,
@@ -637,7 +642,14 @@ class SparclClient: # was SparclApi()
637
642
  print(f"Record key counts: {ut.count_values(found.records)}")
638
643
  return found
639
644
 
640
- def missing(self, uuid_list, *, dataset_list=None, countOnly=False, verbose=False):
645
+ def missing(
646
+ self,
647
+ uuid_list,
648
+ *,
649
+ dataset_list=None,
650
+ countOnly=False,
651
+ verbose=False
652
+ ):
641
653
  """Return the subset of sparcl_ids in the given uuid_list that are
642
654
  NOT stored in the SPARCL database.
643
655
 
@@ -660,7 +672,7 @@ class SparclClient: # was SparclApi()
660
672
  are NOT stored in the SPARCL database.
661
673
 
662
674
  Example:
663
- >>> client = SparclClient()
675
+ >>> client = SparclClient(announcement=False)
664
676
  >>> ids = ['ddbb57ee-8e90-4a0d-823b-0f5d97028076',]
665
677
  >>> client.missing(ids)
666
678
  ['ddbb57ee-8e90-4a0d-823b-0f5d97028076']
@@ -715,11 +727,11 @@ class SparclClient: # was SparclApi()
715
727
  are NOT stored in the SPARCL database.
716
728
 
717
729
  Example:
718
- >>> client = SparclClient()
730
+ >>> client = SparclClient(announcement=False)
719
731
  >>> found = client.find(outfields=['specid'], limit=2)
720
732
  >>> specids = [f.specid for f in found.records]
721
- >>> client.missing_specids(specids + ['bad_id'])
722
- ['bad_id']
733
+ >>> client.missing_specids(specids + ['6802933904984788992'])
734
+ ['6802933904984788992']
723
735
  """
724
736
  if dataset_list is None:
725
737
  dataset_list = self.fields.all_drs
@@ -805,7 +817,7 @@ class SparclClient: # was SparclApi()
805
817
  :class:`~sparcl.Results.Retrieved`: Contains header and records.
806
818
 
807
819
  Example:
808
- >>> client = SparclClient()
820
+ >>> client = SparclClient(announcement=False)
809
821
  >>> ids = client.find(limit=1).ids
810
822
  >>> inc = ['sparcl_id', 'flux', 'wavelength', 'model']
811
823
  >>> ret = client.retrieve(uuid_list=ids, include=inc)
@@ -1008,7 +1020,7 @@ class SparclClient: # was SparclApi()
1008
1020
  :class:`~sparcl.Results.Retrieved`: Contains header and records.
1009
1021
 
1010
1022
  Example:
1011
- >>> client = SparclClient()
1023
+ >>> client = SparclClient(announcement=False)
1012
1024
  >>> sids = [5840097619402313728, -8985592895187431424]
1013
1025
  >>> inc = ['specid', 'flux', 'wavelength', 'model']
1014
1026
  >>> ret = client.retrieve_by_specid(specid_list=sids, include=inc)
@@ -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
- constraints=dict(data_release=["BOSS-DR16"]), limit=numrecs
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-DR16',
55
- 'data_release': 'BOSS-DR16',
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": {"BOSS-DR16", "DESI-DR1", "DESI-EDR", "SDSS-DR16"},
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": {"BOSS-DR16", "DESI-DR1", "DESI-EDR", "SDSS-DR16"},
90
+ "Authorized_Datasets": {"DESI-DR1", "SDSS-DR17", "DESI-EDR", "BOSS-DR17"},
107
91
  }
108
92
 
109
93
  # Private and Public
110
- pub_1 = ["BOSS-DR16"]
111
- pub_all = ["BOSS-DR16", "DESI-DR1", "DESI-EDR", "SDSS-DR16"]
112
- priv = ["SDSS-DR17-test", "BOSS-DR17", "SDSS-DR17"]
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-DR16"]
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
- ["sparcl_id", "specid"], sort="sparcl_id", limit=5
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
- sorted(missing), sorted(uuids), msg="Actual to Expected"
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"""
@@ -287,7 +286,7 @@ class SparclClientTest(unittest.TestCase):
287
286
 
288
287
  def test_missing_specids_1(self):
289
288
  """Specids (not UUID) missing"""
290
- badid = "NOT_SPEC_ID"
289
+ badid = 0
291
290
  specids = set([badid] + self.specid_list0[:1])
292
291
  missing = set(self.client.missing_specids(specids, verbose=False))
293
292
  if showact:
@@ -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-DR16", "BOSS-DR16", "DESI-EDR"]
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": ['BOSS-DR16']}
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-DR16"],
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
- ["data_release", "mjd"], limit=5, sort="sparcl_id"
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-DR16", "DESI-EDR"]}
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-DR16", "DESI-EDR"]}
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
- actual, specids[:2] + [None], msg="Actual to Expected"
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-DR16", "BOSS-DR16", "DESI-EDR"]
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-DR16", "BOSS-DR16", "DESI-EDR"]
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-DR16"]}, limit=1
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-DR16"],
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
- self.got.records, fields=self.specflds
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
- self.got.records, fields=self.specflds
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
- self.got.records, fields=["flux", "model"]
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
- f"\n# Running AuthTest:setUpClass() "
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-DR16", "DESI-DR1", "DESI-EDR", "SDSS-DR16"]
750
- cls.Priv = ["SDSS-DR17-test", "BOSS-DR17", "SDSS-DR17"]
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-DR16"]},
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()['access']
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['access']
852
- self.client.renew_token = token['refresh']
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
- POST http://localhost:8050/sparc/renew_token/
871
- Content-Type: application/json
872
- {
873
- "token": "..."
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
- outfields=out,
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
- f"{expvar}: {actual=}"
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
- uuid_list=ids, include=inc, dataset_list=drs
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
- f"{expvar}: {actual=}"
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 = {'datasetgroup': ['DESI']}
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