Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .aws-architecture
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
linux/arm64
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.13-slim
FROM python:3.12-slim

RUN apt-get update && \
apt-get install -y --no-install-recommends git ca-certificates && \
Expand All @@ -13,9 +13,9 @@ WORKDIR /app
COPY pyproject.toml uv.lock* ./

# Copy CLI application
COPY my_app ./my_app
COPY embeddings ./embeddings

# Install package into system python, includes "marimo-launcher" script
RUN uv pip install --system .

ENTRYPOINT ["my-app"]
ENTRYPOINT ["embeddings"]
9 changes: 5 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
SHELL=/bin/bash
DATETIME:=$(shell date -u +%Y%m%dT%H%M%SZ)
CPU_ARCH ?= $(shell cat .aws-architecture 2>/dev/null || echo "linux/amd64")

help: # Preview Makefile commands
@awk 'BEGIN { FS = ":.*#"; print "Usage: make <target>\n\nTargets:" } \
Expand Down Expand Up @@ -34,7 +35,7 @@ update: # Update Python dependencies
######################

test: # Run tests and print a coverage report
uv run coverage run --source=my_app -m pytest -vv
uv run coverage run --source=embeddings -m pytest -vv
uv run coverage report -m

coveralls: test # Write coverage data to an LCOV report
Expand Down Expand Up @@ -77,10 +78,10 @@ my-app: # CLI without any arguments, utilizing uv script entrypoint
# Docker
####################################
docker-build: # Build local image for testing
docker build -t python-cli-template:latest .
docker build --platform $(CPU_ARCH) -t timdex-embeddings:latest .

docker-shell: # Shell into local container for testing
docker run -it --entrypoint='bash' python-cli-template:latest
docker run -it --entrypoint='bash' timdex-embeddings:latest

docker-run: # Run main entrypoint + command without arguments
docker run python-cli-template:latest
docker run timdex-embeddings:latest
34 changes: 4 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,6 @@
# python-cli-template
# timdex-embeddings

A template repository for creating Python CLI applications.

## App Setup (delete this section and above after initial application setup)

1. Rename "my_app" and "python-cli-template" to the desired app name across the repo. (May be helpful to do a project-wide find-and-replace).
2. Update Python version if needed.
3. Install all dependencies with `make install` to create initial Pipfile.lock with latest dependency versions.
4. Add initial app description to README and update initial required ENV variable documentation as needed.
5. Update license if needed (check app-specific dependencies for licensing terms).
6. Check Github repository settings:
- Confirm repo branch protection settings are correct (see [dev docs](https://mitlibraries.github.io/guides/basics/github.html) for details)
- Confirm that all of the following are enabled in the repo's code security and analysis settings:
- Dependabot alerts
- Dependabot security updates
- Secret scanning
7. Create a Sentry project for the app if needed (we want this for most apps):
- Send initial exceptions to Sentry project for dev, stage, and prod environments to create them.
- Create an alert for the prod environment only, with notifications sent to the appropriate team(s).
- If *not* using Sentry, delete Sentry configuration from config.py and test_config.py, and remove sentry_sdk from project dependencies.

# my_app

Description of the app
A CLI application for creating embeddings for TIMDEX.

## Development

Expand All @@ -31,7 +9,7 @@ Description of the app
- To update dependencies: `make update`
- To run unit tests: `make test`
- To lint the repo: `make lint`
- To run the app: `uv run my-app --help` (Note the hyphen `-` vs underscore `_` that matches the `project.scripts` in `pyproject.toml`)
- To run the app: `my-app --help` (Note the hyphen `-` vs underscore `_` that matches the `project.scripts` in `pyproject.toml`)

## Environment Variables

Expand All @@ -44,11 +22,7 @@ WORKSPACE=### Set to `dev` for local development, this will be set to `stage` an

### Optional

_Delete this section if it isn't applicable to the PR._

```shell
<OPTIONAL_ENV>=### Description for optional environment variable
```
_None yet at this time._



Expand Down
1 change: 1 addition & 0 deletions embeddings/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""embeddings package."""
2 changes: 1 addition & 1 deletion my_app/cli.py → embeddings/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import click

from my_app.config import configure_logger, configure_sentry
from embeddings.config import configure_logger, configure_sentry

logger = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion my_app/config.py → embeddings/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def configure_logger(logger: logging.Logger, *, verbose: bool) -> str:
)
logger.setLevel(logging.DEBUG)
for handler in logging.root.handlers:
handler.addFilter(logging.Filter("my_app"))
handler.addFilter(logging.Filter("embeddings"))
else:
logging.basicConfig(
format="%(asctime)s %(levelname)s %(name)s.%(funcName)s(): %(message)s"
Expand Down
1 change: 0 additions & 1 deletion my_app/__init__.py

This file was deleted.

6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# https://mitlibraries.atlassian.net/wiki/spaces/IN/pages/3432415247/Python+Project+Linters#Template-for-pyproject.toml

[project]
name = "python-cli-template"
version = "2.0.0"
name = "timdex-embeddings"
version = "1.0.0"
requires-python = ">=3.12"

dependencies = [
Expand Down Expand Up @@ -85,7 +85,7 @@ max-doc-length = 90
convention = "google"

[project.scripts]
my-app = "my_app.cli:main"
embeddings = "embeddings.cli:main"

[build-system]
requires = ["setuptools>=61"]
Expand Down
2 changes: 1 addition & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from my_app.cli import main
from embeddings.cli import main


def test_cli_no_options(caplog, runner):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging

from my_app.config import configure_logger, configure_sentry
from embeddings.config import configure_logger, configure_sentry


def test_configure_logger_not_verbose():
Expand Down
4 changes: 2 additions & 2 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.