From b0c7680ccc3b6566fcb899d2c22258deb30b4efb Mon Sep 17 00:00:00 2001 From: Raphael Shirley Date: Thu, 21 May 2026 16:35:17 +0200 Subject: [PATCH 01/18] Started lephare submission based on example PR --- .github/workflows/submit_lephare.yaml | 38 ++++ requirements_lephare.txt | 2 + tests/test_lephare.py | 250 ++++++++++++++++++++++++++ 3 files changed, 290 insertions(+) create mode 100644 .github/workflows/submit_lephare.yaml create mode 100644 requirements_lephare.txt create mode 100644 tests/test_lephare.py diff --git a/.github/workflows/submit_lephare.yaml b/.github/workflows/submit_lephare.yaml new file mode 100644 index 0000000..9fdd663 --- /dev/null +++ b/.github/workflows/submit_lephare.yaml @@ -0,0 +1,38 @@ +--- +# This workflow will install Python dependencies and run tests + +name: Unit test and code coverage + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ['3.13'] + submission: ['lephare'] + + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + sudo apt-get update + sudo apt install libbz2-dev + python -m pip install --upgrade pip + pip install wheel + pip install . + pip install .[dev] + if [ -f requirements_${{ matrix.submission }}.txt ]; then pip install -r requirements_${{ matrix.submission }}.txt; fi + - name: Run unit tests with pytest + run: | + python -m pytest tests/test_${{ matrix.submission }}.py diff --git a/requirements_lephare.txt b/requirements_lephare.txt new file mode 100644 index 0000000..e0de2a1 --- /dev/null +++ b/requirements_lephare.txt @@ -0,0 +1,2 @@ +pz-rail-base +pz-rail-lephare diff --git a/tests/test_lephare.py b/tests/test_lephare.py new file mode 100644 index 0000000..474510c --- /dev/null +++ b/tests/test_lephare.py @@ -0,0 +1,250 @@ +import os +from pathlib import Path +import pytest + +from rail.core.data import TableHandle +from rail.estimation.algos import sklearn_neurnet +from rail.utils import catalog_utils + +from pz_data_challenge.taskset_1 import run_taskset_1 +from pz_data_challenge.taskset_2 import run_taskset_2 + +from pz_data_challenge import submit_utils + +SUBMISSION_NAME: str = "example" +SUBMISSION_URL: str = "https://s3df.slac.stanford.edu/people/echarles/submit_example.tgz" + +# don't change these +SUBMIT_DIR: str = f"submissions/{SUBMISSION_NAME}" +PUBLIC_AREA: str = "tests/public" + + +@pytest.fixture(name="setup_submit_area", scope="module") +def setup_submit_area(request: pytest.FixtureRequest) -> int: + + if not os.path.exists(SUBMIT_DIR): + submit_utils.download_and_extract_tar(SUBMISSION_URL, SUBMIT_DIR) + + def teardown_submit_area() -> None: + if not os.environ.get("NO_TEARDOWN"): + os.system(f"\\rm -rf {SUBMIT_DIR}") + + try: + os.makedirs(os.path.join(SUBMIT_DIR, "outputs_2")) + except Exception: + pass + + try: + os.makedirs(os.path.join(SUBMIT_DIR, "outputs_3")) + except Exception: + pass + + request.addfinalizer(teardown_submit_area) + + catalog_utils.load_yaml("tests/catalogs.yaml") + catalog_utils.apply("cardinal_roman_rubin") + + return 0 + + +def run_taskset_1_estimation_only( + model_file: str | Path, + test_file: str | Path, + output_file: str | Path, +) -> None: + """ + User supplied function to run estimation for task set 1 + + This function should use a model stored in model_file, which + is downloaded as part of the submission tar file. + + This function should write output data to output_file in qp + format. + + Parameters + ---------- + model_file: + Path to the model. This should be part of the submission + tar file. + test_file: + Path to the test file contains the photometric test data on + which the PZ estimation will be run + output_file: + Path to write the output data to. The output data should + be written in qp format. + """ + test_data = TableHandle("test", path=test_file) + estimator = sklearn_neurnet.SklNeurNetEstimator.make_stage( + name="estimate", + model=model_file, + output_mode="return", + ) + pz_out = estimator.estimate(test_data) + pz_out.data.ancil["object_id"] = test_data()["object_id"].astype(int) + pz_out.path = output_file + pz_out.write() + + +def run_taskset_1_training_and_estimation( + train_file: str | Path, + test_file: str | Path, + output_file: str | Path, +) -> None: + """ + User supplied function to run training and estimation for task set 1 + + This function should train a model and use it. + + This function should write output data to output_file in qp + format. + + Parameters + ---------- + train_file: + Path to the test file contains the photometric test data on + which the PZ estimation will be trained + test_file: + Path to the test file contains the photometric test data on + which the PZ estimation will be run + output_file: + Path to write the output data to. The output data should + be written in qp format. + """ + train_data = TableHandle("train", path=train_file) + test_data = TableHandle("test", path=test_file) + + informer = sklearn_neurnet.SklNeurNetInformer.make_stage( + name="inform", + ) + model = informer.inform(train_data) + + estimator = sklearn_neurnet.SklNeurNetEstimator.make_stage( + name="estimate", + model=model, + output_mode="return", + ) + pz_out = estimator.estimate(test_data) + pz_out.data.ancil["object_id"] = test_data()["object_id"].astype(int) + pz_out.path = output_file + pz_out.write() + + +def run_taskset_2_estimation_only( + model_file: str | Path, + test_file: str | Path, + output_file: str | Path, +) -> None: + """ + User supplied function to run estimation for task set 1 + + This function should use a model stored in model_file, which + is downloaded as part of the submission tar file. + + This function should write output data to output_file in qp + format. + + Parameters + ---------- + model_file: + Path to the model. This should be part of the submission + tar file. + test_file: + Path to the test file contains the photometric test data on + which the PZ estimation will be run + output_file: + Path to write the output data to. The output data should + be written in qp format. + """ + test_data = TableHandle("test", path=test_file) + estimator = sklearn_neurnet.SklNeurNetEstimator.make_stage( + name="estimate", + model=model_file, + output_mode="return", + ) + pz_out = estimator.estimate(test_data) + pz_out.data.ancil["object_id"] = test_data()["object_id"].astype(int) + pz_out.path = output_file + pz_out.write() + + +def run_taskset_2_training_and_estimation( + train_file: str | Path, + test_file: str | Path, + output_file: str | Path, +) -> None: + """ + User supplied function to run training and estimation for task set 1 + + This function should train a model and use it. + + This function should write output data to output_file in qp + format. + + Parameters + ---------- + test_file: + Path to the test file contains the photometric test data on + which the PZ estimation will be run + output_file: + Path to write the output data to. The output data should + be written in qp format. + """ + train_data = TableHandle("train", path=train_file) + test_data = TableHandle("test", path=test_file) + + informer = sklearn_neurnet.SklNeurNetInformer.make_stage( + name="inform", + ) + model = informer.inform(train_data) + + estimator = sklearn_neurnet.SklNeurNetEstimator.make_stage( + name="estimate", + model=model, + output_mode="return", + ) + pz_out = estimator.estimate(test_data) + pz_out.data.ancil["object_id"] = test_data()["object_id"].astype(int) + pz_out.path = output_file + pz_out.write() + + +def test_example_taskset_1( + setup_public_area: int, + setup_submit_area: int, +) -> None: + """ + Test fuction to validate a submisson for Taskset 1 + + You should not need to change this function + """ + + assert setup_public_area == 0 + assert setup_submit_area == 0 + + run_taskset_1( + PUBLIC_AREA, + SUBMISSION_NAME, + run_taskset_1_estimation_only, + run_taskset_1_training_and_estimation, + ) + + +def test_example_taskset_2( + setup_public_area: int, + setup_submit_area: int, +) -> None: + """ + Test fuction to validate a submisson for Taskset 1 + + You should not need to change this function + """ + + assert setup_public_area == 0 + assert setup_submit_area == 0 + + run_taskset_2( + PUBLIC_AREA, + SUBMISSION_NAME, + run_taskset_2_estimation_only, + run_taskset_2_training_and_estimation, + ) From e42e7c540d131e77e9be6400daa01133c6a2584a Mon Sep 17 00:00:00 2001 From: Raphael Shirley Date: Thu, 21 May 2026 17:37:35 +0200 Subject: [PATCH 02/18] Tried basic use of standard informer and estimator We may need to ship a trained model via a url tarball --- tests/test_lephare.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/test_lephare.py b/tests/test_lephare.py index 474510c..c5eaf33 100644 --- a/tests/test_lephare.py +++ b/tests/test_lephare.py @@ -3,7 +3,7 @@ import pytest from rail.core.data import TableHandle -from rail.estimation.algos import sklearn_neurnet +from rail.estimation.algos.lephare import LephareInformer, LephareEstimator, lsst_default_config from rail.utils import catalog_utils from pz_data_challenge.taskset_1 import run_taskset_1 @@ -11,8 +11,8 @@ from pz_data_challenge import submit_utils -SUBMISSION_NAME: str = "example" -SUBMISSION_URL: str = "https://s3df.slac.stanford.edu/people/echarles/submit_example.tgz" +SUBMISSION_NAME: str = "lephare" +SUBMISSION_URL: str = "https://github.com/lephare-photoz/pz_data_challenge" # don't change these SUBMIT_DIR: str = f"submissions/{SUBMISSION_NAME}" @@ -74,7 +74,7 @@ def run_taskset_1_estimation_only( be written in qp format. """ test_data = TableHandle("test", path=test_file) - estimator = sklearn_neurnet.SklNeurNetEstimator.make_stage( + estimator = LephareEstimator.make_stage( name="estimate", model=model_file, output_mode="return", @@ -113,12 +113,12 @@ def run_taskset_1_training_and_estimation( train_data = TableHandle("train", path=train_file) test_data = TableHandle("test", path=test_file) - informer = sklearn_neurnet.SklNeurNetInformer.make_stage( + informer = LephareInformer.make_stage( name="inform", ) model = informer.inform(train_data) - estimator = sklearn_neurnet.SklNeurNetEstimator.make_stage( + estimator = LephareEstimator.make_stage( name="estimate", model=model, output_mode="return", @@ -156,7 +156,7 @@ def run_taskset_2_estimation_only( be written in qp format. """ test_data = TableHandle("test", path=test_file) - estimator = sklearn_neurnet.SklNeurNetEstimator.make_stage( + estimator = LephareEstimator.make_stage( name="estimate", model=model_file, output_mode="return", @@ -192,12 +192,12 @@ def run_taskset_2_training_and_estimation( train_data = TableHandle("train", path=train_file) test_data = TableHandle("test", path=test_file) - informer = sklearn_neurnet.SklNeurNetInformer.make_stage( + informer = LephareInformer.make_stage( name="inform", ) model = informer.inform(train_data) - estimator = sklearn_neurnet.SklNeurNetEstimator.make_stage( + estimator = LephareEstimator.make_stage( name="estimate", model=model, output_mode="return", From 91f4063cb2948e02cef684bf4f26a80d789e48d0 Mon Sep 17 00:00:00 2001 From: Raphael Shirley Date: Fri, 22 May 2026 14:16:38 +0200 Subject: [PATCH 03/18] Uploaded tgz but still not working I think it may be a simple issue with paths --- tests/test_lephare.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_lephare.py b/tests/test_lephare.py index c5eaf33..97712bf 100644 --- a/tests/test_lephare.py +++ b/tests/test_lephare.py @@ -12,7 +12,7 @@ from pz_data_challenge import submit_utils SUBMISSION_NAME: str = "lephare" -SUBMISSION_URL: str = "https://github.com/lephare-photoz/pz_data_challenge" +SUBMISSION_URL: str = "https://www.raphaelshirley.co.uk/data/inform_lephare.tgz" # don't change these SUBMIT_DIR: str = f"submissions/{SUBMISSION_NAME}" From ba70d2ccfe887bceb0c0a8c3bd3a1be3d60f18bc Mon Sep 17 00:00:00 2001 From: Raphael Shirley Date: Tue, 26 May 2026 16:06:39 +0200 Subject: [PATCH 04/18] TEsts running locally --- tests/test_lephare.py | 93 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 82 insertions(+), 11 deletions(-) diff --git a/tests/test_lephare.py b/tests/test_lephare.py index 97712bf..0b06053 100644 --- a/tests/test_lephare.py +++ b/tests/test_lephare.py @@ -2,26 +2,39 @@ from pathlib import Path import pytest +import numpy as np + from rail.core.data import TableHandle -from rail.estimation.algos.lephare import LephareInformer, LephareEstimator, lsst_default_config +from rail.estimation.algos.lephare import ( + LephareInformer, + LephareEstimator, + lsst_default_config, +) from rail.utils import catalog_utils +import lephare as lp + from pz_data_challenge.taskset_1 import run_taskset_1 from pz_data_challenge.taskset_2 import run_taskset_2 from pz_data_challenge import submit_utils SUBMISSION_NAME: str = "lephare" -SUBMISSION_URL: str = "https://www.raphaelshirley.co.uk/data/inform_lephare.tgz" +SUBMISSION_URL: str = "https://www.raphaelshirley.co.uk/data/submit_lephare.tgz" # don't change these SUBMIT_DIR: str = f"submissions/{SUBMISSION_NAME}" PUBLIC_AREA: str = "tests/public" +# LePHARE specific globals +flux_cols = [f"mag_{b}_lsst" for b in "ugrizy"] +flux_cols += [f"mag_{b}_roman" for b in "YJH"] +flux_err_cols = [f"mag_{b}_lsst_err" for b in "ugrizy"] +flux_err_cols += [f"mag_{b}_roman_err" for b in "YJH"] + @pytest.fixture(name="setup_submit_area", scope="module") def setup_submit_area(request: pytest.FixtureRequest) -> int: - if not os.path.exists(SUBMIT_DIR): submit_utils.download_and_extract_tar(SUBMISSION_URL, SUBMIT_DIR) @@ -75,9 +88,13 @@ def run_taskset_1_estimation_only( """ test_data = TableHandle("test", path=test_file) estimator = LephareEstimator.make_stage( - name="estimate", + name="estimate_lephare", model=model_file, output_mode="return", + run_dir=SUBMIT_DIR, + bands=flux_cols, + err_bands=flux_err_cols, + hdf5_groupname="", ) pz_out = estimator.estimate(test_data) pz_out.data.ancil["object_id"] = test_data()["object_id"].astype(int) @@ -113,14 +130,39 @@ def run_taskset_1_training_and_estimation( train_data = TableHandle("train", path=train_file) test_data = TableHandle("test", path=test_file) + config = lsst_default_config.copy() + config.update( + { + "MAG_REF": "2", + "ERR_SCALE": "0.02", + "FILTER_CALIB": "0", + "FILTER_LIST": lsst_default_config["FILTER_LIST"] + + ",roman/Roman_WFI.F158.dat,roman/Roman_WFI.F184.dat,roman/Roman_WFI.F213.dat", + } + ) + lp.data_retrieval.get_auxiliary_data(keymap=config) + informer = LephareInformer.make_stage( - name="inform", + name="inform_lephare", + nondetect_val=np.nan, + model="lephare.pkl", + hdf5_groupname="", + lephare_config=config.copy(), + bands=flux_cols, + err_bands=flux_err_cols, + ref_band="mag_g_lsst", ) model = informer.inform(train_data) estimator = LephareEstimator.make_stage( - name="estimate", - model=model, + name="estimate_lephare", + # nondetect_val=np.nan, + model="lephare.pkl", + hdf5_groupname="", + # aliases=dict(input="test_data", output="lephare_estim"), + # use_inform_offsets=False, + bands=flux_cols, + err_bands=flux_err_cols, output_mode="return", ) pz_out = estimator.estimate(test_data) @@ -157,9 +199,13 @@ def run_taskset_2_estimation_only( """ test_data = TableHandle("test", path=test_file) estimator = LephareEstimator.make_stage( - name="estimate", + name="estimate_lephare", model=model_file, output_mode="return", + run_dir=SUBMIT_DIR, + bands=flux_cols, + err_bands=flux_err_cols, + hdf5_groupname="", ) pz_out = estimator.estimate(test_data) pz_out.data.ancil["object_id"] = test_data()["object_id"].astype(int) @@ -192,14 +238,39 @@ def run_taskset_2_training_and_estimation( train_data = TableHandle("train", path=train_file) test_data = TableHandle("test", path=test_file) + config = lsst_default_config.copy() + config.update( + { + "MAG_REF": "2", + "ERR_SCALE": "0.02", + "FILTER_CALIB": "0", + "FILTER_LIST": lsst_default_config["FILTER_LIST"] + + ",roman/Roman_WFI.F158.dat,roman/Roman_WFI.F184.dat,roman/Roman_WFI.F213.dat", + } + ) + lp.data_retrieval.get_auxiliary_data(keymap=config) + informer = LephareInformer.make_stage( - name="inform", + name="inform_lephare", + nondetect_val=np.nan, + model="lephare.pkl", + hdf5_groupname="", + lephare_config=config.copy(), + bands=flux_cols, + err_bands=flux_err_cols, + ref_band="mag_g_lsst", ) model = informer.inform(train_data) estimator = LephareEstimator.make_stage( - name="estimate", - model=model, + name="estimate_lephare", + # nondetect_val=np.nan, + model="lephare.pkl", + hdf5_groupname="", + # aliases=dict(input="test_data", output="lephare_estim"), + # use_inform_offsets=False, + bands=flux_cols, + err_bands=flux_err_cols, output_mode="return", ) pz_out = estimator.estimate(test_data) From fae2abc43da9722f66d0c7ddf9f9eb5c1aad6e05 Mon Sep 17 00:00:00 2001 From: Raphael Shirley Date: Tue, 26 May 2026 17:01:24 +0200 Subject: [PATCH 05/18] Added config download to preparation stage so always tehre I realised because process needs opacity but not sure why it needs it. Isn't that used in the spec lib stage? --- tests/test_lephare.py | 37 +++++++++++++------------------------ 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/tests/test_lephare.py b/tests/test_lephare.py index 0b06053..0ad94b1 100644 --- a/tests/test_lephare.py +++ b/tests/test_lephare.py @@ -32,6 +32,17 @@ flux_err_cols = [f"mag_{b}_lsst_err" for b in "ugrizy"] flux_err_cols += [f"mag_{b}_roman_err" for b in "YJH"] +config = lsst_default_config.copy() +config.update( + { + "MAG_REF": "2", + "ERR_SCALE": "0.02", + "FILTER_CALIB": "0", + "FILTER_LIST": lsst_default_config["FILTER_LIST"] + + ",roman/Roman_WFI.F158.dat,roman/Roman_WFI.F184.dat,roman/Roman_WFI.F213.dat", + } +) + @pytest.fixture(name="setup_submit_area", scope="module") def setup_submit_area(request: pytest.FixtureRequest) -> int: @@ -57,6 +68,8 @@ def teardown_submit_area() -> None: catalog_utils.load_yaml("tests/catalogs.yaml") catalog_utils.apply("cardinal_roman_rubin") + lp.data_retrieval.get_auxiliary_data(keymap=config) + return 0 @@ -130,18 +143,6 @@ def run_taskset_1_training_and_estimation( train_data = TableHandle("train", path=train_file) test_data = TableHandle("test", path=test_file) - config = lsst_default_config.copy() - config.update( - { - "MAG_REF": "2", - "ERR_SCALE": "0.02", - "FILTER_CALIB": "0", - "FILTER_LIST": lsst_default_config["FILTER_LIST"] - + ",roman/Roman_WFI.F158.dat,roman/Roman_WFI.F184.dat,roman/Roman_WFI.F213.dat", - } - ) - lp.data_retrieval.get_auxiliary_data(keymap=config) - informer = LephareInformer.make_stage( name="inform_lephare", nondetect_val=np.nan, @@ -238,18 +239,6 @@ def run_taskset_2_training_and_estimation( train_data = TableHandle("train", path=train_file) test_data = TableHandle("test", path=test_file) - config = lsst_default_config.copy() - config.update( - { - "MAG_REF": "2", - "ERR_SCALE": "0.02", - "FILTER_CALIB": "0", - "FILTER_LIST": lsst_default_config["FILTER_LIST"] - + ",roman/Roman_WFI.F158.dat,roman/Roman_WFI.F184.dat,roman/Roman_WFI.F213.dat", - } - ) - lp.data_retrieval.get_auxiliary_data(keymap=config) - informer = LephareInformer.make_stage( name="inform_lephare", nondetect_val=np.nan, From b404423c328bc2df007f5ec3ba45001b07bd2ec8 Mon Sep 17 00:00:00 2001 From: Raphael Shirley Date: Tue, 26 May 2026 17:46:16 +0200 Subject: [PATCH 06/18] Added required para file This should be in the standard list --- tests/test_lephare.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/test_lephare.py b/tests/test_lephare.py index 0ad94b1..d35c8b0 100644 --- a/tests/test_lephare.py +++ b/tests/test_lephare.py @@ -68,7 +68,9 @@ def teardown_submit_area() -> None: catalog_utils.load_yaml("tests/catalogs.yaml") catalog_utils.apply("cardinal_roman_rubin") - lp.data_retrieval.get_auxiliary_data(keymap=config) + lp.data_retrieval.get_auxiliary_data( + keymap=config, additional_files=["examples/output.para"] + ) return 0 From 89b2f3a9832641272a62a297412746e6e9f270fc Mon Sep 17 00:00:00 2001 From: Raphael Shirley Date: Tue, 26 May 2026 18:51:06 +0200 Subject: [PATCH 07/18] Added output para to config so that it can handle moved lepharedir This might need some thought --- tests/test_lephare.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test_lephare.py b/tests/test_lephare.py index d35c8b0..4f1555d 100644 --- a/tests/test_lephare.py +++ b/tests/test_lephare.py @@ -110,6 +110,7 @@ def run_taskset_1_estimation_only( bands=flux_cols, err_bands=flux_err_cols, hdf5_groupname="", + lephare_config=config.copy(), ) pz_out = estimator.estimate(test_data) pz_out.data.ancil["object_id"] = test_data()["object_id"].astype(int) @@ -209,6 +210,7 @@ def run_taskset_2_estimation_only( bands=flux_cols, err_bands=flux_err_cols, hdf5_groupname="", + lephare_config=config.copy(), ) pz_out = estimator.estimate(test_data) pz_out.data.ancil["object_id"] = test_data()["object_id"].astype(int) From 3493f4fa6b1717c0f5819d7b772546ba4a3728b5 Mon Sep 17 00:00:00 2001 From: Raphael Shirley Date: Tue, 26 May 2026 20:48:31 +0200 Subject: [PATCH 08/18] Fix error with Roman filter names YJH are F106, F129, and F158 --- tests/test_lephare.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_lephare.py b/tests/test_lephare.py index 4f1555d..02be774 100644 --- a/tests/test_lephare.py +++ b/tests/test_lephare.py @@ -39,7 +39,7 @@ "ERR_SCALE": "0.02", "FILTER_CALIB": "0", "FILTER_LIST": lsst_default_config["FILTER_LIST"] - + ",roman/Roman_WFI.F158.dat,roman/Roman_WFI.F184.dat,roman/Roman_WFI.F213.dat", + + ",roman/Roman_WFI.F106.dat,roman/Roman_WFI.F129.dat,roman/Roman_WFI.F158.dat", } ) From 967ef3a992d6ee6577d48b461538665faf5292cd Mon Sep 17 00:00:00 2001 From: Raphael Shirley Date: Wed, 27 May 2026 15:58:12 +0200 Subject: [PATCH 09/18] Update config to work with changes to config values --- tests/test_lephare.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_lephare.py b/tests/test_lephare.py index 02be774..6ae9864 100644 --- a/tests/test_lephare.py +++ b/tests/test_lephare.py @@ -110,7 +110,7 @@ def run_taskset_1_estimation_only( bands=flux_cols, err_bands=flux_err_cols, hdf5_groupname="", - lephare_config=config.copy(), + **{f"lephare.{k}": v for k, v in config.items()}, ) pz_out = estimator.estimate(test_data) pz_out.data.ancil["object_id"] = test_data()["object_id"].astype(int) @@ -151,7 +151,7 @@ def run_taskset_1_training_and_estimation( nondetect_val=np.nan, model="lephare.pkl", hdf5_groupname="", - lephare_config=config.copy(), + **{f"lephare.{k}": v for k, v in config.items()}, bands=flux_cols, err_bands=flux_err_cols, ref_band="mag_g_lsst", @@ -210,7 +210,7 @@ def run_taskset_2_estimation_only( bands=flux_cols, err_bands=flux_err_cols, hdf5_groupname="", - lephare_config=config.copy(), + **{f"lephare.{k}": v for k, v in config.items()}, ) pz_out = estimator.estimate(test_data) pz_out.data.ancil["object_id"] = test_data()["object_id"].astype(int) @@ -248,7 +248,7 @@ def run_taskset_2_training_and_estimation( nondetect_val=np.nan, model="lephare.pkl", hdf5_groupname="", - lephare_config=config.copy(), + **{f"lephare.{k}": v for k, v in config.items()}, bands=flux_cols, err_bands=flux_err_cols, ref_band="mag_g_lsst", From c53436d6204064a76c861eb92d265061823daf2f Mon Sep 17 00:00:00 2001 From: Raphael Shirley Date: Wed, 27 May 2026 16:07:05 +0200 Subject: [PATCH 10/18] Make sure we don't use the model config with my local paths --- tests/test_lephare.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test_lephare.py b/tests/test_lephare.py index 6ae9864..5783ce1 100644 --- a/tests/test_lephare.py +++ b/tests/test_lephare.py @@ -110,6 +110,7 @@ def run_taskset_1_estimation_only( bands=flux_cols, err_bands=flux_err_cols, hdf5_groupname="", + lephare_config_from_model=False, **{f"lephare.{k}": v for k, v in config.items()}, ) pz_out = estimator.estimate(test_data) @@ -210,6 +211,7 @@ def run_taskset_2_estimation_only( bands=flux_cols, err_bands=flux_err_cols, hdf5_groupname="", + lephare_config_from_model=False, **{f"lephare.{k}": v for k, v in config.items()}, ) pz_out = estimator.estimate(test_data) From 2b37833123bddb373ea2313c90b1108cda2fafc6 Mon Sep 17 00:00:00 2001 From: Raphael Shirley Date: Thu, 28 May 2026 17:09:11 +0200 Subject: [PATCH 11/18] Some option changes for speed up removed AGN and reduced redshift grid --- tests/test_lephare.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/test_lephare.py b/tests/test_lephare.py index 5783ce1..19999d9 100644 --- a/tests/test_lephare.py +++ b/tests/test_lephare.py @@ -40,6 +40,8 @@ "FILTER_CALIB": "0", "FILTER_LIST": lsst_default_config["FILTER_LIST"] + ",roman/Roman_WFI.F106.dat,roman/Roman_WFI.F129.dat,roman/Roman_WFI.F158.dat", + "ZPHOTLIB": "LSST_STAR_MAG,LSST_GAL_MAG", + "Z_STEP": "0.02,0.,3.", } ) @@ -156,6 +158,10 @@ def run_taskset_1_training_and_estimation( bands=flux_cols, err_bands=flux_err_cols, ref_band="mag_g_lsst", + zmin=float(config["Z_STEP"].split(",")[1]), + zmax=float(config["Z_STEP"].split(",")[2]), + nzbins=1 + + float(config["Z_STEP"].split(",")[2]) / float(config["Z_STEP"].split(",")[0]), ) model = informer.inform(train_data) @@ -254,6 +260,10 @@ def run_taskset_2_training_and_estimation( bands=flux_cols, err_bands=flux_err_cols, ref_band="mag_g_lsst", + zmin=float(config["Z_STEP"].split(",")[1]), + zmax=float(config["Z_STEP"].split(",")[2]), + nzbins=1 + + float(config["Z_STEP"].split(",")[2]) / float(config["Z_STEP"].split(",")[0]), ) model = informer.inform(train_data) From f34cbf4e6d83e94a1107449b916fcb63ddcfbc64 Mon Sep 17 00:00:00 2001 From: Raphael Shirley Date: Fri, 19 Jun 2026 14:20:57 +0200 Subject: [PATCH 12/18] Updated config a little reduced grid size for time and changed gal models --- tests/test_lephare.py | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/tests/test_lephare.py b/tests/test_lephare.py index 19999d9..c7a10b8 100644 --- a/tests/test_lephare.py +++ b/tests/test_lephare.py @@ -33,17 +33,23 @@ flux_err_cols += [f"mag_{b}_roman_err" for b in "YJH"] config = lsst_default_config.copy() -config.update( - { - "MAG_REF": "2", - "ERR_SCALE": "0.02", - "FILTER_CALIB": "0", - "FILTER_LIST": lsst_default_config["FILTER_LIST"] - + ",roman/Roman_WFI.F106.dat,roman/Roman_WFI.F129.dat,roman/Roman_WFI.F158.dat", - "ZPHOTLIB": "LSST_STAR_MAG,LSST_GAL_MAG", - "Z_STEP": "0.02,0.,3.", - } -) +updates = { + "MAG_REF": "2", + "ERR_SCALE": "0.02", + "FILTER_CALIB": "0", + "FILTER_LIST": lsst_default_config["FILTER_LIST"] + + ",roman/Roman_WFI.F106.dat,roman/Roman_WFI.F129.dat,roman/Roman_WFI.F158.dat", + "GLB_CONTEXT": "0", + "MABS_CONTEXT": "0", + # Remove AGN for speed + "ZPHOTLIB": "LSST_STAR_MAG,LSST_GAL_MAG", + "Z_STEP": "0.02,0.,3.", + "EM_DISPERSION": "0.5,1.,1.5", + "ERR_FACTOR": "1.", +} +config.update(updates) +params = {f"lephare.{k}": v for k, v in updates.items()} +params["gal.MOD_EXTINC"] = ("16,24,24,31,24,31,24,31",) @pytest.fixture(name="setup_submit_area", scope="module") @@ -113,7 +119,7 @@ def run_taskset_1_estimation_only( err_bands=flux_err_cols, hdf5_groupname="", lephare_config_from_model=False, - **{f"lephare.{k}": v for k, v in config.items()}, + **params, ) pz_out = estimator.estimate(test_data) pz_out.data.ancil["object_id"] = test_data()["object_id"].astype(int) @@ -154,7 +160,7 @@ def run_taskset_1_training_and_estimation( nondetect_val=np.nan, model="lephare.pkl", hdf5_groupname="", - **{f"lephare.{k}": v for k, v in config.items()}, + **params, bands=flux_cols, err_bands=flux_err_cols, ref_band="mag_g_lsst", @@ -218,7 +224,7 @@ def run_taskset_2_estimation_only( err_bands=flux_err_cols, hdf5_groupname="", lephare_config_from_model=False, - **{f"lephare.{k}": v for k, v in config.items()}, + **params, ) pz_out = estimator.estimate(test_data) pz_out.data.ancil["object_id"] = test_data()["object_id"].astype(int) @@ -256,7 +262,7 @@ def run_taskset_2_training_and_estimation( nondetect_val=np.nan, model="lephare.pkl", hdf5_groupname="", - **{f"lephare.{k}": v for k, v in config.items()}, + **params, bands=flux_cols, err_bands=flux_err_cols, ref_band="mag_g_lsst", From d558f5d0456bcdbbeaff35e1aee64ad75bd8202f Mon Sep 17 00:00:00 2001 From: Raphael Shirley Date: Fri, 19 Jun 2026 14:41:58 +0200 Subject: [PATCH 13/18] tried simply increasing the timeout to 120s --- tests/test_lephare.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/test_lephare.py b/tests/test_lephare.py index c7a10b8..f6e7796 100644 --- a/tests/test_lephare.py +++ b/tests/test_lephare.py @@ -19,6 +19,9 @@ from pz_data_challenge import submit_utils +# We seem to need more for LePHARE at the durrent address +submit_utils._DOWNLOAD_TIMEOUT = 120 + SUBMISSION_NAME: str = "lephare" SUBMISSION_URL: str = "https://www.raphaelshirley.co.uk/data/submit_lephare.tgz" From 750b36ac49a4a1d9b919a1d99d23bd55fbe4442c Mon Sep 17 00:00:00 2001 From: Raphael Shirley Date: Fri, 19 Jun 2026 15:52:57 +0200 Subject: [PATCH 14/18] Increased download limit again as still failing sometimes --- tests/test_lephare.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_lephare.py b/tests/test_lephare.py index f6e7796..b9fbd51 100644 --- a/tests/test_lephare.py +++ b/tests/test_lephare.py @@ -19,8 +19,8 @@ from pz_data_challenge import submit_utils -# We seem to need more for LePHARE at the durrent address -submit_utils._DOWNLOAD_TIMEOUT = 120 +# We seem to need more for LePHARE at the current address +submit_utils._DOWNLOAD_TIMEOUT = 240 SUBMISSION_NAME: str = "lephare" SUBMISSION_URL: str = "https://www.raphaelshirley.co.uk/data/submit_lephare.tgz" From a2978ae55f43bbcfd8b9d8f1a9ec3c48bd813c42 Mon Sep 17 00:00:00 2001 From: Raphael Shirley Date: Fri, 19 Jun 2026 16:55:11 +0200 Subject: [PATCH 15/18] IT seems to be unreliable Perhaps i need a new host for the file --- tests/test_lephare.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_lephare.py b/tests/test_lephare.py index b9fbd51..1300b84 100644 --- a/tests/test_lephare.py +++ b/tests/test_lephare.py @@ -20,7 +20,7 @@ from pz_data_challenge import submit_utils # We seem to need more for LePHARE at the current address -submit_utils._DOWNLOAD_TIMEOUT = 240 +submit_utils._DOWNLOAD_TIMEOUT = 300 SUBMISSION_NAME: str = "lephare" SUBMISSION_URL: str = "https://www.raphaelshirley.co.uk/data/submit_lephare.tgz" From b395282dfd52f898a08eaeb41b79c523d9d74665 Mon Sep 17 00:00:00 2001 From: Raphael Shirley Date: Fri, 19 Jun 2026 17:26:01 +0200 Subject: [PATCH 16/18] try dropbox instead --- tests/test_lephare.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_lephare.py b/tests/test_lephare.py index 1300b84..72057eb 100644 --- a/tests/test_lephare.py +++ b/tests/test_lephare.py @@ -23,7 +23,8 @@ submit_utils._DOWNLOAD_TIMEOUT = 300 SUBMISSION_NAME: str = "lephare" -SUBMISSION_URL: str = "https://www.raphaelshirley.co.uk/data/submit_lephare.tgz" +SUBMISSION_URL: str = "https://www.dropbox.com/scl/fi/fq1mvmt0d4cgb0qs0zbe2/submit_lephare.tgz?rlkey=3kmk5yiu6pqkx4g3vxbtkz41x&st=yrvmegii&e=1&dl=1" +# SUBMISSION_URL: str = "https://www.raphaelshirley.co.uk/data/submit_lephare.tgz" # don't change these SUBMIT_DIR: str = f"submissions/{SUBMISSION_NAME}" From 96b900eaf74ab5ae810b3866d3dcd6494aefc810 Mon Sep 17 00:00:00 2001 From: Raphael Shirley Date: Fri, 19 Jun 2026 17:48:16 +0200 Subject: [PATCH 17/18] More tests on download --- tests/test_lephare.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/test_lephare.py b/tests/test_lephare.py index 72057eb..1eb4ac4 100644 --- a/tests/test_lephare.py +++ b/tests/test_lephare.py @@ -20,11 +20,12 @@ from pz_data_challenge import submit_utils # We seem to need more for LePHARE at the current address -submit_utils._DOWNLOAD_TIMEOUT = 300 +submit_utils._DOWNLOAD_TIMEOUT = 120 +submit_utils._DOWNLOAD_RETRY_DELAY = 30 SUBMISSION_NAME: str = "lephare" -SUBMISSION_URL: str = "https://www.dropbox.com/scl/fi/fq1mvmt0d4cgb0qs0zbe2/submit_lephare.tgz?rlkey=3kmk5yiu6pqkx4g3vxbtkz41x&st=yrvmegii&e=1&dl=1" -# SUBMISSION_URL: str = "https://www.raphaelshirley.co.uk/data/submit_lephare.tgz" +# SUBMISSION_URL: str = "https://www.dropbox.com/scl/fi/fq1mvmt0d4cgb0qs0zbe2/submit_lephare.tgz?rlkey=3kmk5yiu6pqkx4g3vxbtkz41x&st=yrvmegii&e=1&dl=1" +SUBMISSION_URL: str = "https://www.raphaelshirley.co.uk/data/submit_lephare.tgz" # don't change these SUBMIT_DIR: str = f"submissions/{SUBMISSION_NAME}" From 4d944c68b479dcb80db8551ebd6e365291af8636 Mon Sep 17 00:00:00 2001 From: Raphael Shirley Date: Mon, 22 Jun 2026 12:10:01 +0200 Subject: [PATCH 18/18] Trying to solve issue with null test --- tests/conftest.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/conftest.py b/tests/conftest.py index 9074469..82b72e0 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -12,7 +12,9 @@ def setup_public_area(request: pytest.FixtureRequest) -> int: """ A pytest fixture to download the public data """ - + # + submit_utils._DOWNLOAD_TIMEOUT = 120 + submit_utils._DOWNLOAD_RETRY_DELAY = 30 if not os.path.exists("tests/public"): # Note that the tar file has "public" as top level directory # so we if we extract to "tests" the files actually end