Skip to content
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

Use pip-tools (GSI 334) #160

Merged
merged 34 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
8f09c5b
Add changes from the hexkit piptools update WIP
TheByronHimes Sep 14, 2023
3a3b5d5
Avoid KeyErrors in update_lock
TheByronHimes Sep 14, 2023
2f04cb9
Change requirements-dev file ending to .in
TheByronHimes Sep 14, 2023
bbca429
Compile initial lock files
TheByronHimes Sep 14, 2023
0972387
Exclude toml and .in files from license checker
TheByronHimes Sep 14, 2023
b8d5eaf
Make get_package_name work with pyproject.toml
TheByronHimes Sep 14, 2023
3625834
Make update_readme reference pyproject.toml
TheByronHimes Sep 14, 2023
29de082
Update readme and readme templates
TheByronHimes Sep 14, 2023
718bec7
Add pyproject.toml to mandatory_files
TheByronHimes Sep 14, 2023
f43e40c
Delete setup.cfg
TheByronHimes Sep 14, 2023
798afbb
Use --no-deps
TheByronHimes Sep 14, 2023
e934f4f
Only use --all-extras if optional-deps isn't empty
TheByronHimes Sep 14, 2023
56cc44e
Fix typo in readme files
TheByronHimes Sep 14, 2023
7de28fc
Don't upgrade requirements in dev_install
TheByronHimes Sep 15, 2023
0d60ce3
Add an upgrade flag to the update_lock script
TheByronHimes Sep 15, 2023
24d5632
Tell setuptools where to look
TheByronHimes Sep 15, 2023
9fef841
Fix reqs files after output to reduce diff lines
TheByronHimes Sep 15, 2023
ce4ede4
Uncap requirements and add lock files
TheByronHimes Sep 15, 2023
1ed4616
Constrain production subset to dev dependencies
TheByronHimes Sep 18, 2023
05759ee
Remove unnecessary chdir
TheByronHimes Sep 18, 2023
76b9506
Tweak fix_temp_dir_comments() and run update_lock
TheByronHimes Sep 18, 2023
2185c48
Use gh-action-common v3
TheByronHimes Sep 18, 2023
052aba4
Update missed files
TheByronHimes Sep 18, 2023
7378188
Add pylint and flake8 (that's a separate PR)
TheByronHimes Sep 19, 2023
be25344
Install package to run checks that reference it
TheByronHimes Sep 19, 2023
37820e7
Update readme
TheByronHimes Sep 19, 2023
cea19f9
Relax testcontainers requirement
TheByronHimes Sep 19, 2023
d98bea3
Simplify get_package_name with tomli
TheByronHimes Sep 19, 2023
649daba
Use subprocess.run instead of subprocess.Popen
TheByronHimes Sep 19, 2023
d2f6bd8
Remove package install command from workflow files
TheByronHimes Sep 19, 2023
0946267
Add a --check flag to see if updates are needed
TheByronHimes Sep 19, 2023
59c23b7
Update for dnspython
TheByronHimes Sep 19, 2023
9e275cc
Restore previous get_package_name
TheByronHimes Sep 19, 2023
5777bb1
Move production deps constraint to update script
TheByronHimes Sep 20, 2023
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
3 changes: 3 additions & 0 deletions .deprecated_files
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ scripts/check_mandatory_and_static_files.py
scripts/update_static_files.py

docs

setup.py
setup.cfg
8 changes: 4 additions & 4 deletions .devcontainer/dev_install
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ cd /workspace
# upgrade pip
python -m pip install --upgrade pip

# install with all extras in editable mode
pip install -e .[all]

# install or upgrade dependencies for development and testing
pip install -r requirements-dev.txt
pip install --no-deps -r requirements-dev.txt

# install the package itself in edit mode:
pip install --no-deps -e .

# install pre-commit hooks to git
pre-commit install
2 changes: 1 addition & 1 deletion .github/workflows/check_config_docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
- uses: actions/checkout@v3

- id: common
uses: ghga-de/gh-action-common@v2
uses: ghga-de/gh-action-common@v3

- name: Check config docs
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check_openapi_spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
- uses: actions/checkout@v3

- id: common
uses: ghga-de/gh-action-common@v2
uses: ghga-de/gh-action-common@v3

- name: Check if openapi.yaml is up to date
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check_readme.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
- uses: actions/checkout@v3

- id: common
uses: ghga-de/gh-action-common@v2
uses: ghga-de/gh-action-common@v3

- name: Check readme
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/static_code_analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
- uses: actions/checkout@v3

- id: common
uses: ghga-de/gh-action-common@v2
uses: ghga-de/gh-action-common@v3

- uses: pre-commit/[email protected]
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit_and_int_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- uses: actions/checkout@v3

- id: common
uses: ghga-de/gh-action-common@v2
uses: ghga-de/gh-action-common@v3

- name: Run pytest
run: |
Expand Down
5 changes: 3 additions & 2 deletions .mandatory_files
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ Dockerfile
config_schema.json
example_config.yaml
LICENSE
pyproject.toml
README.md
setup.py
setup.cfg
TheByronHimes marked this conversation as resolved.
Show resolved Hide resolved
requirements-dev.in
requirements-dev.txt
requirements.txt

.description.md
.design.md
2 changes: 1 addition & 1 deletion .readme_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ Moreover, inside the devcontainer, a convenience commands `dev_install` is avail
It installs the service with all development dependencies, installs pre-commit.

The installation is performed automatically when you build the devcontainer. However,
if you update dependencies in the [`./setup.cfg`](./setup.cfg) or the
if you update dependencies in the [`./pyproject.toml`](./pyproject.toml) or the
[`./requirements-dev.txt`](./requirements-dev.txt), please run it again.

## License
Expand Down
3 changes: 1 addition & 2 deletions .static_files
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ example_data/README.md
pytest.ini

LICENSE
requirements.txt
requirements-dev-common.txt
requirements-dev-common.in
setup.py

.readme_template.md
Expand Down
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,21 +70,21 @@ my_microservice --help
### Parameters

The service requires the following configuration parameters:
- **`host`** *(string)*: IP of the host. Default: `127.0.0.1`.
- **`host`** *(string)*: IP of the host. Default: `"127.0.0.1"`.

- **`port`** *(integer)*: Port to expose the server on the specified host. Default: `8080`.

- **`log_level`** *(string)*: Controls the verbosity of the log. Must be one of: `['critical', 'error', 'warning', 'info', 'debug', 'trace']`. Default: `info`.
- **`log_level`** *(string)*: Controls the verbosity of the log. Must be one of: `["critical", "error", "warning", "info", "debug", "trace"]`. Default: `"info"`.

- **`auto_reload`** *(boolean)*: A development feature. Set to `True` to automatically reload the server upon code changes. Default: `False`.
- **`auto_reload`** *(boolean)*: A development feature. Set to `True` to automatically reload the server upon code changes. Default: `false`.

- **`workers`** *(integer)*: Number of workers processes to run. Default: `1`.

- **`api_root_path`** *(string)*: Root path at which the API is reachable. This is relative to the specified host and port. Default: `/`.
- **`api_root_path`** *(string)*: Root path at which the API is reachable. This is relative to the specified host and port. Default: `"/"`.

- **`openapi_url`** *(string)*: Path to get the openapi specification in JSON format. This is relative to the specified host and port. Default: `/openapi.json`.
- **`openapi_url`** *(string)*: Path to get the openapi specification in JSON format. This is relative to the specified host and port. Default: `"/openapi.json"`.

- **`docs_url`** *(string)*: Path to host the swagger documentation. This is relative to the specified host and port. Default: `/docs`.
- **`docs_url`** *(string)*: Path to host the swagger documentation. This is relative to the specified host and port. Default: `"/docs"`.

- **`cors_allowed_origins`** *(array)*: A list of origins that should be permitted to make cross-origin requests. By default, cross-origin requests are not allowed. You can use ['*'] to allow any origin.

Expand All @@ -100,9 +100,9 @@ The service requires the following configuration parameters:

- **Items** *(string)*

- **`service_name`** *(string)*: Default: `my_microservice`.
- **`service_name`** *(string)*: Default: `"my_microservice"`.

- **`language`** *(string)*: Must be one of: `['Greek', 'Croatian', 'French', 'German']`. Default: `Croatian`.
- **`language`** *(string)*: Must be one of: `["Greek", "Croatian", "French", "German"]`. Default: `"Croatian"`.


### Usage:
Expand Down Expand Up @@ -163,7 +163,7 @@ Moreover, inside the devcontainer, a convenience commands `dev_install` is avail
It installs the service with all development dependencies, installs pre-commit.

The installation is performed automatically when you build the devcontainer. However,
if you update dependencies in the [`./setup.cfg`](./setup.cfg) or the
if you update dependencies in the [`./pyproject.toml`](./pyproject.toml) or the
[`./requirements-dev.txt`](./requirements-dev.txt), please run it again.

## License
Expand Down
37 changes: 37 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[build-system]
requires = ["setuptools>=67.7.2"]
build-backend = "setuptools.build_meta"

[project]
name = "my_microservice"
version = "0.1.0"
description = "My-Microservice - a short description"
readme = "README.md"
authors = [
{ name = "German Human Genome Phenome Archive (GHGA)", email = "[email protected]" },
]
requires-python = ">=3.9"
license = { text = "Apache 2.0" }
classifiers = [
"Development Status :: 1 - Planning",
"Operating System :: POSIX :: Linux",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"License :: OSI Approved :: Apache Software License",
"Topic :: Internet :: WWW/HTTP :: HTTP Servers",
"Topic :: Software Development :: Libraries",
"Intended Audience :: Developers",
]
dependencies = [
"typer ~= 0.7.0",
"ghga-service-commons[api] ~= 0.7.0",
"ghga-event-schemas ~= 0.13.0",
"hexkit[akafka,s3,mongodb] ~= 0.10.0"
]

[project.urls]
Repository = "https://github.com/ghga-de/my-microservice"

[tool.setuptools.packages.find]
where = ["src"]
6 changes: 3 additions & 3 deletions readme_generation.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ outlined in the following.
- name: The full name of the package is derived from the remote origin Git repository.
- title: A title case representation of the name.
- shortname: An abbreviation of the full name. This is derived from the name mentioned
in the [`./setup.cfg`](`./setup.cfg).
in the [`./pyproject.toml`](./pyproject.toml).
- summary: A short 1-2 sentence summary derived from the description in the
[`./setup.cfg`](`./setup.cfg).
[`./pyproject.toml`](./pyproject.toml).
- version: The package version derived from the version specified in the
[`./setup.cfg`](`./setup.cfg).
[`./pyproject.toml`](./pyproject.toml).
- description: A markdown-formatted description of the features and use cases of this
service or package. Obtained from the [`./.description.md`](./.description.md).
- design_description: A markdown-formatted description of the overall architecture and
Expand Down
38 changes: 38 additions & 0 deletions requirements-dev-common.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# common requirements for development and testing of services

pytest>=7.2.0
pytest-asyncio>=0.20.3
pytest-cov>=4.0.0
pytest-profiling>=1.7.0
snakeviz>=2.2.0

pre-commit>=3.1.1

mypy>=1.0.0
mypy-extensions>=1.0.0

pylint>=2.16.4
flake8>=6.0.0
bandit>=1.7.4

black>=23.1.0

isort>=5.12.0

click>=8.1.0
typer>=0.7.0

httpx>=0.23.3
pytest-httpx>=0.21.3

urllib3>=1.26.15
requests>=2.28.2

stringcase>=1.2.0
jsonschema2md>=1.0.0
setuptools>=67.7.2

# required since switch to pyproject.toml and pip-tools
pip-tools>=7.3.0
tomli>=2.0.1
tomli_w>=1.0.0
36 changes: 0 additions & 36 deletions requirements-dev-common.txt

This file was deleted.

7 changes: 7 additions & 0 deletions requirements-dev.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# requirements for development and testing this service

# common requirements for development and testing
-r requirements-dev-common.in

# additional requirements can be listed here
testcontainers[kafka,mongo]>=3.4.1
Loading