Skip to content

Commit

Permalink
Setup app
Browse files Browse the repository at this point in the history
  • Loading branch information
ehanson8 committed Dec 3, 2024
1 parent 91d1e3d commit 1587c7d
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 41 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ RUN apt-get update && apt-get upgrade -y && apt-get install -y git
COPY Pipfile* /
RUN pipenv install

ENTRYPOINT ["pipenv", "run", "my_app"]
ENTRYPOINT ["pipenv", "run", "dsc"]
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ update: install # Update Python dependencies
######################

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

coveralls: test # Write coverage data to an LCOV report
Expand Down
2 changes: 1 addition & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ ruff = "*"
python_version = "3.12"

[scripts]
my_app = "python -c \"from my_app.cli import main; main()\""
dsc = "python -c \"from dsc.cli import main; main()\""
38 changes: 5 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,7 @@
# python-cli-template

A template repository for creating Python CLI applications.

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

1. Rename "my_app" 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
# dspace-submission-composer
An application for creating messages for the [DSpace Submission Service application](https://github.com/MITLibraries/dspace-submission-service).

# Application Description

Description of the app

Expand All @@ -31,7 +12,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: `pipenv run my_app --help`
- To run the app: `pipenv run dsc --help`

## Environment Variables

Expand All @@ -42,14 +23,5 @@ SENTRY_DSN=### If set to a valid Sentry DSN, enables Sentry exception monitoring
WORKSPACE=### Set to `dev` for local development, this will be set to `stage` and `prod` in those environments by Terraform.
```

### Optional

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

```shell
<OPTIONAL_ENV>=### Description for optional environment variable
```




1 change: 1 addition & 0 deletions dsc/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""dsc package."""
2 changes: 1 addition & 1 deletion my_app/cli.py → dsc/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 dsc.config import configure_logger, configure_sentry

logger = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion my_app/config.py → dsc/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("dsc"))
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.

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 dsc.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 dsc.config import configure_logger, configure_sentry


def test_configure_logger_not_verbose():
Expand Down

0 comments on commit 1587c7d

Please sign in to comment.