-
Notifications
You must be signed in to change notification settings - Fork 0
feat(factorio-cycle-calculator): Improve Codegen Workflow Via Mise Task #122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -0,0 +1,35 @@ | ||||
| [tasks."schema:generate"] | ||||
| description = "Generate Python models from the JSON schema." | ||||
| run = [ | ||||
| """ | ||||
| uv run \ | ||||
| --project src/private/app/factorio-cycle-calculator \ | ||||
| --package factorio-cycle-calculator \ | ||||
| --group dev \ | ||||
| datamodel-codegen \ | ||||
| --url https://raw.githubusercontent.com/jacquev6/factorio-data-raw-json-schema/refs/heads/main/factorio-data-raw-json-schema.full.json \ | ||||
| --output src/factorio_cycle_calculator/generated/data_raw_models.py \ | ||||
| --input-file-type jsonschema \ | ||||
| --output-model-type dataclasses.dataclass \ | ||||
| --target-python-version 3.12 \ | ||||
| --formatters ruff-format""", | ||||
| """ | ||||
| uv run \ | ||||
| --project src/private/app/factorio-cycle-calculator \ | ||||
| --package factorio-cycle-calculator \ | ||||
| --group dev \ | ||||
| ruff check \ | ||||
| --fix \ | ||||
| --exit-zero \ | ||||
|
||||
| --exit-zero \ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| """Run the Streamlit app via the package entry point.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import sys | ||
| from importlib import import_module | ||
| from pathlib import Path | ||
|
|
||
| from streamlit.web.cli import main as streamlit_main | ||
|
|
||
|
|
||
| def main(argv: list[str] | None = None) -> None: | ||
| """Launch the Streamlit application.""" | ||
| module = import_module("factorio_cycle_calculator.app") | ||
| app_path = Path(module.__file__).resolve() | ||
| new_argv = ["streamlit", "run", str(app_path)] | ||
| if argv is not None: | ||
| new_argv.extend(argv) | ||
|
Comment on lines
+17
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The console script entry point invokes Useful? React with 👍 / 👎. |
||
|
|
||
|
Comment on lines
+12
to
+19
|
||
| old_argv = sys.argv | ||
| try: | ||
| sys.argv = new_argv | ||
| streamlit_main() | ||
| finally: | ||
| sys.argv = old_argv | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running the documented command
mise //src/private/app/factorio-cycle-calculator:schema:generatefrom the repo root executes this task with no taskdir, but the generated-file path here is relative (src/factorio_cycle_calculator/...) and therefore points outside the package directory; this makes codegen/ruff operate on the wrong location (or fail if the path does not exist), so the intendedsrc/private/app/factorio-cycle-calculator/src/factorio_cycle_calculator/generated/data_raw_models.pyis not reliably updated.Useful? React with 👍 / 👎.