-
Notifications
You must be signed in to change notification settings - Fork 1
Update cookiecutter template #2
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
fe8b979
better decomposition of starting apps
irod973 53d841d
parametrize component selection, docker-compose, and coverage
irod973 40cf475
improve parametrizaation; docker fixes
irod973 4ac34a1
update README
irod973 324d1b4
update tests
irod973 a01fa7d
update tests
irod973 1c6a719
update tests
irod973 8d190c1
update tests
irod973 a461695
update tests
irod973 5645f76
update tests
irod973 61543b8
Update {{cookiecutter.repository}}/pyproject.toml
irod973 cfd56a3
Update {{cookiecutter.repository}}/src/metaflow_app/spin_prototype.py
irod973 6f11fd9
Update hooks/post_gen_project.py
irod973 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| import shutil | ||
| import os | ||
|
|
||
| def is_false(val): | ||
| return str(val).strip().lower() in ("false", "n", "no", "0") | ||
|
|
||
| # Remove FastAPI component if not included | ||
| if is_false('{{cookiecutter.include_fastapi}}'): | ||
| shutil.rmtree('src/fastapi_app', ignore_errors=True) | ||
|
|
||
| # Remove Metaflow component if not included | ||
| if is_false('{{cookiecutter.include_metaflow}}'): | ||
| shutil.rmtree('src/metaflow_app', ignore_errors=True) | ||
|
|
||
| # Remove Python package component if not included | ||
| if is_false('{{cookiecutter.include_package}}'): | ||
| shutil.rmtree("src/{{cookiecutter.package}}", ignore_errors=True) | ||
| # Remove publish workflow if present | ||
| workflow_path = os.path.join('.github', 'workflows', 'publish.yml') | ||
| if os.path.exists(workflow_path): | ||
| os.remove(workflow_path) | ||
| # Remove publish badge from README if present | ||
| readme_path = os.path.join('.', 'README.md') | ||
| if os.path.exists(readme_path): | ||
| with open(readme_path, 'r') as f: | ||
| lines = f.readlines() | ||
| with open(readme_path, 'w') as f: | ||
| for line in lines: | ||
| if 'publish.yml' not in line: | ||
| f.write(line) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,25 @@ | ||
| # https://docs.docker.com/engine/reference/builder/ | ||
| # https://docs.astral.sh/uv/guides/integration/docker/#intermediate-layers | ||
|
|
||
| FROM ghcr.io/astral-sh/uv:python{{cookiecutter.python_version}}-bookworm | ||
| COPY dist/*.whl . | ||
| RUN uv pip install --system *.whl | ||
| CMD ["{{cookiecutter.repository}}", "--help"] | ||
| # Install uv | ||
| FROM python:{{cookiecutter.python_version}}-slim | ||
| COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/ | ||
|
|
||
| COPY ./src /app | ||
| ENV PYTHONPATH="${PYTHONPATH}:/app" | ||
| # Change the working directory to the `app` directory | ||
| WORKDIR /app | ||
|
|
||
| CMD ["{{cookiecutter.repository}}", "--help"] | ||
| # Example command | ||
| # CMD ["uvicorn", "example_app.main:app", "--host", "0.0.0.0"] | ||
| # Install dependencies | ||
| RUN --mount=type=cache,target=/root/.cache/uv \ | ||
| --mount=type=bind,source=uv.lock,target=uv.lock \ | ||
| --mount=type=bind,source=pyproject.toml,target=pyproject.toml \ | ||
| uv sync --locked --no-install-project | ||
|
|
||
| # Copy the project into the image | ||
| ADD . /app | ||
|
|
||
| # Sync the project | ||
| RUN --mount=type=cache,target=/root/.cache/uv \ | ||
| uv sync --locked | ||
|
|
||
| # Default command (overridden by docker-compose) | ||
| CMD ["python", "--version"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,26 @@ | ||
| # https://docs.docker.com/compose/compose-file/ | ||
|
|
||
| services: | ||
| fastapi_app: # Name your service | ||
| build: . # Build the image from the current directory (.) | ||
| {% if cookiecutter.include_fastapi %} | ||
| fastapi_app: | ||
| build: . | ||
| command: ["uvicorn", "example_app.main:app", "--host", "0.0.0.0", "--reload"] | ||
| ports: | ||
| - "8000:8000" # Map container port 8000 to host port 8000 | ||
| - "8000:8000" | ||
| volumes: | ||
| - ./src:/app/src # Mount your source code directory | ||
| - ./src:/app/src | ||
| {% endif %} | ||
| {% if cookiecutter.include_metaflow %} | ||
| metaflow_app: | ||
| build: . | ||
| command: ["python", "metaflow_app/spin_prototype.py"] | ||
| volumes: | ||
| - ./src:/app/src | ||
| {% endif %} | ||
| {% if cookiecutter.include_package %} | ||
| python_package: | ||
| build: . | ||
| command: ["python", "-m", "{{cookiecutter.package}}"] | ||
| volumes: | ||
| - ./src:/app/src | ||
| {% endif %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
File renamed without changes.
Empty file.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The 'package' prompt was removed from prompts but the 'package' field still exists in the main configuration (line 6). If the package field should remain configurable, restore its prompt; otherwise, document that it defaults to the repository name.