Skip to content

Commit abf997d

Browse files
authored
Merge pull request #25 from synthesizer-project/qdev
switching over to synference-download, cleaning up files
2 parents 809c425 + 3a52545 commit abf997d

File tree

8 files changed

+44
-10
lines changed

8 files changed

+44
-10
lines changed

.github/workflows/docs.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,16 @@ jobs:
4444
sudo apt install pandoc
4545
pip install "cosmos-synthesizer@git+https://github.com/synthesizer-project/synthesizer.git"
4646
pip install .[test,docs]
47-
pip install "dense_basis@git+https://github.com/kartheikiyer/dense_basis"
47+
pip install "dense_basis@git+https://github.com/kartheikiyer/dense_basis.git"
4848
pip install "ltu_ili@git+https://github.com/maho3/ltu-ili.git"
49+
pip install "cosmos-synthesizer@git+https://github.com/synthesizer-project/synthesizer.git#egg=synthesizer"
4950
pip install pytest-xdist # enable parallel pytest execution
5051
- name: Download test data
5152
run: |
5253
# Download test grid data
5354
mkdir -p data/libraries/
5455
synthesizer-download --test-grids --dust-grid
55-
synference-download --test
56+
python -c "from synference.utils import download_test_data; download_test_data()"
5657
- name: Sphinx Build
5758
run: |
5859
# Test sphinx build (runs all notebooks)

.github/workflows/python-app.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,11 @@ jobs:
3131
- name: Install dependencies
3232
run: |
3333
python -m pip install --upgrade pip
34-
WITH_OPENMP=1 pip install .
34+
pip install .
3535
pip install ruff pytest
3636
pip install "ltu_ili@git+https://github.com/maho3/ltu-ili.git"
37+
pip install "cosmos-synthesizer@git+https://github.com/synthesizer-project/synthesizer.git#egg=synthesizer"
38+
python -c "from synference.utils import download_test_data; download_test_data()"
3739
3840
- name: Test import
3941
run: |

docs/source/posterior_inference/intro.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,5 @@ Posterior Inference
44
.. toctree::
55
:maxdepth: 2
66

7-
using_your_model
7+
catalogue_fitting
88
sed_recovery
9-
catalogue_fitting

pyproject.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ dependencies = [
5252
"lampe",
5353
"cosmos-synthesizer",
5454
"scikit-learn",
55+
"tarp",
5556
"sbi>=0.22.0",
5657
"h5py",
5758
"optuna",
@@ -107,6 +108,10 @@ docs = [
107108
"Source" = "https://github.com/synthesizer-project/synference"
108109
"Documentation" = "https://synthesizer-project.github.io/synference/"
109110

111+
# Entry points
112+
[project.scripts]
113+
synference-download-data="synference.utils:download_test_data"
114+
110115
[build-system]
111116
requires = ["hatchling"]
112117
build-backend = "hatchling.build"

src/synference/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
timeout_handler, TimeoutException, create_sqlite_db, f_jy_err_to_asinh, create_database_universal,
1111
f_jy_to_asinh, check_scaling, detect_outliers, compare_methods_feature_importance,
1212
analyze_feature_contributions, optimize_sfh_xlimit, make_serializable, setup_mpi_named_logger, move_to_device,
13-
asinh_err_to_f_jy
13+
asinh_err_to_f_jy, download_test_data, test_data_dir
1414
)
1515
# Set up logging
1616
logger = setup_mpi_named_logger("synference", level=logging.INFO)
@@ -110,4 +110,6 @@
110110
"setup_mpi_named_logger",
111111
"move_to_device",
112112
"create_database_universal",
113+
"download_test_data",
114+
"test_data_dir",
113115
]

src/synference/library.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5352,7 +5352,7 @@ def from_library(
53525352
emission_model_name = em_group.attrs["name"]
53535353
import synthesizer.emission_models as em
53545354
import synthesizer.emission_models.attenuation as dm
5355-
import synthesizer.emission_models.dust.emission as dem
5355+
import synthesizer.emission_models.dust as dem
53565356
from synthesizer.emission_models.stellar.pacman_model import (
53575357
PacmanEmissionNoEscapedNoDust,
53585358
PacmanEmissionNoEscapedWithDust,

src/synference/utils.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
except (ImportError, RuntimeError):
2424
spectres = None
2525

26+
try:
27+
from synthesizer import get_data_dir
28+
except ImportError:
29+
get_data_dir = lambda: os.path.dirname(__file__) # noqa: E731
2630

2731
try:
2832
import plotext as plo
@@ -2779,3 +2783,23 @@ def interval_sharpness(
27792783

27802784
# Return negative interval score so tighter intervals are closer to zero
27812785
return -float(np.mean(scores))
2786+
2787+
2788+
def download_test_data():
2789+
"""Downloads test data for Synference using the synference-download CLI tool."""
2790+
import subprocess
2791+
2792+
data_dir = get_data_dir() / "synference"
2793+
data_dir.mkdir(parents=True, exist_ok=True)
2794+
2795+
# Download the test data
2796+
subprocess.run(
2797+
["synference-download", "--test", "-d", str(data_dir)],
2798+
check=True,
2799+
capture_output=True,
2800+
text=True,
2801+
)
2802+
print(f"Test data downloaded to {data_dir}")
2803+
2804+
2805+
test_data_dir = get_data_dir() / "synference"

tests/conftest.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
calculate_muv,
2222
draw_from_hypercube,
2323
generate_sfh_basis,
24+
test_data_dir,
2425
)
2526

2627

@@ -31,9 +32,9 @@ def test_dir():
3132

3233

3334
@pytest.fixture
34-
def library_dir(test_dir):
35-
"""Fixture to get the grid directory path."""
36-
return test_dir / "test_libraries"
35+
def library_dir():
36+
"""Fixture to get the library directory path."""
37+
return test_data_dir
3738

3839

3940
@pytest.fixture

0 commit comments

Comments
 (0)