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

List entities in namespace(s) #111

Merged
merged 35 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
4c812c0
Add `list` command to the CLI
CasperWA Apr 9, 2024
26ab9b7
New '/_api' router with an '/entities' GET endpoint
CasperWA Apr 9, 2024
6774239
Merge branch 'main' into cwa/close-107-list-entities-in-namespace
CasperWA Apr 9, 2024
2daf634
Merge remote-tracking branch 'origin/main' into cwa/close-107-list-en…
CasperWA May 14, 2024
b78a076
Move list_entities to separate module
CasperWA May 14, 2024
c244b00
Merge remote-tracking branch 'origin/main' into cwa/close-107-list-en…
CasperWA May 15, 2024
5fc1290
Reorder as a 'list' sub-group of commands
CasperWA May 16, 2024
f5bb7f9
Merge remote-tracking branch 'origin/main' into cwa/close-107-list-en…
CasperWA May 30, 2024
fdd025d
Use slim Python image for Dockerfile
CasperWA May 31, 2024
461ec8f
Redo how backends are initialized
CasperWA May 31, 2024
b824853
Fully implement list CLI cmd
CasperWA Jun 3, 2024
d3a35cc
Merge remote-tracking branch 'origin/main' into cwa/close-107-list-en…
CasperWA Jun 4, 2024
c9b4ccd
Fix reference to _initialize() method
CasperWA Jun 4, 2024
c14f6d8
Add tests for 'list namespaces' cmd
CasperWA Jun 5, 2024
0bc3954
Initial test for 'list entities' command
CasperWA Jun 5, 2024
982dcf1
Test listing entities for a specific namespace
CasperWA Jun 5, 2024
ce9ce0e
Test `--all/-a` option for list entities
CasperWA Jun 5, 2024
ab40399
Mock the CONFIG.base_url with live backend
CasperWA Jun 5, 2024
7972c80
Merge remote-tracking branch 'origin/main' into cwa/close-107-list-en…
CasperWA Jun 26, 2024
cf1bb45
Fix tests wrt a live backend
CasperWA Jun 27, 2024
6186aa9
Avoid list ordering issues
CasperWA Jun 27, 2024
9f8fa8b
Extend run time for Docker in CI
CasperWA Jun 28, 2024
7125bc2
Don't use the slim image
CasperWA Jun 28, 2024
2c09979
Add tests for the new API endpoints
CasperWA Jun 28, 2024
bfd2e39
Finish namespace_from_entity_namespace test
CasperWA Jun 28, 2024
dc413a5
Extend tests
CasperWA Jun 28, 2024
3def757
Fix test - ensure proper appendaging
CasperWA Jun 28, 2024
a01f4ef
Completely cover the new api router module
CasperWA Jun 28, 2024
2326af2
Add "negative" tests for CLI list namespaces
CasperWA Jul 1, 2024
b5a5eca
Add "negative" tests for CLI list entities command
CasperWA Jul 1, 2024
7e33cb0
Merge remote-tracking branch 'origin/main' into cwa/close-107-list-en…
CasperWA Jul 1, 2024
b0b86e4
Add tests for the CLI list utility functions
CasperWA Jul 1, 2024
4bd2585
Merge remote-tracking branch 'origin/cwa/close-107-list-entities-in-n…
CasperWA Jul 1, 2024
33a23b5
Add color to pytest runs in GitHub CI
CasperWA Jul 1, 2024
fba2bbb
Avoid log checks against server for live backend
CasperWA Jul 1, 2024
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
6 changes: 3 additions & 3 deletions .github/workflows/ci_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ jobs:
--env ENTITIES_SERVICE_X509_CERTIFICATE_FILE \
--env ENTITIES_SERVICE_CA_FILE \
--env PORT=${ENTITIES_SERVICE_PORT} \
--env RUN_TIME=40 \
--env RUN_TIME=60 \
--env STOP_TIME=3 \
--name "entities-service" \
--network "host" \
Expand All @@ -124,7 +124,7 @@ jobs:
- name: Run tests
run: |
{
pytest -vv --live-backend --cov-report=
pytest -vv --live-backend --cov-report= --color=yes
} || {
echo "Failed! Here's the Docker logs for the service:" &&
docker logs entities-service &&
Expand Down Expand Up @@ -189,7 +189,7 @@ jobs:
pip install -U -e .[testing]

- name: Run pytest
run: pytest -vv --cov-report=xml
run: pytest -vv --cov-report=xml --color=yes

- name: Upload coverage
if: github.repository_owner == 'SINTEF'
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: "3"
name: "entities-service"

services:
entities_service:
Expand Down
24 changes: 19 additions & 5 deletions entities_service/cli/commands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,20 @@
from typer import Typer


SUB_TYPER_APPS = ("config",)
SUB_TYPER_APPS = ("config", "list")
NO_ARGS_IS_HELP_COMMANDS = ("upload", "validate")
ALIASED_COMMANDS: dict[str, str] = {}


def get_commands() -> Generator[tuple[Callable, dict[str, Any]], None, None]:
"""Return all CLI commands, along with typer.command() kwargs."""
"""Return all CLI commands, along with typer.command() kwargs.

It is important the command module name matches the command function name.

To have a command with an alias, add the alias to the ALIASED_COMMANDS dict.
To have a command that does not require arguments to show the help message, add
the command name to the NO_ARGS_IS_HELP_COMMANDS tuple.
"""
this_dir = Path(__file__).parent.resolve()

for path in this_dir.glob("*.py"):
Expand All @@ -37,16 +46,21 @@
"name."
)

command_kwargs = {}
if path.stem in ("upload", "validate"):
command_kwargs: dict[str, Any] = {}
if path.stem in NO_ARGS_IS_HELP_COMMANDS:
command_kwargs["no_args_is_help"] = True
if path.stem in ALIASED_COMMANDS:
command_kwargs["name"] = ALIASED_COMMANDS[path.stem]

Check warning on line 53 in entities_service/cli/commands/__init__.py

View check run for this annotation

Codecov / codecov/patch

entities_service/cli/commands/__init__.py#L53

Added line #L53 was not covered by tests

yield getattr(module, path.stem), command_kwargs


def get_subtyper_apps() -> Generator[tuple[Typer, dict[str, Any]], None, None]:
"""Return all CLI Typer apps, which are a group of sub-command groups, along with
typer.add_typer() kwargs."""
typer.add_typer() kwargs.

This is done according to the SUB_TYPER_APPS tuple.
"""
this_dir = Path(__file__).parent.resolve()

for path in this_dir.glob("*.py"):
Expand Down
Loading