roman-dataref-test 2026.1.1__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.
- roman_dataref_test-2026.1.1/PKG-INFO +30 -0
- roman_dataref_test-2026.1.1/README.md +21 -0
- roman_dataref_test-2026.1.1/pyproject.toml +21 -0
- roman_dataref_test-2026.1.1/setup.cfg +4 -0
- roman_dataref_test-2026.1.1/shared/notebook_data_dependencies.py +196 -0
- roman_dataref_test-2026.1.1/shared/roman_dataref_test.egg-info/PKG-INFO +30 -0
- roman_dataref_test-2026.1.1/shared/roman_dataref_test.egg-info/SOURCES.txt +8 -0
- roman_dataref_test-2026.1.1/shared/roman_dataref_test.egg-info/dependency_links.txt +1 -0
- roman_dataref_test-2026.1.1/shared/roman_dataref_test.egg-info/requires.txt +2 -0
- roman_dataref_test-2026.1.1/shared/roman_dataref_test.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: roman-dataref-test
|
|
3
|
+
Version: 2026.1.1
|
|
4
|
+
Summary: Reference data installer helper for Roman notebooks
|
|
5
|
+
Requires-Python: >=3.9
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
Requires-Dist: requests
|
|
8
|
+
Requires-Dist: pyyaml
|
|
9
|
+
|
|
10
|
+
# Nancy Grace Roman Space Telescope Notebooks
|
|
11
|
+
|
|
12
|
+
The `roman_notebooks` repository contains several workflows and tutorials that demonstrate how to simulate images from, access, and analyze data from the [Nancy Grace Roman Space Telescope](https://roman.gsfc.nasa.gov/) (Roman), as well as how to plan observations. Python Jupyter notebooks provide [Tutorials](markdown/tutorials.md) on specific topics (for example, running the science data pipeline to calibrate an exposure), while [Science Workflows](markdown/workflows.md) combine multiple tutorials with documentation to provide a guided, end-to-end experience for specific science use cases.
|
|
13
|
+
|
|
14
|
+
The notebooks in this repository are designed for use with the [Roman Research Nexus](https://roman.science.stsci.edu), a cloud-based science platform developed for Roman users. With a [MyST](https://proper.stsci.edu/proper/authentication/auth) account, users can access the Nexus and work with Roman data directly in the cloud.
|
|
15
|
+
|
|
16
|
+
## Repository Organization
|
|
17
|
+
|
|
18
|
+
Notebook tutorials are organized under the `notebooks/` directory. Each notebook is contained within a folder along with a `requirements.txt` file and any supporting files required to run it.
|
|
19
|
+
|
|
20
|
+
Reference and contributor documentation is in the repository root and in the `docs/` directory.
|
|
21
|
+
|
|
22
|
+
## Local Installation
|
|
23
|
+
|
|
24
|
+
The notebooks are optimized for execution on the Roman Research Nexus. For local setup instructions, see [install.rst](install.rst).
|
|
25
|
+
|
|
26
|
+
## Get Support
|
|
27
|
+
|
|
28
|
+
Please refer to the [Roman Documentation (RDox)](https://roman-docs.stsci.edu) website for technical documentation about the Roman Space Telescope .
|
|
29
|
+
|
|
30
|
+
If you need assistance, submit a ticket through the [Roman Help Desk](https://romanhelp.stsci.edu) portal. Once logged in, select "Get Help with the Roman Space Telescope" and then the "Roman Research Nexus" category.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Nancy Grace Roman Space Telescope Notebooks
|
|
2
|
+
|
|
3
|
+
The `roman_notebooks` repository contains several workflows and tutorials that demonstrate how to simulate images from, access, and analyze data from the [Nancy Grace Roman Space Telescope](https://roman.gsfc.nasa.gov/) (Roman), as well as how to plan observations. Python Jupyter notebooks provide [Tutorials](markdown/tutorials.md) on specific topics (for example, running the science data pipeline to calibrate an exposure), while [Science Workflows](markdown/workflows.md) combine multiple tutorials with documentation to provide a guided, end-to-end experience for specific science use cases.
|
|
4
|
+
|
|
5
|
+
The notebooks in this repository are designed for use with the [Roman Research Nexus](https://roman.science.stsci.edu), a cloud-based science platform developed for Roman users. With a [MyST](https://proper.stsci.edu/proper/authentication/auth) account, users can access the Nexus and work with Roman data directly in the cloud.
|
|
6
|
+
|
|
7
|
+
## Repository Organization
|
|
8
|
+
|
|
9
|
+
Notebook tutorials are organized under the `notebooks/` directory. Each notebook is contained within a folder along with a `requirements.txt` file and any supporting files required to run it.
|
|
10
|
+
|
|
11
|
+
Reference and contributor documentation is in the repository root and in the `docs/` directory.
|
|
12
|
+
|
|
13
|
+
## Local Installation
|
|
14
|
+
|
|
15
|
+
The notebooks are optimized for execution on the Roman Research Nexus. For local setup instructions, see [install.rst](install.rst).
|
|
16
|
+
|
|
17
|
+
## Get Support
|
|
18
|
+
|
|
19
|
+
Please refer to the [Roman Documentation (RDox)](https://roman-docs.stsci.edu) website for technical documentation about the Roman Space Telescope .
|
|
20
|
+
|
|
21
|
+
If you need assistance, submit a ticket through the [Roman Help Desk](https://romanhelp.stsci.edu) portal. Once logged in, select "Get Help with the Roman Space Telescope" and then the "Roman Research Nexus" category.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "roman-dataref-test"
|
|
7
|
+
version = "2026.1.1"
|
|
8
|
+
description = "Reference data installer helper for Roman notebooks"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license-files = []
|
|
12
|
+
dependencies = [
|
|
13
|
+
"requests",
|
|
14
|
+
"pyyaml",
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
[tool.setuptools]
|
|
18
|
+
py-modules = ["notebook_data_dependencies"]
|
|
19
|
+
|
|
20
|
+
[tool.setuptools.package-dir]
|
|
21
|
+
"" = "shared"
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import requests
|
|
3
|
+
import tarfile
|
|
4
|
+
import tempfile
|
|
5
|
+
import yaml
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
from importlib.metadata import version as _pkg_version, PackageNotFoundError
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
_DEPENDENCIES_PATH = Path(__file__).parent.parent / "refdata_dependencies.yaml"
|
|
11
|
+
|
|
12
|
+
try:
|
|
13
|
+
_ref = "refs/tags/" + _pkg_version("roman-dataref-test")
|
|
14
|
+
except PackageNotFoundError:
|
|
15
|
+
_ref = "refs/heads/main"
|
|
16
|
+
|
|
17
|
+
_REFDATA_URL = (
|
|
18
|
+
f"https://raw.githubusercontent.com/spacetelescope/notebook-ci-testing"
|
|
19
|
+
f"/{_ref}/refdata_dependencies.yaml"
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def _load_yaml(dependencies=None):
|
|
24
|
+
"""Load YAML from local file or URL, preferring local when unspecified."""
|
|
25
|
+
if dependencies is None:
|
|
26
|
+
dependencies = str(_DEPENDENCIES_PATH) if _DEPENDENCIES_PATH.exists() else _REFDATA_URL
|
|
27
|
+
|
|
28
|
+
dep = str(dependencies)
|
|
29
|
+
if os.path.exists(dep):
|
|
30
|
+
with open(dep, "r") as f:
|
|
31
|
+
return yaml.safe_load(f)
|
|
32
|
+
|
|
33
|
+
req = requests.get(dep, allow_redirects=True, timeout=(10, 60))
|
|
34
|
+
req.raise_for_status()
|
|
35
|
+
return yaml.safe_load(req.content)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def _invalid_env_value(envvar, value):
|
|
39
|
+
value = (value or "").strip()
|
|
40
|
+
if not value:
|
|
41
|
+
return True
|
|
42
|
+
if value == "***unset***" or value == f"${{{envvar}}}":
|
|
43
|
+
return True
|
|
44
|
+
return not os.path.exists(value)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def install_files(dependencies=None, verbose=True, packages=None):
|
|
48
|
+
"""
|
|
49
|
+
PURPOSE
|
|
50
|
+
-------
|
|
51
|
+
Retrieve ancillary reference data files needed for specific Python packages:
|
|
52
|
+
- pandeia
|
|
53
|
+
- STIPS
|
|
54
|
+
- STPSF
|
|
55
|
+
- synphot
|
|
56
|
+
|
|
57
|
+
This code checks for each package that the appropriate environment variable exists
|
|
58
|
+
and, if not, it downloads the reference data to the path indicated in the YAML
|
|
59
|
+
instructions and returns instructions to the user for how to set the variables.
|
|
60
|
+
|
|
61
|
+
INPUTS
|
|
62
|
+
------
|
|
63
|
+
dependencies (str): A URL or local path to the YAML definition file for the data
|
|
64
|
+
dependencies. The code will first check for the existence of the file locally, and
|
|
65
|
+
if it does not exist then it will assume the input is a URL. The default is the URL
|
|
66
|
+
of the file on the notebook-ci-testing GitHub repository. The YAML file should have the
|
|
67
|
+
following format:
|
|
68
|
+
|
|
69
|
+
package_name: # Name of the package
|
|
70
|
+
version: # Package version number for documentation
|
|
71
|
+
data_url: # URL for each tarball to pull (can provide multiple, e.g., synphot)
|
|
72
|
+
- URL_1
|
|
73
|
+
...
|
|
74
|
+
- URL_N
|
|
75
|
+
environment_variable: # Environment variable to check or set up (e.g., PYSYN_CDBS)
|
|
76
|
+
install_path: # Parent directory under which to install the reference data
|
|
77
|
+
data_path: # Name of the folder that the reference data exists in
|
|
78
|
+
|
|
79
|
+
The variable data_path is appended to install_path to give the final path to the reference
|
|
80
|
+
data in the file system.
|
|
81
|
+
|
|
82
|
+
verbose (bool): Print messages to the standard out. Default is False.
|
|
83
|
+
|
|
84
|
+
packages (None, list, str): List of packages for which to install reference data. This can
|
|
85
|
+
be a list of string package names, a comma separated string of package names, or None. If None,
|
|
86
|
+
then install package reference data for all packages in the dependencies file. Default None.
|
|
87
|
+
|
|
88
|
+
RETURNS
|
|
89
|
+
-------
|
|
90
|
+
results (dict): A dictionary for each environment variable with the value equal to the final
|
|
91
|
+
path to which the variable should be set.
|
|
92
|
+
"""
|
|
93
|
+
|
|
94
|
+
# Local YAML is preferred when available, otherwise tag-aware remote fallback.
|
|
95
|
+
yf = _load_yaml(dependencies)['install_files']
|
|
96
|
+
|
|
97
|
+
# If only installing certain packages, check that now and limit the dictionary to
|
|
98
|
+
# just those package keys.
|
|
99
|
+
if packages:
|
|
100
|
+
if isinstance(packages, str):
|
|
101
|
+
packages = [p.strip() for p in packages.split(',') if p.strip()]
|
|
102
|
+
|
|
103
|
+
keys = list(yf.keys())
|
|
104
|
+
skips = [k for k in keys if k not in packages]
|
|
105
|
+
for s in skips:
|
|
106
|
+
_ = yf.pop(s)
|
|
107
|
+
|
|
108
|
+
# Loop over packages defined in the dependencies dictionary.
|
|
109
|
+
home = os.environ.get('HOME', os.path.expanduser('~'))
|
|
110
|
+
result = {}
|
|
111
|
+
for package in yf.keys():
|
|
112
|
+
envvar = yf[package]['environment_variable']
|
|
113
|
+
try:
|
|
114
|
+
test = os.environ.get(envvar, '')
|
|
115
|
+
if _invalid_env_value(envvar, test):
|
|
116
|
+
raise KeyError('UNSET PATH')
|
|
117
|
+
if verbose:
|
|
118
|
+
print(f"Found {package} path {os.environ[envvar]}")
|
|
119
|
+
result[envvar] = {'path': os.environ[envvar], 'pre_installed': True}
|
|
120
|
+
except KeyError:
|
|
121
|
+
if verbose:
|
|
122
|
+
print(f"Did not find {package} data in environment, setting it up...")
|
|
123
|
+
|
|
124
|
+
# Get the path where the data should be installed. Resolve any environment variables.
|
|
125
|
+
env_path = yf[package]['install_path']
|
|
126
|
+
tmp_path = env_path.split('/')
|
|
127
|
+
tmp_path = [home if '${HOME}' in tp else tp for tp in tmp_path]
|
|
128
|
+
final_path = '/'.join(tmp_path)
|
|
129
|
+
|
|
130
|
+
# Check if path directory structure exists. If not, make it.
|
|
131
|
+
if not os.path.isdir(final_path):
|
|
132
|
+
os.makedirs(final_path, exist_ok=True)
|
|
133
|
+
|
|
134
|
+
# Download the tarball from the URL in the YAML file and extract the files.
|
|
135
|
+
tot_files = len(yf[package]['data_url'])
|
|
136
|
+
if verbose:
|
|
137
|
+
print(f"\tDownloading and uncompressing file...")
|
|
138
|
+
print(f"\tFound {tot_files} data URL(s) to download and install...")
|
|
139
|
+
for i, url in enumerate(yf[package]['data_url']):
|
|
140
|
+
if verbose:
|
|
141
|
+
print(f"\tWorking on file {i+1} out of {tot_files}")
|
|
142
|
+
req = requests.get(url, allow_redirects=True, stream=True, timeout=(10, 300))
|
|
143
|
+
req.raise_for_status()
|
|
144
|
+
with tempfile.NamedTemporaryFile(dir=final_path, suffix='.tar.gz', delete=False) as tmp:
|
|
145
|
+
tmp_name = tmp.name
|
|
146
|
+
for chunk in req.iter_content(chunk_size=8192):
|
|
147
|
+
tmp.write(chunk)
|
|
148
|
+
try:
|
|
149
|
+
with tarfile.open(tmp_name) as tarball:
|
|
150
|
+
tarball.extractall(path=final_path, filter='data')
|
|
151
|
+
finally:
|
|
152
|
+
os.remove(tmp_name)
|
|
153
|
+
|
|
154
|
+
# Messages to the user
|
|
155
|
+
if verbose:
|
|
156
|
+
print(f"\tUpdate environment variable with the following:")
|
|
157
|
+
print(f"\t\texport {yf[package]['environment_variable']}='{os.path.join(final_path, yf[package]['data_path'])}'")
|
|
158
|
+
result[envvar] = {'path': os.path.join(final_path, yf[package]['data_path']), 'pre_installed': False}
|
|
159
|
+
|
|
160
|
+
# Return the environment variables and paths to the user as a dictionary so that they
|
|
161
|
+
# can be set programmatically.
|
|
162
|
+
return result
|
|
163
|
+
|
|
164
|
+
def setup_env(result, dependencies=None, verbose=True):
|
|
165
|
+
# Update environment variables (if necessary) and print reference data paths
|
|
166
|
+
print('Reference data paths set to:')
|
|
167
|
+
for k, v in result.items():
|
|
168
|
+
if not v['pre_installed']:
|
|
169
|
+
os.environ[k] = v['path']
|
|
170
|
+
print(f"\t{k} = {v['path']}")
|
|
171
|
+
|
|
172
|
+
# Apply additional environment variables from YAML (for example CRDS vars).
|
|
173
|
+
yf = _load_yaml(dependencies)
|
|
174
|
+
other = yf.get('other_variables', {})
|
|
175
|
+
home = os.environ.get('HOME', os.path.expanduser('~'))
|
|
176
|
+
for key, value in other.items():
|
|
177
|
+
value = str(value).replace('${HOME}', home)
|
|
178
|
+
current = (os.environ.get(key) or '').strip()
|
|
179
|
+
|
|
180
|
+
# Replace clearly invalid placeholders and malformed CRDS URL values.
|
|
181
|
+
invalid_current = (
|
|
182
|
+
not current
|
|
183
|
+
or current == '***unset***'
|
|
184
|
+
or current == f'${{{key}}}'
|
|
185
|
+
or (key == 'CRDS_SERVER_URL' and not current.startswith('https://'))
|
|
186
|
+
)
|
|
187
|
+
|
|
188
|
+
if invalid_current:
|
|
189
|
+
os.environ[key] = value
|
|
190
|
+
if verbose:
|
|
191
|
+
print(f"\t{key} = {value}")
|
|
192
|
+
elif verbose:
|
|
193
|
+
print(f"\t{key} = {os.environ[key]} (pre-set, not overwritten)")
|
|
194
|
+
|
|
195
|
+
if __name__ == '__main__':
|
|
196
|
+
setup_env(install_files())
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: roman-dataref-test
|
|
3
|
+
Version: 2026.1.1
|
|
4
|
+
Summary: Reference data installer helper for Roman notebooks
|
|
5
|
+
Requires-Python: >=3.9
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
Requires-Dist: requests
|
|
8
|
+
Requires-Dist: pyyaml
|
|
9
|
+
|
|
10
|
+
# Nancy Grace Roman Space Telescope Notebooks
|
|
11
|
+
|
|
12
|
+
The `roman_notebooks` repository contains several workflows and tutorials that demonstrate how to simulate images from, access, and analyze data from the [Nancy Grace Roman Space Telescope](https://roman.gsfc.nasa.gov/) (Roman), as well as how to plan observations. Python Jupyter notebooks provide [Tutorials](markdown/tutorials.md) on specific topics (for example, running the science data pipeline to calibrate an exposure), while [Science Workflows](markdown/workflows.md) combine multiple tutorials with documentation to provide a guided, end-to-end experience for specific science use cases.
|
|
13
|
+
|
|
14
|
+
The notebooks in this repository are designed for use with the [Roman Research Nexus](https://roman.science.stsci.edu), a cloud-based science platform developed for Roman users. With a [MyST](https://proper.stsci.edu/proper/authentication/auth) account, users can access the Nexus and work with Roman data directly in the cloud.
|
|
15
|
+
|
|
16
|
+
## Repository Organization
|
|
17
|
+
|
|
18
|
+
Notebook tutorials are organized under the `notebooks/` directory. Each notebook is contained within a folder along with a `requirements.txt` file and any supporting files required to run it.
|
|
19
|
+
|
|
20
|
+
Reference and contributor documentation is in the repository root and in the `docs/` directory.
|
|
21
|
+
|
|
22
|
+
## Local Installation
|
|
23
|
+
|
|
24
|
+
The notebooks are optimized for execution on the Roman Research Nexus. For local setup instructions, see [install.rst](install.rst).
|
|
25
|
+
|
|
26
|
+
## Get Support
|
|
27
|
+
|
|
28
|
+
Please refer to the [Roman Documentation (RDox)](https://roman-docs.stsci.edu) website for technical documentation about the Roman Space Telescope .
|
|
29
|
+
|
|
30
|
+
If you need assistance, submit a ticket through the [Roman Help Desk](https://romanhelp.stsci.edu) portal. Once logged in, select "Get Help with the Roman Space Telescope" and then the "Roman Research Nexus" category.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
pyproject.toml
|
|
3
|
+
shared/notebook_data_dependencies.py
|
|
4
|
+
shared/roman_dataref_test.egg-info/PKG-INFO
|
|
5
|
+
shared/roman_dataref_test.egg-info/SOURCES.txt
|
|
6
|
+
shared/roman_dataref_test.egg-info/dependency_links.txt
|
|
7
|
+
shared/roman_dataref_test.egg-info/requires.txt
|
|
8
|
+
shared/roman_dataref_test.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
notebook_data_dependencies
|