From 8f6ceefbafb51e69369585fd0b9e35eac3391e1c Mon Sep 17 00:00:00 2001 From: Carter Mak Date: Wed, 18 Dec 2024 08:45:21 -0800 Subject: [PATCH] Scheduling PR tweaks --- src/aerie_cli/aerie_client.py | 4 ++-- src/aerie_cli/app.py | 1 - src/aerie_cli/commands/scheduling.py | 19 +++++++--------- tests/integration_tests/README.md | 22 +++++++++++-------- .../{test_goals.py => test_scheduling.py} | 1 - 5 files changed, 23 insertions(+), 24 deletions(-) rename tests/integration_tests/{test_goals.py => test_scheduling.py} (99%) diff --git a/src/aerie_cli/aerie_client.py b/src/aerie_cli/aerie_client.py index 4402c70..6c01fd7 100644 --- a/src/aerie_cli/aerie_client.py +++ b/src/aerie_cli/aerie_client.py @@ -1782,9 +1782,9 @@ def get_goal_id_for_name(self, name): name=name ) if len(resp) == 0: - raise RuntimeError(f"No goals found with name {name}. Specify goal id manually with -g.") + raise RuntimeError(f"No goals found with name {name}.") elif len(resp) > 1: - raise RuntimeError(f"Multiple goals found with name {name}. Specify goal id manually with -g.") + raise RuntimeError(f"Multiple goals found with name {name}.") return resp[0]["id"] def add_goals_to_specifications(self, upload_object): diff --git a/src/aerie_cli/app.py b/src/aerie_cli/app.py index 57ddd80..7ffed17 100644 --- a/src/aerie_cli/app.py +++ b/src/aerie_cli/app.py @@ -3,7 +3,6 @@ `app` is the CLI application with which all commands, subcommands, and callbacks are registered. """ import typer -from rich import print from typing import Optional from aerie_cli.commands import models diff --git a/src/aerie_cli/commands/scheduling.py b/src/aerie_cli/commands/scheduling.py index 28e2dd3..92b8262 100644 --- a/src/aerie_cli/commands/scheduling.py +++ b/src/aerie_cli/commands/scheduling.py @@ -1,23 +1,18 @@ import typer -import os +from pathlib import Path from typing import Optional from aerie_cli.commands.command_context import CommandContext app = typer.Typer() -def _get_name_and_ext(path: str): - path = path.strip() - filename = os.path.basename(path) - return os.path.splitext(filename) - @app.command() def new( - path: str = typer.Argument(default=...), + path: Path = typer.Argument(default=...), description: Optional[str] = typer.Option( None, '--description', '-d', help="Description metadata" ), - public: bool = typer.Option(False, '-pub', help="Indicates a public goal visible to all users (default false)"), + public: bool = typer.Option(False, '--public', '-pub', help="Indicates a public goal visible to all users (default false)"), name: Optional[str] = typer.Option( None, '--name', '-n', help="Name of the new goal (default is the file name without extension)" ), @@ -31,7 +26,8 @@ def new( """Upload new scheduling goal""" client = CommandContext.get_client() - filename, extension = _get_name_and_ext(path) + filename = path.stem + extension = path.suffix if name is None: name = filename upload_obj = {} @@ -63,13 +59,14 @@ def new( @app.command() def update( - path: str = typer.Argument(default=...), + path: Path = typer.Argument(default=...), goal_id: Optional[int] = typer.Option(None, '--goal', '-g', help="Goal ID of goal to be updated (will search by name if omitted)"), name: Optional[str] = typer.Option(None, '--name', '-n', help="Name of the goal to be updated (ignored if goal is provided, default is the file name without extension)"), ): """Upload an update to a scheduling goal""" client = CommandContext.get_client() - filename, extension = _get_name_and_ext(path) + filename = path.stem + extension = path.suffix if goal_id is None: if name is None: name = filename diff --git a/tests/integration_tests/README.md b/tests/integration_tests/README.md index dc73978..7f6669c 100644 --- a/tests/integration_tests/README.md +++ b/tests/integration_tests/README.md @@ -24,15 +24,19 @@ python3 -m pytest . ## Updating Tests for New Aerie Versions -Integration tests are automatically run by CI against all supported Aerie versions. To add and test support for a new Aerie version: +Integration tests are automatically run by CI against all supported Aerie versions. Update as follows with the supported set of Aerie versions: -1. Download the appropriate version release JAR for the [Banananation model](https://github.com/NASA-AMMOS/aerie/packages/1171106/versions) and add it to `tests/integration_tests/files/models`, named as `banananation-X.X.X.jar` (substituting the correct version number). -2. Update the [`.env`](../../.env) file `DOCKER_TAG` value to the new version string. This defaults the local deployment to the latest Aerie version. -3. Update [`docker-compose-test.yml`](../../docker-compose-test.yml) as necessary to match the new Aerie version. The [aerie-ui compose file](https://github.com/NASA-AMMOS/aerie-ui/blob/develop/docker-compose-test.yml) can be a helpful reference to identify changes. -4. Manually run the integration tests and update the code and tests as necessary for any Aerie changes. +1. Integration tests require a JAR for the Banananation model for each tested Aerie version. [Download official artifacts from Github](https://github.com/NASA-AMMOS/aerie/packages/1171106/versions) and add to `tests/integration_tests/files/models`, named as `banananation-X.X.X.jar` (substituting the correct version number). Remove outdated JAR files. +2. Update the `COMPATIBLE_AERIE_VERSIONS` array in [`aerie_host.py`](../../src/aerie_cli/aerie_host.py). +3. Update the [`.env`](../../.env) file `DOCKER_TAG` value to the latest compatible version. This sets the default value for a local Aerie deployment. +4. Update [`docker-compose-test.yml`](../../docker-compose-test.yml) as necessary to match the supported Aerie versions. The [aerie-ui compose file](https://github.com/NASA-AMMOS/aerie-ui/blob/develop/docker-compose-test.yml) can be a helpful reference to identify changes. 5. Update the `aerie-version` list in the [CI configuration](../../.github/workflows/test.yml) to include the new version. -6. If breaking changes are necessary to support the new Aerie version, remove any Aerie versions which are no longer supported from the CI configuration and remove the corresponding banananation JAR file. -7. Open a PR and verify all tests still pass. + +To verify changes: + +1. Manually run the integration tests and update the code and tests as necessary for any Aerie changes. +2. If breaking changes are necessary to support the new Aerie version, remove any Aerie versions which will no longer be supported as described above. +3. Open a PR and verify all CI tests pass. ## Summary of Integration Tests @@ -48,8 +52,8 @@ Integration tests are automatically run by CI against all supported Aerie versio - Test all `plans` commands - Tests simulations and `plans download...` commands as well -### [Goals test](test_goals.py) -- Test all `goals` commands +### [Scheduling test](test_scheduling.py) +- Test all `scheduling` commands ### [Expansion test](test_expansion.py) - Test all `expansion` commands diff --git a/tests/integration_tests/test_goals.py b/tests/integration_tests/test_scheduling.py similarity index 99% rename from tests/integration_tests/test_goals.py rename to tests/integration_tests/test_scheduling.py index 4ad7d9c..03c0840 100644 --- a/tests/integration_tests/test_goals.py +++ b/tests/integration_tests/test_scheduling.py @@ -3,7 +3,6 @@ import arrow from typer.testing import CliRunner -from pathlib import Path from aerie_cli.__main__ import app from aerie_cli.schemas.client import ActivityPlanCreate