Skip to content

Commit 6ef490f

Browse files
authored
Merge pull request #8 from MITLibraries/USE-111-initial-setup
USE 111 - Initial app setup
2 parents fc7df3e + 24ab4ed commit 6ef490f

File tree

12 files changed

+23
-47
lines changed

12 files changed

+23
-47
lines changed

.aws-architecture

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
linux/arm64

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.13-slim
1+
FROM python:3.12-slim
22

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

1515
# Copy CLI application
16-
COPY my_app ./my_app
16+
COPY embeddings ./embeddings
1717

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

21-
ENTRYPOINT ["my-app"]
21+
ENTRYPOINT ["embeddings"]

Makefile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
SHELL=/bin/bash
22
DATETIME:=$(shell date -u +%Y%m%dT%H%M%SZ)
3+
CPU_ARCH ?= $(shell cat .aws-architecture 2>/dev/null || echo "linux/amd64")
34

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

3637
test: # Run tests and print a coverage report
37-
uv run coverage run --source=my_app -m pytest -vv
38+
uv run coverage run --source=embeddings -m pytest -vv
3839
uv run coverage report -m
3940

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

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

8586
docker-run: # Run main entrypoint + command without arguments
86-
docker run python-cli-template:latest
87+
docker run timdex-embeddings:latest

README.md

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,6 @@
1-
# python-cli-template
1+
# timdex-embeddings
22

3-
A template repository for creating Python CLI applications.
4-
5-
## App Setup (delete this section and above after initial application setup)
6-
7-
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).
8-
2. Update Python version if needed.
9-
3. Install all dependencies with `make install` to create initial Pipfile.lock with latest dependency versions.
10-
4. Add initial app description to README and update initial required ENV variable documentation as needed.
11-
5. Update license if needed (check app-specific dependencies for licensing terms).
12-
6. Check Github repository settings:
13-
- Confirm repo branch protection settings are correct (see [dev docs](https://mitlibraries.github.io/guides/basics/github.html) for details)
14-
- Confirm that all of the following are enabled in the repo's code security and analysis settings:
15-
- Dependabot alerts
16-
- Dependabot security updates
17-
- Secret scanning
18-
7. Create a Sentry project for the app if needed (we want this for most apps):
19-
- Send initial exceptions to Sentry project for dev, stage, and prod environments to create them.
20-
- Create an alert for the prod environment only, with notifications sent to the appropriate team(s).
21-
- If *not* using Sentry, delete Sentry configuration from config.py and test_config.py, and remove sentry_sdk from project dependencies.
22-
23-
# my_app
24-
25-
Description of the app
3+
A CLI application for creating embeddings for TIMDEX.
264

275
## Development
286

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

3614
## Environment Variables
3715

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

4523
### Optional
4624

47-
_Delete this section if it isn't applicable to the PR._
48-
49-
```shell
50-
<OPTIONAL_ENV>=### Description for optional environment variable
51-
```
25+
_None yet at this time._
5226

5327

5428

embeddings/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""embeddings package."""

my_app/cli.py renamed to embeddings/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import click
66

7-
from my_app.config import configure_logger, configure_sentry
7+
from embeddings.config import configure_logger, configure_sentry
88

99
logger = logging.getLogger(__name__)
1010

my_app/config.py renamed to embeddings/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def configure_logger(logger: logging.Logger, *, verbose: bool) -> str:
1212
)
1313
logger.setLevel(logging.DEBUG)
1414
for handler in logging.root.handlers:
15-
handler.addFilter(logging.Filter("my_app"))
15+
handler.addFilter(logging.Filter("embeddings"))
1616
else:
1717
logging.basicConfig(
1818
format="%(asctime)s %(levelname)s %(name)s.%(funcName)s(): %(message)s"

my_app/__init__.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
# https://mitlibraries.atlassian.net/wiki/spaces/IN/pages/3432415247/Python+Project+Linters#Template-for-pyproject.toml
44

55
[project]
6-
name = "python-cli-template"
7-
version = "2.0.0"
6+
name = "timdex-embeddings"
7+
version = "1.0.0"
88
requires-python = ">=3.12"
99

1010
dependencies = [
@@ -85,7 +85,7 @@ max-doc-length = 90
8585
convention = "google"
8686

8787
[project.scripts]
88-
my-app = "my_app.cli:main"
88+
embeddings = "embeddings.cli:main"
8989

9090
[build-system]
9191
requires = ["setuptools>=61"]

tests/test_cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from my_app.cli import main
1+
from embeddings.cli import main
22

33

44
def test_cli_no_options(caplog, runner):

0 commit comments

Comments
 (0)