From 72bc5be3c8ab4dda6f109854df5eb42c6355011c Mon Sep 17 00:00:00 2001 From: Jheison Martinez Bolivar Date: Mon, 16 Nov 2026 14:57:46 -0500 Subject: [PATCH 1/3] fix(bench): scaffold new methods under the lab's Apache-2.0 licence --- src/astro_denoise/bench/scaffold_templates.py | 225 ++++++++++++++++-- tests/bench/snapshots/scaffold_wavelet.json | 4 +- tests/bench/test_scaffold.py | 9 + 3 files changed, 214 insertions(+), 24 deletions(-) diff --git a/src/astro_denoise/bench/scaffold_templates.py b/src/astro_denoise/bench/scaffold_templates.py index b9c9123..cec2a89 100644 --- a/src/astro_denoise/bench/scaffold_templates.py +++ b/src/astro_denoise/bench/scaffold_templates.py @@ -18,7 +18,7 @@ description = "@DESCRIPTION@" readme = "README.md" requires-python = ">=3.10" -license = "MIT" +license = "Apache-2.0" dependencies = [ "numpy>=1.26", "astropy>=6.0", @@ -337,25 +337,206 @@ def test_cli_protocol(tmp_path, capsys): """ LICENSE = """\ -MIT License - -Copyright (c) 2026 UniverLab - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + """ diff --git a/tests/bench/snapshots/scaffold_wavelet.json b/tests/bench/snapshots/scaffold_wavelet.json index e775e18..a3d1a8e 100644 --- a/tests/bench/snapshots/scaffold_wavelet.json +++ b/tests/bench/snapshots/scaffold_wavelet.json @@ -1,5 +1,5 @@ { - "pyproject.toml": "[build-system]\nrequires = [\"setuptools>=68\"]\nbuild-backend = \"setuptools.build_meta\"\n\n[project]\nname = \"astro-denoise-wavelet\"\nversion = \"0.1.0\"\ndescription = \"wavelet denoising method for the astro-denoise benchmark\"\nreadme = \"README.md\"\nrequires-python = \">=3.10\"\nlicense = \"MIT\"\ndependencies = [\n \"numpy>=1.26\",\n \"astropy>=6.0\",\n \"rich>=13.0\",\n]\n\n[project.optional-dependencies]\ndev = [\"pytest>=8.0\", \"ruff>=0.8\", \"mypy>=1.13\"]\n\n[project.entry-points.\"astro_denoise.methods\"]\nwavelet = \"astro_denoise_wavelet.denoiser:WaveletDenoiser\"\n\n[tool.setuptools.packages.find]\nwhere = [\"src\"]\ninclude = [\"astro_denoise_wavelet*\"]\n\n[tool.ruff]\ntarget-version = \"py310\"\nline-length = 100\n\n[tool.ruff.lint]\nselect = [\"E\", \"F\", \"I\", \"N\", \"UP\", \"B\", \"SIM\"]\n\n[tool.mypy]\npython_version = \"3.12\"\nignore_missing_imports = true\n\n[tool.pytest.ini_options]\ntestpaths = [\"tests\"]\n", + "pyproject.toml": "[build-system]\nrequires = [\"setuptools>=68\"]\nbuild-backend = \"setuptools.build_meta\"\n\n[project]\nname = \"astro-denoise-wavelet\"\nversion = \"0.1.0\"\ndescription = \"wavelet denoising method for the astro-denoise benchmark\"\nreadme = \"README.md\"\nrequires-python = \">=3.10\"\nlicense = \"Apache-2.0\"\ndependencies = [\n \"numpy>=1.26\",\n \"astropy>=6.0\",\n \"rich>=13.0\",\n]\n\n[project.optional-dependencies]\ndev = [\"pytest>=8.0\", \"ruff>=0.8\", \"mypy>=1.13\"]\n\n[project.entry-points.\"astro_denoise.methods\"]\nwavelet = \"astro_denoise_wavelet.denoiser:WaveletDenoiser\"\n\n[tool.setuptools.packages.find]\nwhere = [\"src\"]\ninclude = [\"astro_denoise_wavelet*\"]\n\n[tool.ruff]\ntarget-version = \"py310\"\nline-length = 100\n\n[tool.ruff.lint]\nselect = [\"E\", \"F\", \"I\", \"N\", \"UP\", \"B\", \"SIM\"]\n\n[tool.mypy]\npython_version = \"3.12\"\nignore_missing_imports = true\n\n[tool.pytest.ini_options]\ntestpaths = [\"tests\"]\n", "src/astro_denoise_wavelet/__init__.py": "\"\"\"astro-denoise-wavelet: wavelet denoising method for the astro-denoise benchmark\"\"\"\n\n__version__ = \"0.1.0\"\n\nfrom .denoiser import WaveletDenoiser\n\n__all__ = [\"WaveletDenoiser\", \"__version__\"]\n", "src/astro_denoise_wavelet/interface.py": "\"\"\"Standard denoising-method contract of the astro-denoise platform.\n\nEvery algorithm module ships (a copy of) this ABC so methods stay\nimportable without a shared runtime dependency; `astro-denoise-bench`\nonly relies on the duck-typed ``denoise`` / ``name`` protocol.\n\"\"\"\n\nfrom __future__ import annotations\n\nfrom abc import ABC, abstractmethod\n\nimport numpy as np\n\n\nclass DenoiseMethod(ABC):\n \"\"\"A denoising algorithm operating on 2-D image patches.\"\"\"\n\n @abstractmethod\n def denoise(self, patch: np.ndarray) -> np.ndarray:\n \"\"\"Return the denoised version of ``patch`` (same shape/dtype float).\"\"\"\n\n @abstractmethod\n def name(self) -> str:\n \"\"\"Short identifier of the method.\"\"\"\n\n def fit(self, patches: list[np.ndarray]) -> None: # noqa: B027\n \"\"\"Optional training/calibration step; no-op for classical methods.\"\"\"\n", "src/astro_denoise_wavelet/denoiser.py": "\"\"\"wavelet denoiser implementing the astro-denoise contract.\n\nReplace the body of :meth:`denoise` with your algorithm. It receives a\n2-D float array (one patch / region) and must return an array of the\nsame shape. Config keys arrive through :class:`WaveletDenoiser`'s\nconstructor (forwarded from the CLI ``--config`` JSON).\n\"\"\"\n\nfrom __future__ import annotations\n\nimport numpy as np\n\nfrom .interface import DenoiseMethod\n\n\nclass WaveletDenoiser(DenoiseMethod):\n \"\"\"TODO: describe the method and its parameters.\"\"\"\n\n def __init__(self, **config):\n self.config = config\n\n def name(self) -> str:\n return \"wavelet\"\n\n def denoise(self, patch: np.ndarray) -> np.ndarray:\n patch = np.asarray(patch, dtype=np.float64)\n if patch.ndim != 2:\n raise ValueError(f\"expected a 2-D patch, got shape {patch.shape}\")\n # TODO: implement the actual denoising. The pass-through below\n # keeps the module runnable end-to-end from the first minute.\n return patch.copy()\n", @@ -9,5 +9,5 @@ "README.md": "# astro-denoise-wavelet\n\n> wavelet denoising method for the astro-denoise benchmark\n\nMódulo de método para la plataforma [astro-denoise](https://github.com/UniverLab).\nGenerado con `astro-denoise-bench --new-method wavelet` — el esqueleto ya corre\nend-to-end; solo falta tu algoritmo.\n\n## Implementar el método\n\nEdita `src/astro_denoise_wavelet/denoiser.py` y reemplaza el cuerpo de `denoise()`\n(recibe y devuelve un `ndarray` 2-D float). Los parámetros llegan por el\nJSON de `--config` al constructor.\n\n## Desarrollo\n\n```bash\nuv sync --all-extras # crea .venv e instala en editable\nuv run pytest # los tests del esqueleto ya pasan\nuv run ruff format . && uv run ruff check . && uv run mypy src/\n```\n\n## Correr en el benchmark\n\n```bash\npython -m astro_denoise.bench \\\n --algo wavelet \\\n --manifest data/curated/manifest.json \\\n --python /ruta/a/astro-denoise-wavelet/.venv/bin/python \\\n --metrics-python /ruta/a/astro-denoise-metrics/.venv/bin/python\n```\n\nEl orquestador invoca `python -m astro_denoise_wavelet --input ... --output ... [--config ...]`\ny espera una línea JSON de status por stdout (ya implementada en `__main__.py`).\n\n## Protocolo\n\n- Entry point `astro_denoise.methods` -> `wavelet` (descubrimiento automático).\n- Contrato `DenoiseMethod` en `src/astro_denoise_wavelet/interface.py`.\n- Las métricas del benchmark se explican con `astro-denoise-metrics --explain`.\n", ".gitignore": "__pycache__/\n*.py[cod]\n*.egg-info/\nbuild/\ndist/\n.venv/\nvenv/\n.pytest_cache/\n.mypy_cache/\n.coverage\n*.fits\n.env\n", ".github/workflows/ci.yml": "name: CI\n\non:\n pull_request:\n workflow_dispatch:\n\njobs:\n python-ci:\n uses: UniverLab/workflows/.github/workflows/python-ci.yml@main\n with:\n python-version: \"3.12\"\n", - "LICENSE": "MIT License\n\nCopyright (c) 2026 UniverLab\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n" + "LICENSE": " Apache License\n Version 2.0, January 2004\n http://www.apache.org/licenses/\n\n TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n 1. Definitions.\n\n \"License\" shall mean the terms and conditions for use, reproduction,\n and distribution as defined by Sections 1 through 9 of this document.\n\n \"Licensor\" shall mean the copyright owner or entity authorized by\n the copyright owner that is granting the License.\n\n \"Legal Entity\" shall mean the union of the acting entity and all\n other entities that control, are controlled by, or are under common\n control with that entity. For the purposes of this definition,\n \"control\" means (i) the power, direct or indirect, to cause the\n direction or management of such entity, whether by contract or\n otherwise, or (ii) ownership of fifty percent (50%) or more of the\n outstanding shares, or (iii) beneficial ownership of such entity.\n\n \"You\" (or \"Your\") shall mean an individual or Legal Entity\n exercising permissions granted by this License.\n\n \"Source\" form shall mean the preferred form for making modifications,\n including but not limited to software source code, documentation\n source, and configuration files.\n\n \"Object\" form shall mean any form resulting from mechanical\n transformation or translation of a Source form, including but\n not limited to compiled object code, generated documentation,\n and conversions to other media types.\n\n \"Work\" shall mean the work of authorship, whether in Source or\n Object form, made available under the License, as indicated by a\n copyright notice that is included in or attached to the work\n (an example is provided in the Appendix below).\n\n \"Derivative Works\" shall mean any work, whether in Source or Object\n form, that is based on (or derived from) the Work and for which the\n editorial revisions, annotations, elaborations, or other modifications\n represent, as a whole, an original work of authorship. For the purposes\n of this License, Derivative Works shall not include works that remain\n separable from, or merely link (or bind by name) to the interfaces of,\n the Work and Derivative Works thereof.\n\n \"Contribution\" shall mean any work of authorship, including\n the original version of the Work and any modifications or additions\n to that Work or Derivative Works thereof, that is intentionally\n submitted to Licensor for inclusion in the Work by the copyright owner\n or by an individual or Legal Entity authorized to submit on behalf of\n the copyright owner. For the purposes of this definition, \"submitted\"\n means any form of electronic, verbal, or written communication sent\n to the Licensor or its representatives, including but not limited to\n communication on electronic mailing lists, source code control systems,\n and issue tracking systems that are managed by, or on behalf of, the\n Licensor for the purpose of discussing and improving the Work, but\n excluding communication that is conspicuously marked or otherwise\n designated in writing by the copyright owner as \"Not a Contribution.\"\n\n \"Contributor\" shall mean Licensor and any individual or Legal Entity\n on behalf of whom a Contribution has been received by Licensor and\n subsequently incorporated within the Work.\n\n 2. Grant of Copyright License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n copyright license to reproduce, prepare Derivative Works of,\n publicly display, publicly perform, sublicense, and distribute the\n Work and such Derivative Works in Source or Object form.\n\n 3. Grant of Patent License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n (except as stated in this section) patent license to make, have made,\n use, offer to sell, sell, import, and otherwise transfer the Work,\n where such license applies only to those patent claims licensable\n by such Contributor that are necessarily infringed by their\n Contribution(s) alone or by combination of their Contribution(s)\n with the Work to which such Contribution(s) was submitted. If You\n institute patent litigation against any entity (including a\n cross-claim or counterclaim in a lawsuit) alleging that the Work\n or a Contribution incorporated within the Work constitutes direct\n or contributory patent infringement, then any patent licenses\n granted to You under this License for that Work shall terminate\n as of the date such litigation is filed.\n\n 4. Redistribution. You may reproduce and distribute copies of the\n Work or Derivative Works thereof in any medium, with or without\n modifications, and in Source or Object form, provided that You\n meet the following conditions:\n\n (a) You must give any other recipients of the Work or\n Derivative Works a copy of this License; and\n\n (b) You must cause any modified files to carry prominent notices\n stating that You changed the files; and\n\n (c) You must retain, in the Source form of any Derivative Works\n that You distribute, all copyright, patent, trademark, and\n attribution notices from the Source form of the Work,\n excluding those notices that do not pertain to any part of\n the Derivative Works; and\n\n (d) If the Work includes a \"NOTICE\" text file as part of its\n distribution, then any Derivative Works that You distribute must\n include a readable copy of the attribution notices contained\n within such NOTICE file, excluding those notices that do not\n pertain to any part of the Derivative Works, in at least one\n of the following places: within a NOTICE text file distributed\n as part of the Derivative Works; within the Source form or\n documentation, if provided along with the Derivative Works; or,\n within a display generated by the Derivative Works, if and\n wherever such third-party notices normally appear. The contents\n of the NOTICE file are for informational purposes only and\n do not modify the License. You may add Your own attribution\n notices within Derivative Works that You distribute, alongside\n or as an addendum to the NOTICE text from the Work, provided\n that such additional attribution notices cannot be construed\n as modifying the License.\n\n You may add Your own copyright statement to Your modifications and\n may provide additional or different license terms and conditions\n for use, reproduction, or distribution of Your modifications, or\n for any such Derivative Works as a whole, provided Your use,\n reproduction, and distribution of the Work otherwise complies with\n the conditions stated in this License.\n\n 5. Submission of Contributions. Unless You explicitly state otherwise,\n any Contribution intentionally submitted for inclusion in the Work\n by You to the Licensor shall be under the terms and conditions of\n this License, without any additional terms or conditions.\n Notwithstanding the above, nothing herein shall supersede or modify\n the terms of any separate license agreement you may have executed\n with Licensor regarding such Contributions.\n\n 6. Trademarks. This License does not grant permission to use the trade\n names, trademarks, service marks, or product names of the Licensor,\n except as required for reasonable and customary use in describing the\n origin of the Work and reproducing the content of the NOTICE file.\n\n 7. Disclaimer of Warranty. Unless required by applicable law or\n agreed to in writing, Licensor provides the Work (and each\n Contributor provides its Contributions) on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n implied, including, without limitation, any warranties or conditions\n of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n PARTICULAR PURPOSE. You are solely responsible for determining the\n appropriateness of using or redistributing the Work and assume any\n risks associated with Your exercise of permissions under this License.\n\n 8. Limitation of Liability. In no event and under no legal theory,\n whether in tort (including negligence), contract, or otherwise,\n unless required by applicable law (such as deliberate and grossly\n negligent acts) or agreed to in writing, shall any Contributor be\n liable to You for damages, including any direct, indirect, special,\n incidental, or consequential damages of any character arising as a\n result of this License or out of the use or inability to use the\n Work (including but not limited to damages for loss of goodwill,\n work stoppage, computer failure or malfunction, or any and all\n other commercial damages or losses), even if such Contributor\n has been advised of the possibility of such damages.\n\n 9. Accepting Warranty or Additional Liability. While redistributing\n the Work or Derivative Works thereof, You may choose to offer,\n and charge a fee for, acceptance of support, warranty, indemnity,\n or other liability obligations and/or rights consistent with this\n License. However, in accepting such obligations, You may act only\n on Your own behalf and on Your sole responsibility, not on behalf\n of any other Contributor, and only if You agree to indemnify,\n defend, and hold each Contributor harmless for any liability\n incurred by, or claims asserted against, such Contributor by reason\n of your accepting any such warranty or additional liability.\n\n END OF TERMS AND CONDITIONS\n\n APPENDIX: How to apply the Apache License to your work.\n\n To apply the Apache License to your work, attach the following\n boilerplate notice, with the fields enclosed by brackets \"[]\"\n replaced with your own identifying information. (Don't include\n the brackets!) The text should be enclosed in the appropriate\n comment syntax for the file format. We also recommend that a\n file or class name and description of purpose be included on the\n same \"printed page\" as the copyright notice for easier\n identification within third-party archives.\n\n Copyright [yyyy] [name of copyright owner]\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n\n" } diff --git a/tests/bench/test_scaffold.py b/tests/bench/test_scaffold.py index fd1bff9..ada07db 100644 --- a/tests/bench/test_scaffold.py +++ b/tests/bench/test_scaffold.py @@ -10,6 +10,7 @@ from astro_denoise.bench.scaffold import _files, scaffold_method SNAPSHOT = Path(__file__).parent / "snapshots" / "scaffold_wavelet.json" +ROOT_LICENSE = Path(__file__).parents[2] / "LICENSE" WAVELET_ARGS = ("wavelet", "wavelet denoising method for the astro-denoise benchmark") PLACEHOLDERS = ("@PKG@", "@REPO@", "@NAME@", "@NAME_CAP@", "@DESCRIPTION@") @@ -58,6 +59,14 @@ def test_no_unreplaced_placeholders(self): for placeholder in PLACEHOLDERS: assert placeholder not in content, f"{placeholder} left in {path}" + def test_generated_license_is_the_repository_license(self): + assert _files(*WAVELET_ARGS)["LICENSE"] == ROOT_LICENSE.read_text(encoding="utf-8") + + def test_pyproject_declares_apache_license(self): + pyproject = _files(*WAVELET_ARGS)["pyproject.toml"] + assert 'license = "Apache-2.0"' in pyproject + assert "MIT" not in pyproject + class TestScaffoldRunsOutOfTheBox: def test_generated_tests_pass_and_cli_speaks_protocol(self, tmp_path): From 9e61b771c49c6def07b7ed0e7a83ab3be3e590b8 Mon Sep 17 00:00:00 2001 From: Jheison Martinez Bolivar Date: Mon, 16 Nov 2026 15:48:34 -0500 Subject: [PATCH 2/3] fix(bench): point the scaffolded README at the current metrics invocation --- src/astro_denoise/bench/scaffold_templates.py | 16 ++++++++++------ tests/bench/snapshots/scaffold_wavelet.json | 2 +- tests/bench/test_scaffold.py | 8 ++++++++ 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/astro_denoise/bench/scaffold_templates.py b/src/astro_denoise/bench/scaffold_templates.py index cec2a89..b1e81c5 100644 --- a/src/astro_denoise/bench/scaffold_templates.py +++ b/src/astro_denoise/bench/scaffold_templates.py @@ -289,22 +289,26 @@ def test_cli_protocol(tmp_path, capsys): ## Correr en el benchmark +El bench y las métricas son el mismo paquete `astro-denoise`; prepara el +checkout core una vez y corre desde ahí: + ```bash -python -m astro_denoise.bench \\ +cd /ruta/a/astro-denoise +uv sync --all-extras +uv run python -m astro_denoise.bench \\ --algo @NAME@ \\ --manifest data/curated/manifest.json \\ - --python /ruta/a/@REPO@/.venv/bin/python \\ - --metrics-python /ruta/a/astro-denoise-metrics/.venv/bin/python + --python /ruta/a/@REPO@/.venv/bin/python ``` -El orquestador invoca `python -m @PKG@ --input ... --output ... [--config ...]` -y espera una línea JSON de status por stdout (ya implementada en `__main__.py`). +`--python` es el `.venv` de este método; las métricas usan el intérprete del +bench (`astro_denoise.metrics`, extra `metrics`), sin otro venv. ## Protocolo - Entry point `astro_denoise.methods` -> `@NAME@` (descubrimiento automático). - Contrato `DenoiseMethod` en `src/@PKG@/interface.py`. -- Las métricas del benchmark se explican con `astro-denoise-metrics --explain`. +- Métricas: `python -m astro_denoise.metrics --explain`. """ GITIGNORE = """\ diff --git a/tests/bench/snapshots/scaffold_wavelet.json b/tests/bench/snapshots/scaffold_wavelet.json index a3d1a8e..025485c 100644 --- a/tests/bench/snapshots/scaffold_wavelet.json +++ b/tests/bench/snapshots/scaffold_wavelet.json @@ -6,7 +6,7 @@ "src/astro_denoise_wavelet/__main__.py": "\"\"\"CLI: denoise a FITS image following the astro-denoise bench protocol.\n\nUsage:\n python -m astro_denoise_wavelet --input input.fits --output output.fits \\\n [--config config.json]\n\nstdout emits a single JSON status line consumed by the orchestrator:\n {\"algorithm\": \"wavelet\", \"version\": \"0.1.0\", \"status\": \"ok\"}\n\"\"\"\n\nfrom __future__ import annotations\n\nimport argparse\nimport json\nimport sys\nimport time\nfrom pathlib import Path\n\nimport numpy as np\nfrom astropy.io import fits\nfrom rich.console import Console\n\nfrom . import __version__\nfrom .denoiser import WaveletDenoiser\n\n\ndef load_config(path):\n if path is None:\n return {}\n return json.loads(Path(path).read_text())\n\n\ndef find_image_hdu(hdul):\n for index, hdu in enumerate(hdul):\n if hdu.data is not None and np.asarray(hdu.data).ndim == 2:\n return index\n raise ValueError(\"no 2-D image HDU found in input FITS\")\n\n\ndef main(argv=None):\n console = Console(stderr=True)\n parser = argparse.ArgumentParser(\n prog=\"python -m astro_denoise_wavelet\",\n description=\"wavelet denoising method for the astro-denoise benchmark\",\n )\n parser.add_argument(\"--input\", required=True, type=Path)\n parser.add_argument(\"--output\", required=True, type=Path)\n parser.add_argument(\"--config\", type=Path, default=None)\n args = parser.parse_args(argv)\n\n try:\n config = load_config(args.config)\n denoiser = WaveletDenoiser(**config)\n\n with fits.open(args.input) as hdul:\n image_hdu = find_image_hdu(hdul)\n image = np.asarray(hdul[image_hdu].data, dtype=np.float64)\n header = hdul[image_hdu].header.copy()\n\n start = time.perf_counter()\n denoised = denoiser.denoise(image)\n elapsed = time.perf_counter() - start\n\n header[\"HISTORY\"] = f\"astro-denoise-wavelet {__version__}\"\n args.output.parent.mkdir(parents=True, exist_ok=True)\n fits.PrimaryHDU(data=denoised.astype(np.float32), header=header).writeto(\n args.output, overwrite=True\n )\n console.print(f\"[green]ok[/green] {args.input.name} -> {args.output.name}\")\n print(\n json.dumps(\n {\n \"algorithm\": \"wavelet\",\n \"version\": __version__,\n \"status\": \"ok\",\n \"elapsed_s\": round(elapsed, 4),\n }\n )\n )\n return 0\n except Exception as exc:\n console.print(f\"[red]error:[/red] {exc}\")\n print(\n json.dumps(\n {\n \"algorithm\": \"wavelet\",\n \"version\": __version__,\n \"status\": \"error\",\n \"error\": str(exc),\n }\n )\n )\n return 1\n\n\nif __name__ == \"__main__\":\n sys.exit(main())\n", "tests/test_denoiser.py": "import numpy as np\nimport pytest\n\nfrom astro_denoise_wavelet import WaveletDenoiser\n\n\ndef test_preserves_shape():\n rng = np.random.default_rng(0)\n patch = rng.normal(100.0, 2.0, (64, 64))\n out = WaveletDenoiser().denoise(patch)\n assert out.shape == patch.shape\n\n\ndef test_rejects_non_2d():\n with pytest.raises(ValueError):\n WaveletDenoiser().denoise(np.zeros(10))\n", "tests/test_cli.py": "import json\n\nimport numpy as np\nfrom astropy.io import fits\n\nfrom astro_denoise_wavelet.__main__ import main\n\n\ndef test_cli_protocol(tmp_path, capsys):\n image = np.random.default_rng(0).normal(100.0, 2.0, (32, 32)).astype(np.float32)\n fits.PrimaryHDU(data=image).writeto(tmp_path / \"in.fits\")\n\n rc = main([\"--input\", str(tmp_path / \"in.fits\"), \"--output\", str(tmp_path / \"out.fits\")])\n assert rc == 0\n assert (tmp_path / \"out.fits\").exists()\n status = json.loads(capsys.readouterr().out.strip().splitlines()[-1])\n assert status[\"algorithm\"] == \"wavelet\"\n assert status[\"status\"] == \"ok\"\n", - "README.md": "# astro-denoise-wavelet\n\n> wavelet denoising method for the astro-denoise benchmark\n\nMódulo de método para la plataforma [astro-denoise](https://github.com/UniverLab).\nGenerado con `astro-denoise-bench --new-method wavelet` — el esqueleto ya corre\nend-to-end; solo falta tu algoritmo.\n\n## Implementar el método\n\nEdita `src/astro_denoise_wavelet/denoiser.py` y reemplaza el cuerpo de `denoise()`\n(recibe y devuelve un `ndarray` 2-D float). Los parámetros llegan por el\nJSON de `--config` al constructor.\n\n## Desarrollo\n\n```bash\nuv sync --all-extras # crea .venv e instala en editable\nuv run pytest # los tests del esqueleto ya pasan\nuv run ruff format . && uv run ruff check . && uv run mypy src/\n```\n\n## Correr en el benchmark\n\n```bash\npython -m astro_denoise.bench \\\n --algo wavelet \\\n --manifest data/curated/manifest.json \\\n --python /ruta/a/astro-denoise-wavelet/.venv/bin/python \\\n --metrics-python /ruta/a/astro-denoise-metrics/.venv/bin/python\n```\n\nEl orquestador invoca `python -m astro_denoise_wavelet --input ... --output ... [--config ...]`\ny espera una línea JSON de status por stdout (ya implementada en `__main__.py`).\n\n## Protocolo\n\n- Entry point `astro_denoise.methods` -> `wavelet` (descubrimiento automático).\n- Contrato `DenoiseMethod` en `src/astro_denoise_wavelet/interface.py`.\n- Las métricas del benchmark se explican con `astro-denoise-metrics --explain`.\n", + "README.md": "# astro-denoise-wavelet\n\n> wavelet denoising method for the astro-denoise benchmark\n\nMódulo de método para la plataforma [astro-denoise](https://github.com/UniverLab).\nGenerado con `astro-denoise-bench --new-method wavelet` — el esqueleto ya corre\nend-to-end; solo falta tu algoritmo.\n\n## Implementar el método\n\nEdita `src/astro_denoise_wavelet/denoiser.py` y reemplaza el cuerpo de `denoise()`\n(recibe y devuelve un `ndarray` 2-D float). Los parámetros llegan por el\nJSON de `--config` al constructor.\n\n## Desarrollo\n\n```bash\nuv sync --all-extras # crea .venv e instala en editable\nuv run pytest # los tests del esqueleto ya pasan\nuv run ruff format . && uv run ruff check . && uv run mypy src/\n```\n\n## Correr en el benchmark\n\nEl bench y las métricas son el mismo paquete `astro-denoise`; prepara el\ncheckout core una vez y corre desde ahí:\n\n```bash\ncd /ruta/a/astro-denoise\nuv sync --all-extras\nuv run python -m astro_denoise.bench \\\n --algo wavelet \\\n --manifest data/curated/manifest.json \\\n --python /ruta/a/astro-denoise-wavelet/.venv/bin/python\n```\n\n`--python` es el `.venv` de este método; las métricas usan el intérprete del\nbench (`astro_denoise.metrics`, extra `metrics`), sin otro venv.\n\n## Protocolo\n\n- Entry point `astro_denoise.methods` -> `wavelet` (descubrimiento automático).\n- Contrato `DenoiseMethod` en `src/astro_denoise_wavelet/interface.py`.\n- Métricas: `python -m astro_denoise.metrics --explain`.\n", ".gitignore": "__pycache__/\n*.py[cod]\n*.egg-info/\nbuild/\ndist/\n.venv/\nvenv/\n.pytest_cache/\n.mypy_cache/\n.coverage\n*.fits\n.env\n", ".github/workflows/ci.yml": "name: CI\n\non:\n pull_request:\n workflow_dispatch:\n\njobs:\n python-ci:\n uses: UniverLab/workflows/.github/workflows/python-ci.yml@main\n with:\n python-version: \"3.12\"\n", "LICENSE": " Apache License\n Version 2.0, January 2004\n http://www.apache.org/licenses/\n\n TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n 1. Definitions.\n\n \"License\" shall mean the terms and conditions for use, reproduction,\n and distribution as defined by Sections 1 through 9 of this document.\n\n \"Licensor\" shall mean the copyright owner or entity authorized by\n the copyright owner that is granting the License.\n\n \"Legal Entity\" shall mean the union of the acting entity and all\n other entities that control, are controlled by, or are under common\n control with that entity. For the purposes of this definition,\n \"control\" means (i) the power, direct or indirect, to cause the\n direction or management of such entity, whether by contract or\n otherwise, or (ii) ownership of fifty percent (50%) or more of the\n outstanding shares, or (iii) beneficial ownership of such entity.\n\n \"You\" (or \"Your\") shall mean an individual or Legal Entity\n exercising permissions granted by this License.\n\n \"Source\" form shall mean the preferred form for making modifications,\n including but not limited to software source code, documentation\n source, and configuration files.\n\n \"Object\" form shall mean any form resulting from mechanical\n transformation or translation of a Source form, including but\n not limited to compiled object code, generated documentation,\n and conversions to other media types.\n\n \"Work\" shall mean the work of authorship, whether in Source or\n Object form, made available under the License, as indicated by a\n copyright notice that is included in or attached to the work\n (an example is provided in the Appendix below).\n\n \"Derivative Works\" shall mean any work, whether in Source or Object\n form, that is based on (or derived from) the Work and for which the\n editorial revisions, annotations, elaborations, or other modifications\n represent, as a whole, an original work of authorship. For the purposes\n of this License, Derivative Works shall not include works that remain\n separable from, or merely link (or bind by name) to the interfaces of,\n the Work and Derivative Works thereof.\n\n \"Contribution\" shall mean any work of authorship, including\n the original version of the Work and any modifications or additions\n to that Work or Derivative Works thereof, that is intentionally\n submitted to Licensor for inclusion in the Work by the copyright owner\n or by an individual or Legal Entity authorized to submit on behalf of\n the copyright owner. For the purposes of this definition, \"submitted\"\n means any form of electronic, verbal, or written communication sent\n to the Licensor or its representatives, including but not limited to\n communication on electronic mailing lists, source code control systems,\n and issue tracking systems that are managed by, or on behalf of, the\n Licensor for the purpose of discussing and improving the Work, but\n excluding communication that is conspicuously marked or otherwise\n designated in writing by the copyright owner as \"Not a Contribution.\"\n\n \"Contributor\" shall mean Licensor and any individual or Legal Entity\n on behalf of whom a Contribution has been received by Licensor and\n subsequently incorporated within the Work.\n\n 2. Grant of Copyright License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n copyright license to reproduce, prepare Derivative Works of,\n publicly display, publicly perform, sublicense, and distribute the\n Work and such Derivative Works in Source or Object form.\n\n 3. Grant of Patent License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n (except as stated in this section) patent license to make, have made,\n use, offer to sell, sell, import, and otherwise transfer the Work,\n where such license applies only to those patent claims licensable\n by such Contributor that are necessarily infringed by their\n Contribution(s) alone or by combination of their Contribution(s)\n with the Work to which such Contribution(s) was submitted. If You\n institute patent litigation against any entity (including a\n cross-claim or counterclaim in a lawsuit) alleging that the Work\n or a Contribution incorporated within the Work constitutes direct\n or contributory patent infringement, then any patent licenses\n granted to You under this License for that Work shall terminate\n as of the date such litigation is filed.\n\n 4. Redistribution. You may reproduce and distribute copies of the\n Work or Derivative Works thereof in any medium, with or without\n modifications, and in Source or Object form, provided that You\n meet the following conditions:\n\n (a) You must give any other recipients of the Work or\n Derivative Works a copy of this License; and\n\n (b) You must cause any modified files to carry prominent notices\n stating that You changed the files; and\n\n (c) You must retain, in the Source form of any Derivative Works\n that You distribute, all copyright, patent, trademark, and\n attribution notices from the Source form of the Work,\n excluding those notices that do not pertain to any part of\n the Derivative Works; and\n\n (d) If the Work includes a \"NOTICE\" text file as part of its\n distribution, then any Derivative Works that You distribute must\n include a readable copy of the attribution notices contained\n within such NOTICE file, excluding those notices that do not\n pertain to any part of the Derivative Works, in at least one\n of the following places: within a NOTICE text file distributed\n as part of the Derivative Works; within the Source form or\n documentation, if provided along with the Derivative Works; or,\n within a display generated by the Derivative Works, if and\n wherever such third-party notices normally appear. The contents\n of the NOTICE file are for informational purposes only and\n do not modify the License. You may add Your own attribution\n notices within Derivative Works that You distribute, alongside\n or as an addendum to the NOTICE text from the Work, provided\n that such additional attribution notices cannot be construed\n as modifying the License.\n\n You may add Your own copyright statement to Your modifications and\n may provide additional or different license terms and conditions\n for use, reproduction, or distribution of Your modifications, or\n for any such Derivative Works as a whole, provided Your use,\n reproduction, and distribution of the Work otherwise complies with\n the conditions stated in this License.\n\n 5. Submission of Contributions. Unless You explicitly state otherwise,\n any Contribution intentionally submitted for inclusion in the Work\n by You to the Licensor shall be under the terms and conditions of\n this License, without any additional terms or conditions.\n Notwithstanding the above, nothing herein shall supersede or modify\n the terms of any separate license agreement you may have executed\n with Licensor regarding such Contributions.\n\n 6. Trademarks. This License does not grant permission to use the trade\n names, trademarks, service marks, or product names of the Licensor,\n except as required for reasonable and customary use in describing the\n origin of the Work and reproducing the content of the NOTICE file.\n\n 7. Disclaimer of Warranty. Unless required by applicable law or\n agreed to in writing, Licensor provides the Work (and each\n Contributor provides its Contributions) on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n implied, including, without limitation, any warranties or conditions\n of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n PARTICULAR PURPOSE. You are solely responsible for determining the\n appropriateness of using or redistributing the Work and assume any\n risks associated with Your exercise of permissions under this License.\n\n 8. Limitation of Liability. In no event and under no legal theory,\n whether in tort (including negligence), contract, or otherwise,\n unless required by applicable law (such as deliberate and grossly\n negligent acts) or agreed to in writing, shall any Contributor be\n liable to You for damages, including any direct, indirect, special,\n incidental, or consequential damages of any character arising as a\n result of this License or out of the use or inability to use the\n Work (including but not limited to damages for loss of goodwill,\n work stoppage, computer failure or malfunction, or any and all\n other commercial damages or losses), even if such Contributor\n has been advised of the possibility of such damages.\n\n 9. Accepting Warranty or Additional Liability. While redistributing\n the Work or Derivative Works thereof, You may choose to offer,\n and charge a fee for, acceptance of support, warranty, indemnity,\n or other liability obligations and/or rights consistent with this\n License. However, in accepting such obligations, You may act only\n on Your own behalf and on Your sole responsibility, not on behalf\n of any other Contributor, and only if You agree to indemnify,\n defend, and hold each Contributor harmless for any liability\n incurred by, or claims asserted against, such Contributor by reason\n of your accepting any such warranty or additional liability.\n\n END OF TERMS AND CONDITIONS\n\n APPENDIX: How to apply the Apache License to your work.\n\n To apply the Apache License to your work, attach the following\n boilerplate notice, with the fields enclosed by brackets \"[]\"\n replaced with your own identifying information. (Don't include\n the brackets!) The text should be enclosed in the appropriate\n comment syntax for the file format. We also recommend that a\n file or class name and description of purpose be included on the\n same \"printed page\" as the copyright notice for easier\n identification within third-party archives.\n\n Copyright [yyyy] [name of copyright owner]\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n\n" diff --git a/tests/bench/test_scaffold.py b/tests/bench/test_scaffold.py index ada07db..abf7320 100644 --- a/tests/bench/test_scaffold.py +++ b/tests/bench/test_scaffold.py @@ -54,6 +54,14 @@ def test_files_match_snapshot(self): assert list(rendered) == list(expected) assert rendered == expected + def test_readme_points_at_the_unified_core_metrics(self): + readme = _files(*WAVELET_ARGS)["README.md"] + assert "astro-denoise-metrics" not in readme + assert "--metrics-python" not in readme + assert "python -m astro_denoise.bench" in readme + assert "astro_denoise.metrics" in readme + assert "uv sync --all-extras" in readme + def test_no_unreplaced_placeholders(self): for path, content in _files(*WAVELET_ARGS).items(): for placeholder in PLACEHOLDERS: From ccf9adb461267624ececdf75361593dc44ad5f1a Mon Sep 17 00:00:00 2001 From: Jheison Martinez Bolivar Date: Mon, 16 Nov 2026 16:11:26 -0500 Subject: [PATCH 3/3] docs(bench): point documentation at the unified core metrics --- docs/bench.md | 30 +++++++++++++++--------------- docs/metrics.md | 27 ++++++++++++--------------- docs/passthrough.md | 16 ++++++++++------ 3 files changed, 37 insertions(+), 36 deletions(-) diff --git a/docs/bench.md b/docs/bench.md index e32e66b..b434fb0 100644 --- a/docs/bench.md +++ b/docs/bench.md @@ -19,9 +19,10 @@ computacionales desde fuera del proceso Python; el protocolo CLI es el mismo.) - **Ejecución** — lanza cada algoritmo como proceso aislado con el protocolo CLI estándar (cada módulo conserva su propio venv) y mide tiempo de pared y memoria pico RSS (GNU time). -- **Evaluación** — en modo curado invoca el CLI de `astro-denoise-metrics` - (su propio venv) contra el truth catalog Parquet real, por región y banda; - en modo clásico usa PSNR/SSIM/σ_sky con fallback numpy. El umbral de +- **Evaluación** — en modo curado invoca `python -m astro_denoise.metrics` + (mismo intérprete del bench, extra `metrics`) contra el truth catalog + Parquet real, por región y banda; en modo clásico usa PSNR/SSIM/σ_sky + con fallback numpy. El umbral de detección se ancla al RMS de fondo de la **región de entrada** (se pasa `--thresh-image` a metrics), de modo que todos los métodos se evalúan a la misma profundidad absoluta: un método que aplasta el fondo ya no "detecta @@ -61,7 +62,6 @@ python -m astro_denoise.bench \ --algo bm3d \ --manifest data/curated/manifest.json \ --python ../astro-denoise-bm3d/.venv/bin/python \ - --metrics-python ../astro-denoise-metrics/.venv/bin/python \ [--bands z,r] [--tracts 3829] [--mag-limit 26] [--previews] \ --output data/curated/report_bm3d.json @@ -74,14 +74,12 @@ python -m astro_denoise.bench --tui --manifest data/curated/manifest.json # 4) Figuras del paper a partir de reportes ya completados python -m astro_denoise.bench --figures --curated-out data/curated \ - --metrics-python ../astro-denoise-metrics/.venv/bin/python \ [--reports report_raw.json,report_bm3d_t3829.json,report_unet.json] \ [--figures-out data/curated/figures] [--refresh-sweep] \ [--skip-sweep] [--skip-d8] -# Explicación de cada métrica (delega en astro-denoise-metrics --explain) -python -m astro_denoise.bench --explain-metrics \ - --metrics-python ../astro-denoise-metrics/.venv/bin/python +# Explicación de cada métrica (delega en python -m astro_denoise.metrics --explain) +python -m astro_denoise.bench --explain-metrics # Crear un nuevo método con cero fricción (para otros investigadores) python -m astro_denoise.bench --new-method wavelet [--methods-dir /ruta] @@ -100,8 +98,10 @@ python -m astro_denoise.bench --new-method wavelet cd astro-denoise-wavelet uv sync --all-extras && uv run pytest # verde desde el minuto cero # implementar denoise() en src/astro_denoise_wavelet/denoiser.py -python -m astro_denoise.bench --algo wavelet --manifest data/curated/manifest.json \ - --python .venv/bin/python --metrics-python /.venv/bin/python +cd .. +python -m astro_denoise.bench --algo wavelet \ + --manifest data/curated/manifest.json \ + --python astro-denoise-wavelet/.venv/bin/python ``` El esqueleto sin modificar es un pass-through: corre el benchmark tal cual y @@ -120,9 +120,10 @@ python -m astro_denoise.bench \ [--python ../astro-denoise-bm3d/.venv/bin/python] ``` -- `--python` / `--metrics-python` apuntan al intérprete del venv propio de - cada módulo; por defecto usan el intérprete actual. Así cada módulo mantiene - sus dependencias aisladas. +- `--python` apunta al intérprete del venv propio del módulo; por defecto usa + el intérprete actual. Las métricas corren en el mismo intérprete del bench + (`astro_denoise.metrics`, extra `metrics`). Así cada módulo mantiene sus + dependencias aisladas. - `--config` se reenvía tal cual al módulo del método. - En modo curado, si no se pasa `--config` y existe `_config.json` junto al manifest (p. ej. `bm3d_config.json` con @@ -264,8 +265,7 @@ metadatos del método, métricas) y un bloque `summary`: umbrales del barrido, banda de D8). `--skip-sweep` y `--skip-d8` permiten quedarse solo con las figuras puras -(sin relanzar métricas). `--metrics-python` es el mismo intérprete que en -el modo `--manifest`. +(sin relanzar métricas). ## Tests diff --git a/docs/metrics.md b/docs/metrics.md index 0ce87fe..a84980f 100644 --- a/docs/metrics.md +++ b/docs/metrics.md @@ -1,6 +1,6 @@ -# astro-denoise-metrics +# Módulo de métricas astro-denoise -> Módulo de métricas downstream científico para el benchmark astro-denoise. +> Módulo de métricas científico para el benchmark astro-denoise. Implementa la capa de evaluación de la plataforma astro-denoise: mide cómo un método de denoising afecta la **recuperación de fuentes** @@ -112,7 +112,7 @@ python -m astro_denoise.metrics \ - Con truth DC2, `photometric_accuracy` compara flujo instrumental (ADU) contra nJy: solo la dispersión relativa es interpretable, no el bias. - `results.json` contiene todas las métricas; stdout emite una línea JSON de - estado (`{"module": "astro-denoise-metrics", "status": "ok", ...}`) para que + estado (`{"module": "astro_denoise.metrics", "status": "ok", ...}`) para que orquestadores como `astro-denoise-bench` parseen el resultado. - El resumen legible se imprime por stderr vía `rich`. @@ -120,7 +120,7 @@ python -m astro_denoise.metrics \ ```json { - "module": "astro-denoise-metrics", + "module": "astro_denoise.metrics", "version": "0.4.0", "n_detected": 142, "n_truth": 150, @@ -157,17 +157,14 @@ workflow reusable [`UniverLab/workflows`](https://github.com/UniverLab/workflows ## Estructura del proyecto ``` -astro-denoise-metrics/ -├── pyproject.toml -├── src/ -│ └── astro_denoise/metrics/ -│ ├── __init__.py -│ ├── __main__.py # CLI entry point -│ ├── detect.py -│ └── metrics.py -├── tests/ -└── README.md +src/astro_denoise/metrics/ +├── __init__.py +├── __main__.py # CLI entry point +├── detect.py +├── explain.py +├── metrics.py +└── truth.py ``` --- -Este submódulo forma parte de la plataforma `astro-denoise`. +Este módulo forma parte de la plataforma `astro-denoise`. diff --git a/docs/passthrough.md b/docs/passthrough.md index c3352fb..2950baa 100644 --- a/docs/passthrough.md +++ b/docs/passthrough.md @@ -22,19 +22,23 @@ uv run ruff format . && uv run ruff check . && uv run mypy src/ ## Correr en el benchmark +El bench y las métricas son el mismo paquete `astro-denoise`; prepara el +checkout core una vez y corre desde ahí: + ```bash -python -m astro_denoise.bench \ +cd /ruta/a/astro-denoise +uv sync --all-extras +uv run python -m astro_denoise.bench \ --algo passthrough \ --manifest data/curated/manifest.json \ - --python /ruta/a/astro-denoise-passthrough/.venv/bin/python \ - --metrics-python /ruta/a/astro-denoise-metrics/.venv/bin/python + --python /ruta/a/astro-denoise-passthrough/.venv/bin/python ``` -El orquestador invoca `python -m astro_denoise_passthrough --input ... --output ... [--config ...]` -y espera una línea JSON de status por stdout (ya implementada en `__main__.py`). +`--python` es el `.venv` de este método; las métricas usan el intérprete del +bench (`astro_denoise.metrics`, extra `metrics`), sin otro venv. ## Protocolo - Entry point `astro_denoise.methods` -> `passthrough` (descubrimiento automático). - Contrato `DenoiseMethod` en `src/astro_denoise_passthrough/interface.py`. -- Las métricas del benchmark se explican con `astro-denoise-metrics --explain`. +- Métricas: `python -m astro_denoise.metrics --explain`.