Skip to content

Commit 089bbc5

Browse files
Merge pull request #120 from ghga-de/feature/big_refactor_GSI-1859
Download path refactoring (GSI-1859)
2 parents 60c3a85 + 3ac3c52 commit 089bbc5

36 files changed

+1410
-1416
lines changed

.readme_generation/readme_template.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ $description
1313

1414
We recommend using the provided Docker container.
1515

16-
A pre-built version is available at [docker hub](https://hub.docker.com/repository/docker/ghga/$name):
16+
A pre-built version is available on [Docker Hub](https://hub.docker.com/repository/docker/ghga/$name):
1717
```bash
1818
docker pull ghga/$name:$version
1919
```
@@ -24,11 +24,11 @@ Or you can build the container yourself from the [`./Dockerfile`](./Dockerfile):
2424
docker build -t ghga/$name:$version .
2525
```
2626

27-
For production-ready deployment, we recommend using Kubernetes, however,
28-
for simple use cases, you could execute the service using docker
27+
For production-ready deployment, we recommend using Kubernetes.
28+
However for simple use cases, you could execute the service using docker
2929
on a single server:
3030
```bash
31-
# The entrypoint is preconfigured:
31+
# The entrypoint is pre-configured:
3232
docker run -p 8080:8080 ghga/$name:$version --help
3333
```
3434

@@ -50,18 +50,18 @@ $config_description
5050

5151
### Usage:
5252

53-
A template YAML for configuring the service can be found at
53+
A template YAML file for configuring the service can be found at
5454
[`./example_config.yaml`](./example_config.yaml).
5555
Please adapt it, rename it to `.$shortname.yaml`, and place it in one of the following locations:
5656
- in the current working directory where you execute the service (on Linux: `./.$shortname.yaml`)
5757
- in your home directory (on Linux: `~/.$shortname.yaml`)
5858

59-
The config yaml will be automatically parsed by the service.
59+
The config YAML file will be automatically parsed by the service.
6060

6161
**Important: If you are using containers, the locations refer to paths within the container.**
6262

6363
All parameters mentioned in the [`./example_config.yaml`](./example_config.yaml)
64-
could also be set using environment variables or file secrets.
64+
can also be set using environment variables or file secrets.
6565

6666
For naming the environment variables, just prefix the parameter name with `${shortname}_`,
6767
e.g. for the `host` set an environment variable named `${shortname}_host`
@@ -95,12 +95,12 @@ This will give you a full-fledged, pre-configured development environment includ
9595
- a pre-configured debugger
9696
- automatic license-header insertion
9797

98-
Moreover, inside the devcontainer, a command `dev_install` is available for convenience.
98+
Inside the devcontainer, a command `dev_install` is available for convenience.
9999
It installs the service with all development dependencies, and it installs pre-commit.
100100

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

105105
## License
106106

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Additionally, the decrypt command needs the private key to decrypt the downloade
2424

2525
We recommend using the provided Docker container.
2626

27-
A pre-built version is available at [docker hub](https://hub.docker.com/repository/docker/ghga/ghga-connector):
27+
A pre-built version is available on [Docker Hub](https://hub.docker.com/repository/docker/ghga/ghga-connector):
2828
```bash
2929
docker pull ghga/ghga-connector:1.7.3
3030
```
@@ -35,11 +35,11 @@ Or you can build the container yourself from the [`./Dockerfile`](./Dockerfile):
3535
docker build -t ghga/ghga-connector:1.7.3 .
3636
```
3737

38-
For production-ready deployment, we recommend using Kubernetes, however,
39-
for simple use cases, you could execute the service using docker
38+
For production-ready deployment, we recommend using Kubernetes.
39+
However for simple use cases, you could execute the service using docker
4040
on a single server:
4141
```bash
42-
# The entrypoint is preconfigured:
42+
# The entrypoint is pre-configured:
4343
docker run -p 8080:8080 ghga/ghga-connector:1.7.3 --help
4444
```
4545

@@ -76,18 +76,18 @@ The service requires the following configuration parameters:
7676

7777
### Usage:
7878

79-
A template YAML for configuring the service can be found at
79+
A template YAML file for configuring the service can be found at
8080
[`./example_config.yaml`](./example_config.yaml).
8181
Please adapt it, rename it to `.ghga_connector.yaml`, and place it in one of the following locations:
8282
- in the current working directory where you execute the service (on Linux: `./.ghga_connector.yaml`)
8383
- in your home directory (on Linux: `~/.ghga_connector.yaml`)
8484

85-
The config yaml will be automatically parsed by the service.
85+
The config YAML file will be automatically parsed by the service.
8686

8787
**Important: If you are using containers, the locations refer to paths within the container.**
8888

8989
All parameters mentioned in the [`./example_config.yaml`](./example_config.yaml)
90-
could also be set using environment variables or file secrets.
90+
can also be set using environment variables or file secrets.
9191

9292
For naming the environment variables, just prefix the parameter name with `ghga_connector_`,
9393
e.g. for the `host` set an environment variable named `ghga_connector_host`
@@ -128,12 +128,12 @@ This will give you a full-fledged, pre-configured development environment includ
128128
- a pre-configured debugger
129129
- automatic license-header insertion
130130

131-
Moreover, inside the devcontainer, a command `dev_install` is available for convenience.
131+
Inside the devcontainer, a command `dev_install` is available for convenience.
132132
It installs the service with all development dependencies, and it installs pre-commit.
133133

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

138138
## License
139139

scripts/update_config_docs.py

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
# See the License for the specific language governing permissions and
1616
# limitations under the License.
1717

18-
"""Generates a JSON schema from the service's Config class as well as a corresponding
19-
example config yaml (or check whether these files are up to date).
18+
"""Generate a JSON Schema from the service's Config class and an example
19+
config YAML file, or check whether the existing files are up to date.
2020
"""
2121

2222
import importlib
@@ -46,7 +46,7 @@ class ValidationError(RuntimeError):
4646
def get_config_class():
4747
"""
4848
Dynamically imports and returns the Config class from the current service.
49-
This makes the script service repo agnostic.
49+
This makes the script agnostic to the service repository.
5050
"""
5151
# get the name of the microservice package
5252
with subprocess.Popen(
@@ -82,28 +82,22 @@ def get_schema() -> str:
8282

8383
def get_example() -> str:
8484
"""Returns an example config YAML."""
85-
8685
config = get_dev_config()
8786
normalized_config_dict = config.model_dump(mode="json", by_alias=True)
8887
return yaml.dump(normalized_config_dict, indent=2, sort_keys=True)
8988

9089

9190
def update_docs():
92-
"""Update the example config and config schema files documenting the config
93-
options."""
94-
95-
example = get_example()
96-
with open(EXAMPLE_CONFIG_YAML, "w", encoding="utf-8") as example_file:
97-
example_file.write(example)
98-
99-
schema = get_schema()
100-
with open(CONFIG_SCHEMA_JSON, "w", encoding="utf-8") as schema_file:
101-
schema_file.write(schema)
91+
"""Update the example config YAML and JSON Schema files documenting the
92+
config options.
93+
"""
94+
EXAMPLE_CONFIG_YAML.write_text(get_example(), encoding="utf-8")
95+
CONFIG_SCHEMA_JSON.write_text(get_schema(), encoding="utf-8")
10296

10397

10498
def print_diff(expected: str, observed: str):
105-
"""Print differences between expected and observed files."""
106-
echo_failure("Differences in Config YAML:")
99+
"""Print differences between expected and observed example config YAML."""
100+
echo_failure("Differences in config YAML file:")
107101
for line in unified_diff(
108102
expected.splitlines(keepends=True),
109103
observed.splitlines(keepends=True),
@@ -114,28 +108,25 @@ def print_diff(expected: str, observed: str):
114108

115109

116110
def check_docs():
117-
"""Check whether the example config and config schema files documenting the config
118-
options are up to date.
111+
"""Check whether the example config YAML and JSON Schema files are up to date.
119112
120113
Raises:
121-
ValidationError: if not up to date.
114+
ValidationError: If not up to date.
122115
"""
123116

124117
example_expected = get_example()
125-
with open(EXAMPLE_CONFIG_YAML, encoding="utf-8") as example_file:
126-
example_observed = example_file.read()
118+
example_observed = EXAMPLE_CONFIG_YAML.read_text(encoding="utf-8")
127119
if example_expected != example_observed:
128120
print_diff(example_expected, example_observed)
129121
raise ValidationError(
130-
f"Example config YAML at '{EXAMPLE_CONFIG_YAML}' is not up to date."
122+
f"Example config YAML file at '{EXAMPLE_CONFIG_YAML}' is not up to date."
131123
)
132124

133125
schema_expected = get_schema()
134-
with open(CONFIG_SCHEMA_JSON, encoding="utf-8") as schema_file:
135-
schema_observed = schema_file.read()
126+
schema_observed = CONFIG_SCHEMA_JSON.read_text(encoding="utf-8")
136127
if schema_expected != schema_observed:
137128
raise ValidationError(
138-
f"Config schema JSON at '{CONFIG_SCHEMA_JSON}' is not up to date."
129+
f"Config schema JSON file at '{CONFIG_SCHEMA_JSON}' is not up to date."
139130
)
140131

141132

0 commit comments

Comments
 (0)