Skip to content

Commit

Permalink
[Auto-generated] Update dependencies (#214)
Browse files Browse the repository at this point in the history
* Update dependencies in `pyproject.toml` (#206, #209, #213)
* Bump codecov/codecov-action from 4 to 5 (#208)

Remove deprecated typer options.
Manually sort commands for CLI docs.
Update CLI docs according to updated typer generation-algorithm.
Add timeout for `build_cli_docs.sh` file.


Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Casper Welzel Andersen <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Nov 21, 2024
1 parent ededa0c commit 86d99df
Show file tree
Hide file tree
Showing 7 changed files with 215 additions and 208 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ jobs:
- name: Upload coverage
if: github.repository_owner == 'SINTEF'
uses: codecov/codecov-action@v4
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
Expand Down Expand Up @@ -254,7 +254,7 @@ jobs:

- name: Upload coverage
if: github.repository_owner == 'SINTEF'
uses: codecov/codecov-action@v4
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
Expand Down
10 changes: 9 additions & 1 deletion build_cli_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,20 @@ fi

rm /tmp/CLI.md 2> /dev/null

TIMEOUT_EXECUTION_SECONDS=5
SECONDS=0

# Generate CLI documentation
typer entities_service.cli.main utils docs --output /tmp/CLI.md > /dev/null
until grep -q "# \`entities-service\`" /tmp/CLI.md; do
until grep -q "# \`entities-service\`" /tmp/CLI.md || [ "$SECONDS" -gt "${TIMEOUT_EXECUTION_SECONDS}" ]; do
typer entities_service.cli.main utils docs --output /tmp/CLI.md > /dev/null
done

if [ "$SECONDS" -gt "${TIMEOUT_EXECUTION_SECONDS}" ]; then
echo "❌ Timeout while generating CLI documentation."
exit 1
fi

diff --suppress-common-lines /tmp/CLI.md ${DOCS_PATH} > /dev/null 2>&1

ERROR_CODE=$?
Expand Down
130 changes: 65 additions & 65 deletions docs/CLI.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,73 @@ $ entities-service [OPTIONS] COMMAND [ARGS]...

**Commands**:

* `config`: Manage configuration options.
* `list`: List resources.
* `login`: Login to the entities service.
* `upload`: Upload (local) entities to a remote location.
* `validate`: Validate (local) entities.
* `config`: Manage configuration options.
* `list`: List resources.

## `entities-service login`

Login to the entities service.

**Usage**:

```console
$ entities-service login [OPTIONS]
```

**Options**:

* `-q, -s, -y, --quiet, --silent`: Do not print anything on success and do not ask for confirmation.
* `--help`: Show this message and exit.

## `entities-service upload`

Upload (local) entities to a remote location.

**Usage**:

```console
$ entities-service upload [OPTIONS] [SOURCE]...
```

**Arguments**:

* `[SOURCE]...`: Path to file or directory with one or more entities.

**Options**:

* `--format [json|yaml|yml]`: Format of entity file(s). [default: json]
* `--fail-fast`: Stop uploading entities on the first error during file validation.
* `-q, -s, --quiet, --silent`: Do not print anything on success and do not ask for confirmation. IMPORTANT, for content conflicts the defaults will be chosen.
* `-y, --auto-confirm`: Automatically agree to any confirmations and use defaults for content conflicts. This differs from --quiet in that it will still print information.
* `--strict`: Strict validation of entities. This means the command will fail during the validation process, if an external entity already exists and the two entities are not equal. This option is only relevant if &#x27;--no-external-calls&#x27; is not provided. If both &#x27;--no-external-calls&#x27; and this options is provided, an error will be emitted.
* `--help`: Show this message and exit.

## `entities-service validate`

Validate (local) entities.

**Usage**:

```console
$ entities-service validate [OPTIONS] [SOURCE]...
```

**Arguments**:

* `[SOURCE]...`: Path to file or directory with one or more entities.

**Options**:

* `--format [json|yaml|yml]`: Format of entity file(s). [default: json]
* `--fail-fast`: Stop validating entities on the first discovered error.
* `-q, -s, -y, --quiet, --silent`: Do not print anything on success.
* `--no-external-calls`: Do not make any external calls to validate the entities. This includes mainly comparing local entities with their remote counterparts.
* `-v, --verbose`: Print the differences between the external and local entities (if any).
* `--strict`: Strict validation of entities. This means validation will fail if an external entity already exists and the two entities are not equal. This option is only relevant if &#x27;--no-external-calls&#x27; is not provided. If both &#x27;--no-external-calls&#x27; and this options is provided, an error will be emitted.
* `--help`: Show this message and exit.

## `entities-service config`

Expand Down Expand Up @@ -59,7 +121,7 @@ $ entities-service config set [OPTIONS] KEY:{access_token|backend|base_url|ca_fi

**Arguments**:

* `KEY:{access_token|backend|base_url|ca_file|debug|mongo_collection|mongo_db|mongo_password|mongo_uri|mongo_user|oauth2_provider|oauth2_provider_base_url|roles_group|x509_certificate_file}`: Configuration option to set. These can also be set as an environment variable by prefixing with 'ENTITIES_SERVICE_'. [required]
* `KEY:{access_token|backend|base_url|ca_file|debug|mongo_collection|mongo_db|mongo_password|mongo_uri|mongo_user|oauth2_provider|oauth2_provider_base_url|roles_group|x509_certificate_file}`: Configuration option to set. These can also be set as an environment variable by prefixing with &#x27;ENTITIES_SERVICE_&#x27;. [required]
* `[VALUE]`: Value to set. This will be prompted for if not provided.

**Options**:
Expand Down Expand Up @@ -164,65 +226,3 @@ $ entities-service list namespaces [OPTIONS]
**Options**:

* `--help`: Show this message and exit.

## `entities-service login`

Login to the entities service.

**Usage**:

```console
$ entities-service login [OPTIONS]
```

**Options**:

* `-q, -s, -y, --quiet, --silent`: Do not print anything on success and do not ask for confirmation.
* `--help`: Show this message and exit.

## `entities-service upload`

Upload (local) entities to a remote location.

**Usage**:

```console
$ entities-service upload [OPTIONS] [SOURCE]...
```

**Arguments**:

* `[SOURCE]...`: Path to file or directory with one or more entities.

**Options**:

* `--format [json|yaml|yml]`: Format of entity file(s). [default: json]
* `--fail-fast`: Stop uploading entities on the first error during file validation.
* `-q, -s, --quiet, --silent`: Do not print anything on success and do not ask for confirmation. IMPORTANT, for content conflicts the defaults will be chosen.
* `-y, --auto-confirm`: Automatically agree to any confirmations and use defaults for content conflicts. This differs from --quiet in that it will still print information.
* `--strict`: Strict validation of entities. This means the command will fail during the validation process, if an external entity already exists and the two entities are not equal. This option is only relevant if '--no-external-calls' is not provided. If both '--no-external-calls' and this options is provided, an error will be emitted.
* `--help`: Show this message and exit.

## `entities-service validate`

Validate (local) entities.

**Usage**:

```console
$ entities-service validate [OPTIONS] [SOURCE]...
```

**Arguments**:

* `[SOURCE]...`: Path to file or directory with one or more entities.

**Options**:

* `--format [json|yaml|yml]`: Format of entity file(s). [default: json]
* `--fail-fast`: Stop validating entities on the first discovered error.
* `-q, -s, -y, --quiet, --silent`: Do not print anything on success.
* `--no-external-calls`: Do not make any external calls to validate the entities. This includes mainly comparing local entities with their remote counterparts.
* `-v, --verbose`: Print the differences between the external and local entities (if any).
* `--strict`: Strict validation of entities. This means validation will fail if an external entity already exists and the two entities are not equal. This option is only relevant if '--no-external-calls' is not provided. If both '--no-external-calls' and this options is provided, an error will be emitted.
* `--help`: Show this message and exit.
4 changes: 2 additions & 2 deletions entities_service/cli/commands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def get_commands() -> Generator[tuple[Callable, dict[str, Any]]]:
"""
this_dir = Path(__file__).parent.resolve()

for path in this_dir.glob("*.py"):
for path in sorted(this_dir.glob("*.py")):
if path.stem in ("__init__", *SUB_TYPER_APPS):
continue

Expand Down Expand Up @@ -63,7 +63,7 @@ def get_subtyper_apps() -> Generator[tuple[Typer, dict[str, Any]]]:
"""
this_dir = Path(__file__).parent.resolve()

for path in this_dir.glob("*.py"):
for path in sorted(this_dir.glob("*.py")):
if path.stem not in SUB_TYPER_APPS:
continue

Expand Down
83 changes: 41 additions & 42 deletions entities_service/cli/commands/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,55 +142,13 @@ def set_config(
)


@APP.command()
def unset(
key: Annotated[
ConfigFields,
typer.Argument(
help="Configuration option to unset.",
show_choices=True,
shell_complete=ConfigFields.autocomplete,
case_sensitive=False,
show_default=False,
),
],
) -> None:
"""Unset a single configuration option."""
dotenv_file = CONTEXT["dotenv_path"]

if dotenv_file.exists():
unset_key(dotenv_file, f"{CONFIG.model_config['env_prefix']}{key}".upper())
print(f"Unset {CONFIG.model_config['env_prefix'].upper()}{key.upper()}.")
else:
print(f"{dotenv_file} file not found.")


@APP.command()
def unset_all() -> None:
"""Unset all configuration options."""
dotenv_file = CONTEXT["dotenv_path"]

typer.confirm(
"Are you sure you want to unset (remove) all configuration options in "
f"{dotenv_file} file, deleting the file in the process?",
abort=True,
)

if dotenv_file.exists():
dotenv_file.unlink()
print(f"Unset all configuration options. (Removed {dotenv_file}.)")
else:
print(f"{dotenv_file} file not found.")


@APP.command()
def show(
reveal_sensitive: Annotated[
bool,
typer.Option(
"--reveal-sensitive",
help="Reveal sensitive values. (DANGEROUS! Use with caution.)",
is_flag=True,
show_default=False,
),
] = False,
Expand Down Expand Up @@ -230,3 +188,44 @@ def show(
for key, value in output.items()
)
)


@APP.command()
def unset(
key: Annotated[
ConfigFields,
typer.Argument(
help="Configuration option to unset.",
show_choices=True,
shell_complete=ConfigFields.autocomplete,
case_sensitive=False,
show_default=False,
),
],
) -> None:
"""Unset a single configuration option."""
dotenv_file = CONTEXT["dotenv_path"]

if dotenv_file.exists():
unset_key(dotenv_file, f"{CONFIG.model_config['env_prefix']}{key}".upper())
print(f"Unset {CONFIG.model_config['env_prefix'].upper()}{key.upper()}.")
else:
print(f"{dotenv_file} file not found.")


@APP.command()
def unset_all() -> None:
"""Unset all configuration options."""
dotenv_file = CONTEXT["dotenv_path"]

typer.confirm(
"Are you sure you want to unset (remove) all configuration options in "
f"{dotenv_file} file, deleting the file in the process?",
abort=True,
)

if dotenv_file.exists():
dotenv_file.unlink()
print(f"Unset all configuration options. (Removed {dotenv_file}.)")
else:
print(f"{dotenv_file} file not found.")
Loading

0 comments on commit 86d99df

Please sign in to comment.