microlens-submit 0.12.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Amber Malpas
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,2 @@
1
+ include microlens_submit/assets/rges-pit_logo.png
2
+ include microlens_submit/assets/github-desktop_logo.png
@@ -0,0 +1,159 @@
1
+ Metadata-Version: 2.4
2
+ Name: microlens-submit
3
+ Version: 0.12.1
4
+ Summary: A stateful submission toolkit for the Microlensing Data Challenge.
5
+ Author-email: Amber Malpas <malpas.1@osu.edu>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/AmberLee2427/microlens-submit
8
+ Project-URL: Repository, https://github.com/AmberLee2427/microlens-submit
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Operating System :: OS Independent
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: Topic :: Scientific/Engineering :: Astronomy
14
+ Requires-Python: >=3.8
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE
17
+ Requires-Dist: typer[all]>=0.9.0
18
+ Requires-Dist: pydantic>=2.0
19
+ Requires-Dist: rich>=13.0
20
+ Requires-Dist: PyYAML>=6.0
21
+ Requires-Dist: markdown>=3.0
22
+ Provides-Extra: dev
23
+ Requires-Dist: pytest; extra == "dev"
24
+ Requires-Dist: pytest-cov; extra == "dev"
25
+ Requires-Dist: build; extra == "dev"
26
+ Requires-Dist: twine; extra == "dev"
27
+ Requires-Dist: pre-commit; extra == "dev"
28
+ Requires-Dist: black; extra == "dev"
29
+ Requires-Dist: isort; extra == "dev"
30
+ Requires-Dist: sphinx; extra == "dev"
31
+ Requires-Dist: sphinx_rtd_theme; extra == "dev"
32
+ Dynamic: license-file
33
+
34
+ <p align="center">
35
+ <a href="https://github.com/AmberLee2427/microlens-submit">
36
+ <img src="./microlens_submit/assets/rges-pit_logo.png" alt="logo" width="300"/>
37
+ </a>
38
+ </p>
39
+
40
+ <h1 align="center">microlens-submit</h1>
41
+
42
+ *A stateful submission toolkit for the RGES-PIT Microlensing Data Challenge.*
43
+
44
+ [![PyPI - v0.12.1](https://img.shields.io/pypi/v/microlens-submit.svg)](https://pypi.org/project/microlens-submit/)
45
+ [![CI](https://github.com/AmberLee2427/microlens-submit/actions/workflows/ci.yml/badge.svg)](https://github.com/AmberLee2427/microlens-submit/actions/workflows/ci.yml)
46
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
47
+
48
+ <br>
49
+
50
+ `microlens-submit` provides a robust, version-controlled workflow for managing, validating, and packaging your challenge submission over a long period. It supports both a programmatic Python API and a full-featured Command Line Interface (CLI) for language-agnostic use.
51
+
52
+ Full documentation is hosted on [Read the Docs](https://microlens-submit.readthedocs.io/en/latest/). A comprehensive tutorial notebook is available at `docs/Submission_Tool_Tutorial.ipynb`. Challenge participants who prefer not to use this tool can consult [SUBMISSION_MANUAL.md](SUBMISSION_MANUAL.md) for the manual submission format.
53
+
54
+ ## Key Features
55
+
56
+ * **Persistent Projects:** Treat your submission as a local project that you can load, edit, and save over weeks or months.
57
+ * **Python API & CLI:** Use the tool directly in your Python analysis scripts or via the command line.
58
+ * **Solution Management:** Easily add, update, and deactivate degenerate solutions for any event without losing your work history.
59
+ * **Active Solution Control:** Quickly list just the active solutions or mark
60
+ all solutions inactive in one call.
61
+ * **Automatic Validation:** Aggressive data validation powered by Pydantic ensures your submission is always compliant with the challenge rules.
62
+ * **Parameter Validation:** Centralized validation logic checks parameter completeness, types, and physical consistency based on model type and higher-order effects.
63
+ * **Rich Documentation:** Notes field supports Markdown formatting for creating detailed, structured documentation and submission dossiers.
64
+ * **Environment Capture:** Automatically records your Python dependencies for each specific model fit, ensuring reproducibility.
65
+ * **Optional Posterior Storage:** Record the path to posterior samples for any solution.
66
+ * **Simple Export:** Packages all your active solutions into a clean, standardized `.zip` archive for final submission.
67
+
68
+ ## Installation
69
+
70
+ This package is pre-release. It is currently available on TestPyPI:
71
+
72
+ ```bash
73
+ pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple microlens-submit==0.12.0-dev
74
+ ```
75
+
76
+ The package will be available on PyPI:
77
+
78
+ ```bash
79
+ pip install microlens-submit
80
+ ```
81
+
82
+ ### Quickstart Using the Command Line Interface (CLI)
83
+
84
+ The CLI is the recommended way to interact with your submission project.
85
+
86
+ You can pass ``--no-color`` to any command if your terminal does not support ANSI colors.
87
+
88
+ 1. Initialize your project: `microlens-submit init --team-name "Planet Pounders" --tier "advanced"`
89
+ 2. Add a new solution to an event:
90
+ ```bash
91
+ microlens-submit add-solution ogle-2025-blg-0042 1S2L \
92
+ --param t0=555.5 \
93
+ --param u0=0.1 \
94
+ --param tE=25.0 \
95
+ --notes "This is a great fit!"
96
+ ```
97
+ Model types must be one of `1S1L`, `1S2L`, `2S1L`, `2S2L`, `1S3L`, `2S3L`, or `other`.
98
+ This will create a new solution and print its unique `solution_id`.
99
+ You can run the same command with `--dry-run` first to verify the
100
+ parsed input without saving anything.
101
+ 3. Deactivate a solution that didn't work out: `microlens-submit deactivate <solution_id>`
102
+ 4. List all solutions for an event: `microlens-submit list-solutions ogle-2025-blg-0042`
103
+ 5. Validate solutions and check for issues: `microlens-submit validate-solution <solution_id>`
104
+ 6. Export your final submission: `microlens-submit export final_submission.zip`
105
+
106
+ **Note:** When you add a solution, it's automatically validated and any warnings are displayed. Use `--dry-run` to check validation without saving.
107
+
108
+ ### Using the Python API
109
+
110
+ For those who want to integrate the tool directly into their Python analysis pipeline.
111
+
112
+ ```python
113
+ import microlens_submit
114
+
115
+ # Load or create the project
116
+ sub = microlens_submit.load(project_path="./my_challenge_submission")
117
+ sub.team_name = "Planet Pounders"
118
+ sub.tier = "advanced"
119
+
120
+ # Get an event and add a solution
121
+ evt = sub.get_event("ogle-2025-blg-0042")
122
+ params = {"t0": 555.5, "u0": 0.1, "tE": 25.0}
123
+ sol = evt.add_solution(model_type="1S2L", parameters=params)
124
+
125
+ # Record compute info for this specific run
126
+ sol.set_compute_info(cpu_hours=15.5)
127
+ sol.notes = "This fit was generated from our Python script."
128
+
129
+ # Save progress to disk
130
+ sub.save()
131
+
132
+ # When ready, export the final package
133
+ sub.export("final_submission.zip")
134
+ ```
135
+
136
+ ## Development
137
+
138
+ The full development plan can be found in agents.md. Contributions are welcome!
139
+
140
+ To build and test this project, the development environment needs the following Python libraries. You can provide these to Codex or set up a `requirements-dev.txt` file.
141
+
142
+ ### Core Dependencies:
143
+ * **`typer[all]`**: For building the powerful command-line interface. The `[all]` extra ensures shell completion support is included.
144
+ * **`pydantic`**: For aggressive data validation and settings management.
145
+
146
+ ### Testing Dependencies:
147
+ * **`pytest`**: The standard framework for testing Python code.
148
+ * **`pytest-cov`**: To measure test coverage.
149
+
150
+ ### Packaging & Distribution Dependencies:
151
+ * **`build`**: For building the package from the `pyproject.toml` file.
152
+ * **`twine`**: For uploading the final package to PyPI.
153
+
154
+ ## Citation
155
+
156
+ If you use **microlens-submit** in your research, please cite the project using
157
+ the metadata provided in the `CITATION.cff` file. Most reference managers can
158
+ import this file directly.
159
+
@@ -0,0 +1,126 @@
1
+ <p align="center">
2
+ <a href="https://github.com/AmberLee2427/microlens-submit">
3
+ <img src="./microlens_submit/assets/rges-pit_logo.png" alt="logo" width="300"/>
4
+ </a>
5
+ </p>
6
+
7
+ <h1 align="center">microlens-submit</h1>
8
+
9
+ *A stateful submission toolkit for the RGES-PIT Microlensing Data Challenge.*
10
+
11
+ [![PyPI - v0.12.1](https://img.shields.io/pypi/v/microlens-submit.svg)](https://pypi.org/project/microlens-submit/)
12
+ [![CI](https://github.com/AmberLee2427/microlens-submit/actions/workflows/ci.yml/badge.svg)](https://github.com/AmberLee2427/microlens-submit/actions/workflows/ci.yml)
13
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
14
+
15
+ <br>
16
+
17
+ `microlens-submit` provides a robust, version-controlled workflow for managing, validating, and packaging your challenge submission over a long period. It supports both a programmatic Python API and a full-featured Command Line Interface (CLI) for language-agnostic use.
18
+
19
+ Full documentation is hosted on [Read the Docs](https://microlens-submit.readthedocs.io/en/latest/). A comprehensive tutorial notebook is available at `docs/Submission_Tool_Tutorial.ipynb`. Challenge participants who prefer not to use this tool can consult [SUBMISSION_MANUAL.md](SUBMISSION_MANUAL.md) for the manual submission format.
20
+
21
+ ## Key Features
22
+
23
+ * **Persistent Projects:** Treat your submission as a local project that you can load, edit, and save over weeks or months.
24
+ * **Python API & CLI:** Use the tool directly in your Python analysis scripts or via the command line.
25
+ * **Solution Management:** Easily add, update, and deactivate degenerate solutions for any event without losing your work history.
26
+ * **Active Solution Control:** Quickly list just the active solutions or mark
27
+ all solutions inactive in one call.
28
+ * **Automatic Validation:** Aggressive data validation powered by Pydantic ensures your submission is always compliant with the challenge rules.
29
+ * **Parameter Validation:** Centralized validation logic checks parameter completeness, types, and physical consistency based on model type and higher-order effects.
30
+ * **Rich Documentation:** Notes field supports Markdown formatting for creating detailed, structured documentation and submission dossiers.
31
+ * **Environment Capture:** Automatically records your Python dependencies for each specific model fit, ensuring reproducibility.
32
+ * **Optional Posterior Storage:** Record the path to posterior samples for any solution.
33
+ * **Simple Export:** Packages all your active solutions into a clean, standardized `.zip` archive for final submission.
34
+
35
+ ## Installation
36
+
37
+ This package is pre-release. It is currently available on TestPyPI:
38
+
39
+ ```bash
40
+ pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple microlens-submit==0.12.0-dev
41
+ ```
42
+
43
+ The package will be available on PyPI:
44
+
45
+ ```bash
46
+ pip install microlens-submit
47
+ ```
48
+
49
+ ### Quickstart Using the Command Line Interface (CLI)
50
+
51
+ The CLI is the recommended way to interact with your submission project.
52
+
53
+ You can pass ``--no-color`` to any command if your terminal does not support ANSI colors.
54
+
55
+ 1. Initialize your project: `microlens-submit init --team-name "Planet Pounders" --tier "advanced"`
56
+ 2. Add a new solution to an event:
57
+ ```bash
58
+ microlens-submit add-solution ogle-2025-blg-0042 1S2L \
59
+ --param t0=555.5 \
60
+ --param u0=0.1 \
61
+ --param tE=25.0 \
62
+ --notes "This is a great fit!"
63
+ ```
64
+ Model types must be one of `1S1L`, `1S2L`, `2S1L`, `2S2L`, `1S3L`, `2S3L`, or `other`.
65
+ This will create a new solution and print its unique `solution_id`.
66
+ You can run the same command with `--dry-run` first to verify the
67
+ parsed input without saving anything.
68
+ 3. Deactivate a solution that didn't work out: `microlens-submit deactivate <solution_id>`
69
+ 4. List all solutions for an event: `microlens-submit list-solutions ogle-2025-blg-0042`
70
+ 5. Validate solutions and check for issues: `microlens-submit validate-solution <solution_id>`
71
+ 6. Export your final submission: `microlens-submit export final_submission.zip`
72
+
73
+ **Note:** When you add a solution, it's automatically validated and any warnings are displayed. Use `--dry-run` to check validation without saving.
74
+
75
+ ### Using the Python API
76
+
77
+ For those who want to integrate the tool directly into their Python analysis pipeline.
78
+
79
+ ```python
80
+ import microlens_submit
81
+
82
+ # Load or create the project
83
+ sub = microlens_submit.load(project_path="./my_challenge_submission")
84
+ sub.team_name = "Planet Pounders"
85
+ sub.tier = "advanced"
86
+
87
+ # Get an event and add a solution
88
+ evt = sub.get_event("ogle-2025-blg-0042")
89
+ params = {"t0": 555.5, "u0": 0.1, "tE": 25.0}
90
+ sol = evt.add_solution(model_type="1S2L", parameters=params)
91
+
92
+ # Record compute info for this specific run
93
+ sol.set_compute_info(cpu_hours=15.5)
94
+ sol.notes = "This fit was generated from our Python script."
95
+
96
+ # Save progress to disk
97
+ sub.save()
98
+
99
+ # When ready, export the final package
100
+ sub.export("final_submission.zip")
101
+ ```
102
+
103
+ ## Development
104
+
105
+ The full development plan can be found in agents.md. Contributions are welcome!
106
+
107
+ To build and test this project, the development environment needs the following Python libraries. You can provide these to Codex or set up a `requirements-dev.txt` file.
108
+
109
+ ### Core Dependencies:
110
+ * **`typer[all]`**: For building the powerful command-line interface. The `[all]` extra ensures shell completion support is included.
111
+ * **`pydantic`**: For aggressive data validation and settings management.
112
+
113
+ ### Testing Dependencies:
114
+ * **`pytest`**: The standard framework for testing Python code.
115
+ * **`pytest-cov`**: To measure test coverage.
116
+
117
+ ### Packaging & Distribution Dependencies:
118
+ * **`build`**: For building the package from the `pyproject.toml` file.
119
+ * **`twine`**: For uploading the final package to PyPI.
120
+
121
+ ## Citation
122
+
123
+ If you use **microlens-submit** in your research, please cite the project using
124
+ the metadata provided in the `CITATION.cff` file. Most reference managers can
125
+ import this file directly.
126
+
@@ -0,0 +1,163 @@
1
+ """microlens-submit: A stateful submission toolkit for the Microlensing Data Challenge.
2
+
3
+ This package provides a comprehensive toolkit for managing and submitting microlensing
4
+ data challenge solutions. It offers both programmatic API access and command-line
5
+ interface for creating, validating, and exporting microlensing submissions.
6
+
7
+ **Core Features:**
8
+ - Project initialization and management
9
+ - Solution creation and parameter validation
10
+ - Submission validation and completeness checking
11
+ - HTML dossier generation with rich visualizations
12
+ - Export functionality for challenge submission
13
+ - Command-line interface for all operations
14
+
15
+ **Main Components:**
16
+ - Submission: Top-level container for all submission data
17
+ - Event: Container for microlensing events and their solutions
18
+ - Solution: Individual microlensing solutions with parameters and metadata
19
+ - Validation: Comprehensive parameter and submission validation
20
+ - Dossier: HTML report generation with Tailwind CSS styling
21
+
22
+ **Quick Start:**
23
+ >>> from microlens_submit import load, Submission
24
+ >>>
25
+ >>> # Load an existing project
26
+ >>> submission = load("./my_project")
27
+ >>>
28
+ >>> # Or create a new submission
29
+ >>> submission = Submission()
30
+ >>> submission.team_name = "Team Alpha"
31
+ >>> submission.tier = "advanced"
32
+ >>> submission.save("./my_project")
33
+ >>>
34
+ >>> # Add a solution to an event
35
+ >>> event = submission.get_event("EVENT001")
36
+ >>> solution = event.add_solution(
37
+ ... model_type="1S1L",
38
+ ... parameters={"t0": 2459123.5, "u0": 0.1, "tE": 20.0}
39
+ ... )
40
+ >>> solution.log_likelihood = -1234.56
41
+ >>> solution.cpu_hours = 2.5
42
+ >>> submission.save()
43
+
44
+ **Command Line Usage:**
45
+ # Initialize a new project
46
+ microlens-submit init --team-name "Team Alpha" --tier "advanced" ./project
47
+
48
+ # Add a solution
49
+ microlens-submit add-solution EVENT001 1S1L ./project \
50
+ --param t0=2459123.5 --param u0=0.1 --param tE=20.0 \
51
+ --log-likelihood -1234.56 --cpu-hours 2.5
52
+
53
+ # Validate and generate dossier
54
+ microlens-submit validate-submission ./project
55
+ microlens-submit generate-dossier ./project
56
+
57
+ # Export for submission
58
+ microlens-submit export submission.zip ./project
59
+
60
+ **Supported Model Types:**
61
+ - 1S1L: Point Source, Single Point Lens (standard microlensing)
62
+ - 1S2L: Point Source, Binary Point Lens
63
+ - 2S1L: Binary Source, Single Point Lens
64
+ - 2S2L: Binary Source, Binary Point Lens
65
+ - 1S3L: Point Source, Triple Point Lens
66
+ - 2S3L: Binary Source, Triple Point Lens
67
+
68
+ **Higher-Order Effects:**
69
+ - parallax: Microlens parallax effect
70
+ - finite-source: Finite source size effect
71
+ - lens-orbital-motion: Orbital motion of lens components
72
+ - xallarap: Source orbital motion
73
+ - gaussian-process: Gaussian process noise modeling
74
+ - stellar-rotation: Stellar rotation effects
75
+ - fitted-limb-darkening: Fitted limb darkening coefficients
76
+
77
+ Example:
78
+ >>> from microlens_submit import load, Submission
79
+ >>> from pathlib import Path
80
+ >>>
81
+ >>> # Create a new submission project
82
+ >>> submission = Submission()
83
+ >>> submission.team_name = "Team Alpha"
84
+ >>> submission.tier = "advanced"
85
+ >>> submission.repo_url = "https://github.com/team-alpha/microlens-analysis"
86
+ >>>
87
+ >>> # Add hardware information
88
+ >>> submission.hardware_info = {
89
+ ... "cpu_details": "Intel Xeon E5-2680 v4",
90
+ ... "memory_gb": 64,
91
+ ... "nexus_image": "roman-science-platform:latest"
92
+ ... }
93
+ >>>
94
+ >>> # Create an event and add solutions
95
+ >>> event = submission.get_event("EVENT001")
96
+ >>>
97
+ >>> # Simple 1S1L solution
98
+ >>> solution1 = event.add_solution(
99
+ ... model_type="1S1L",
100
+ ... parameters={
101
+ ... "t0": 2459123.5,
102
+ ... "u0": 0.1,
103
+ ... "tE": 20.0,
104
+ ... "F0_S": 1000.0,
105
+ ... "F0_B": 500.0
106
+ ... }
107
+ ... )
108
+ >>> solution1.log_likelihood = -1234.56
109
+ >>> solution1.n_data_points = 1250
110
+ >>> solution1.cpu_hours = 2.5
111
+ >>> solution1.relative_probability = 0.8
112
+ >>> solution1.notes = "# Simple Point Lens Fit\n\nThis is a basic 1S1L solution."
113
+ >>>
114
+ >>> # Binary lens solution with parallax
115
+ >>> solution2 = event.add_solution(
116
+ ... model_type="1S2L",
117
+ ... parameters={
118
+ ... "t0": 2459123.5,
119
+ ... "u0": 0.08,
120
+ ... "tE": 22.1,
121
+ ... "s": 1.15,
122
+ ... "q": 0.001,
123
+ ... "alpha": 45.2,
124
+ ... "piEN": 0.1,
125
+ ... "piEE": 0.05,
126
+ ... "F0_S": 1000.0,
127
+ ... "F0_B": 500.0
128
+ ... }
129
+ ... )
130
+ >>> solution2.higher_order_effects = ["parallax"]
131
+ >>> solution2.t_ref = 2459123.0
132
+ >>> solution2.log_likelihood = -1189.34
133
+ >>> solution2.cpu_hours = 15.2
134
+ >>> solution2.relative_probability = 0.2
135
+ >>>
136
+ >>> # Save the submission
137
+ >>> submission.save("./my_submission")
138
+ >>>
139
+ >>> # Validate the submission
140
+ >>> warnings = submission.validate()
141
+ >>> if warnings:
142
+ ... print("Validation warnings:", warnings)
143
+ >>> else:
144
+ ... print("Submission is valid!")
145
+ >>>
146
+ >>> # Generate dossier
147
+ >>> from microlens_submit.dossier import generate_dashboard_html
148
+ >>> generate_dashboard_html(submission, Path("./my_submission/dossier"))
149
+
150
+ Note:
151
+ This package is designed for the Microlensing Data Challenge and provides
152
+ comprehensive tools for managing submission data. All data is stored in
153
+ JSON format for portability and human readability. The package includes
154
+ extensive validation to ensure submission completeness and correctness.
155
+ The HTML dossier generation creates professional, printable reports with
156
+ Tailwind CSS styling and syntax-highlighted markdown notes.
157
+ """
158
+
159
+ __version__ = "0.12.1"
160
+
161
+ from .api import Event, Solution, Submission, load
162
+
163
+ __all__ = ["Event", "Solution", "Submission", "load"]