Skip to content

Commit

Permalink
Template update
Browse files Browse the repository at this point in the history
  • Loading branch information
mephenor committed Jan 15, 2024
1 parent 4f9df1f commit 80ebde9
Show file tree
Hide file tree
Showing 42 changed files with 982 additions and 366 deletions.
5 changes: 0 additions & 5 deletions .coveragerc

This file was deleted.

2 changes: 1 addition & 1 deletion .devcontainer/dev_install
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ cd /workspace
python -m pip install --upgrade pip

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

# install the package itself in edit mode:
pip install --no-deps -e .
Expand Down
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@v3
uses: ghga-de/gh-action-common@v4

- name: Check config docs
run: |
Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/check_openapi_spec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# This file is only needed, if your repository uses FastAPI
name: Check if openapi.yaml is up to date

on: push

jobs:
static-code-analysis:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- id: common
uses: ghga-de/gh-action-common@v4

- name: Check if openapi.yaml is up to date
run: |
export ${{ steps.common.outputs.CONFIG_YAML_ENV_VAR_NAME }}="${{ steps.common.outputs.CONFIG_YAML }}"
./scripts/update_openapi_docs.py --check
16 changes: 16 additions & 0 deletions .github/workflows/check_pyproject.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Check if the config schema and the example are up to date.

on: push

jobs:
static-code-analysis:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- id: common
uses: ghga-de/gh-action-common@v4

- name: Check pyproject.toml
run: |
./scripts/update_pyproject.py --check
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@v3
uses: ghga-de/gh-action-common@v4

- 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@v3
uses: ghga-de/gh-action-common@v4

- uses: pre-commit/[email protected]
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/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@v3
uses: ghga-de/gh-action-common@v4

- id: pytest
run: |
Expand Down
12 changes: 0 additions & 12 deletions .mypy.ini

This file was deleted.

29 changes: 29 additions & 0 deletions .pyproject_generation/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!--
Copyright 2021 - 2023 Universität Tübingen, DKFZ, EMBL, and Universität zu Köln
for the German Human Genome-Phenome Archive (GHGA)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

# Generating the pyproject.toml

The pyproject.toml of the service is generated by combining static configuration
captured in [`./pyproject_template.toml`](./pyproject_template.toml) and custom
package metadata specified in [`./pyproject_custom.toml`](./pyproject_custom.toml).

The `./pyproject_template.toml` is managed by the template, please do not edit manually.

You may specify properties in the `./pyproject_custom.toml` which are already specified
in the `./pyproject_template.toml`. In that case, the `./pyproject_custom.toml` takes
priority.
17 changes: 17 additions & 0 deletions .pyproject_generation/pyproject_custom.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[project]
name = "ghga_connector"
version = "1.2.0"
description = "GHGA Connector - A CLI client application for interacting with the GHGA system."
dependencies = [
"typer~=0.9.0",
"crypt4gh>=1.6, <2",
"ghga-service-commons[api, crypt]~=2.0.0",
"hexkit[s3]~=2.0.0",
]


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

[project.scripts]
ghga-connector = "ghga_connector.__main__:run"
61 changes: 52 additions & 9 deletions .ruff.toml → ...roject_generation/pyproject_template.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,37 @@
[build-system]
requires = ["setuptools>=67.7.2"]
build-backend = "setuptools.build_meta"

[project]
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",
]

[tool.setuptools.packages.find]
where = ["src"]

[tool.ruff]
exclude = [
".git",
".devcontainer",
"__pycache__",
"build",
"dist",
]

ignore = [
"E", # pycodestyle errors
"W", # pycodestyle warnings - pycodestyle covered by black
Expand All @@ -23,9 +49,7 @@ ignore = [
"D206", # indent-with-spaces (ignored for formatter)
"D300", # triple-single-quotes (ignored for formatter)
]

line-length = 88

select = [
"C90", # McCabe Complexity
"F", # pyflakes codes
Expand All @@ -39,26 +63,45 @@ select = [
"SIM", # flake8-simplify
"D", # pydocstyle
]

fixable = [
"UP", # e.g. List -> list
"I", # sort imports
"D", # pydocstyle
]

src = ["src", "tests", "examples", "scripts"]

target-version = "py39"

[mccabe]
[tool.ruff.mccabe]
max-complexity = 10

[per-file-ignores]
[tool.ruff.per-file-ignores]
"scripts/*" = ["PL", "S", "SIM", "D"]
"tests/*" = ["S", "SIM", "PLR", "B011"]
".devcontainer/*" = ["S", "SIM", "D"]
"examples/*" = ["S", "D"]
"__init__.py" = ["D"]

[pydocstyle]
[tool.ruff.pydocstyle]
convention = "pep257"

[tool.mypy]
disable_error_code = "import"
show_error_codes = true
exclude = [
'build/lib/',
]
warn_redundant_casts = true
warn_unused_ignores = true
check_untyped_defs = true
no_site_packages = false

[tool.pytest.ini_options]
minversion = "7.1"
asyncio_mode = "strict"

[tool.coverage.paths]
source = [
"src",
"/workspace/src",
"**/lib/python*/site-packages",
]
22 changes: 11 additions & 11 deletions readme_generation.md → .readme_generation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,30 @@

# Readme Generation

The README file is generated by collecting information from different sources as
The Repository README is generated by collecting information from different sources as
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 [`./pyproject.toml`](./pyproject.toml).
in the [`../pyproject.toml`](../pyproject.toml).
- summary: A short 1-2 sentence summary derived from the description in the
[`./pyproject.toml`](./pyproject.toml).
[`../pyproject.toml`](../pyproject.toml).
- version: The package version derived from the version specified in the
[`./pyproject.toml`](./pyproject.toml).
[`../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).
service or package. Obtained from the [`./description.md`](./description.md).
- design_description: A markdown-formatted description of the overall architecture and
design of the package. Obtained from the [`./.design.md`](./.design.md).
design of the package. Obtained from the [`./design.md`](./design.md).
- config_description: A markdown-formatted description of all config parameters.
This is autogenerated from the [`./config_schema.json`](./config_schema.json).
This is autogenerated from the [`../config_schema.json`](../config_schema.json).
- openapi_doc: A markdown-formatted description of the HTTP API. This is autogenerated
and links to the [`./openapi.yaml`](./openapi.yaml). If the openapi.yaml is not
and links to the [`../openapi.yaml`](../openapi.yaml). If the openapi.yaml is not
this documentation is empty.

The [`./.readme_template.md`](./.readme_template.md) serves as a template where the
The [`./readme_template.md`](./readme_template.md) serves as a template where the
above variable can be filled in using Pythons `string.Template` utility from the
standard library.

The [`./scripts/update_readme.py`] script can be used to collect all information and
fill it into the template to generate the README file.
The [`../scripts/update_readme.py`](../scripts/update_readme.py) script can be used to
collect all information and fill it into the template to generate the README file.
8 changes: 4 additions & 4 deletions .description.md → .readme_generation/description.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<!-- Please provide a short overview of the features of this service.-->

The GHGA Connector is a command line client facilitating interaction with the file storage infrastructure of GHGA.
To this end, it provides commands for the up- and download of files that interact with the RESTful APIs exposed by the Upload Controller Service (https://github.com/ghga-de/upload-controller-service) and Download Controller Service (https://github.com/ghga-de/download-controller-service), respectively.
To this end, it provides commands for the up- and download of files that interact with the RESTful APIs exposed
by the Upload Controller Service (https://github.com/ghga-de/upload-controller-service) and Download Controller Service (https://github.com/ghga-de/download-controller-service), respectively.

When uploading, the Connector expects an unencrypted file that is subsequently encrypted according to the Crypt4GH standard (https://www.ga4gh.org/news_item/crypt4gh-a-secure-method-for-sharing-human-genetic-data/) and only afterwards uploaded to the GHGA storage infrastructure.
When uploading, the Connector expects an unencrypted file that is subsequently encrypted according to the Crypt4
GH standard (https://www.ga4gh.org/news_item/crypt4gh-a-secure-method-for-sharing-human-genetic-data/) and only afterwards uploaded to the GHGA storage infrastructure.

When downloading, the resulting file is still encrypted in this manner and can be decrypted using the Connector's decrypt command.
As the user is expected to download multiple files, this command takes a directory location as input and an optional output directory location can be provided, creating the directory if it does not yet exist (defaulting to the current working directory, if none is provided).
Expand Down
4 changes: 0 additions & 4 deletions .design.md → .readme_generation/design.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
<!-- Please provide an overview of the architecture and design of the code base.
Mention anything that deviates from the standard triple hexagonal architecture and
the corresponding structure. -->

This is a Python-based client enabling interaction with GHGA's file services.
Contrary to the design of the actual services, the client does not follow the triple-hexagonal architecture.
The client is roughly structured into three parts:
Expand Down
5 changes: 2 additions & 3 deletions .readme_template.md → .readme_generation/readme_template.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

[![tests](https://github.com/ghga-de/$name/actions/workflows/tests.yaml/badge.svg)](https://github.com/ghga-de/$name/actions/workflows/tests.yaml)
[![Coverage Status](https://coveralls.io/repos/github/ghga-de/$name/badge.svg?branch=main)](https://coveralls.io/github/ghga-de/$name?branch=main)
[![tests](https://github.com/ghga-de/$repo_name/actions/workflows/tests.yaml/badge.svg)](https://github.com/ghga-de/$repo_name/actions/workflows/tests.yaml)
[![Coverage Status](https://coveralls.io/repos/github/ghga-de/$repo_name/badge.svg?branch=main)](https://coveralls.io/github/ghga-de/$repo_name?branch=main)

# $title

Expand Down
47 changes: 47 additions & 0 deletions .template/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<!--
Copyright 2021 - 2023 Universität Tübingen, DKFZ, EMBL, and Universität zu Köln
for the German Human Genome-Phenome Archive (GHGA)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

# Template File Lists

This directory contains multiple text files that are listing paths to other files
of this repository. The listed files are affected in different ways by template updates
as explained in the following.

## `static_files.txt`
The files listed here are synced with their counterparts in the template. They should
never be modified manually.

## `static_files_ignore.txt`
To opt out of template updates just for individual files declared as static
(e.g. because you would like manually modify them), you may add them to this list.

## `mandatory_files.txt`
The contents of the files listed here are not synced with the template, however, upon
every template update it is checked that the files exist. You should modify them
manually to the needs of your repository.

## `mandatory_files_ignore.txt`
To opt out of existence checks for individual files declared as mandatory, you may add
them to this list.

## `deprecated_files.txt`
Files listed here must not exist in your repository and are automatically deleted upon
a template update.

## `deprecated_files_ignore.txt`
If you would like to keep files declared as deprecated, you may add them to this list.
19 changes: 19 additions & 0 deletions .deprecated_files → .template/deprecated_files.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,26 @@ docs

setup.py
setup.cfg
requirements-dev-common.in
requirements-dev.in
requirements-dev.txt
requirements.txt
pytest.ini
readme_generation.md

.pylintrc
.flake8
.mypy.ini
.ruff.toml
.coveragerc
.editorconfig
.deprecated_files
.deprecated_files_ignore
.mandatory_files
.mandatory_files_ignore
.static_files
.static_files_ignore
.description.md
.design.md
.readme_template.md
.readme_generation.md
Loading

0 comments on commit 80ebde9

Please sign in to comment.