diff --git a/.aws-architecture b/.aws-architecture new file mode 100644 index 0000000..ed3f99e --- /dev/null +++ b/.aws-architecture @@ -0,0 +1 @@ +linux/arm64 \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index ca63d23..59442ae 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 && \ @@ -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"] diff --git a/Makefile b/Makefile index 9b4156a..8c11fc0 100644 --- a/Makefile +++ b/Makefile @@ -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 \n\nTargets:" } \ @@ -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 @@ -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 diff --git a/README.md b/README.md index 5d4cf08..27327b1 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 @@ -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 -=### Description for optional environment variable -``` +_None yet at this time._ diff --git a/embeddings/__init__.py b/embeddings/__init__.py new file mode 100644 index 0000000..9e9f6b5 --- /dev/null +++ b/embeddings/__init__.py @@ -0,0 +1 @@ +"""embeddings package.""" diff --git a/my_app/cli.py b/embeddings/cli.py similarity index 91% rename from my_app/cli.py rename to embeddings/cli.py index 2be55a3..27da889 100644 --- a/my_app/cli.py +++ b/embeddings/cli.py @@ -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__) diff --git a/my_app/config.py b/embeddings/config.py similarity index 94% rename from my_app/config.py rename to embeddings/config.py index 1b39fc7..7d47b73 100644 --- a/my_app/config.py +++ b/embeddings/config.py @@ -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" diff --git a/my_app/__init__.py b/my_app/__init__.py deleted file mode 100644 index 470cdfb..0000000 --- a/my_app/__init__.py +++ /dev/null @@ -1 +0,0 @@ -"""my_app package.""" diff --git a/pyproject.toml b/pyproject.toml index 28dbd75..ed231cd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 = [ @@ -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"] diff --git a/tests/test_cli.py b/tests/test_cli.py index 9975759..07fcb85 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -1,4 +1,4 @@ -from my_app.cli import main +from embeddings.cli import main def test_cli_no_options(caplog, runner): diff --git a/tests/test_config.py b/tests/test_config.py index 34e8272..4ca42ab 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -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(): diff --git a/uv.lock b/uv.lock index 15650ba..e912812 100644 --- a/uv.lock +++ b/uv.lock @@ -602,8 +602,8 @@ wheels = [ ] [[package]] -name = "python-cli-template" -version = "2.0.0" +name = "timdex-embeddings" +version = "1.0.0" source = { editable = "." } dependencies = [ { name = "click" },