Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
DOCKER_TAG=v4.4.0
DOCKER_TAG=v4.5.0
REPOSITORY_DOCKER_URL=ghcr.io/nasa-ammos

PLANDEV_USERNAME=plandev
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ env:

jobs:
unit-test:
runs-on: ubuntu-latest
# run python 3.9 test on ubuntu 24.04 since newer ubuntu dropped support
runs-on: ${{ matrix.python-version == '3.9' && 'ubuntu-24.04' || 'ubuntu-latest' }}
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
Expand Down
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ PlanDev-CLI provides a command-line interface and user-extendable Python API for

## Upgrading from Aerie-CLI

Version 2.12.0 renames Aerie-CLI to **PlanDev-CLI** and supports [PlanDev 4.4.0](https://nasa-ammos.github.io/plandev-docs/). This release uses the new package, command, and Python API names exclusively.
Version 2.12.0+ renames Aerie-CLI to **PlanDev-CLI** and supports [PlanDev 4.4.0+](https://nasa-ammos.github.io/plandev-docs/). This release uses the new package, command, and Python API names exclusively.

Use `plandev-cli` instead of `aerie-cli`, or `python3 -m plandev_cli` instead of `python3 -m aerie_cli`.

Expand All @@ -31,6 +31,23 @@ plandev-cli activate

Command expansion is unavailable in this CLI release - previous CLI commands used the deprecated EDSL expansion APIs. Template-based expansion is supported by the PlanDev UI; CLI support is planned for a future release.

### Plan file format change

`plans download` now writes, and `plans upload` now reads, the **PlanTransfer v3** format shared with the PlanDev UI and Gateway. The previous CLI-specific plan format is no longer supported: files with `end_time` or `sim_id` must be converted.
For reference, a [complete JSON schema describing the new format](https://github.com/NASA-AMMOS/plandev-gateway/blob/v4.5.0/src/schemas/plan-transfer-validation-schema.ts) can be found in the PlanDev Gateway repo.

| Previous format | PlanTransfer v3 |
|---|---|
| `end_time` | `duration`, an interval such as `"48:00:00"`. Python's `end_time` is still available as a computed `ActivityPlan*.end_time` property, but is not in the JSON. |
| _(not exported)_ | `simulation_arguments` |
| `tags` on the plan only, with tag IDs | `tags` on the plan and on each activity, as `{"tag": {"name": ..., "color": ...}}` |
| `sim_id` | _(removed from JSON; `ActivityPlanRead.sim_id` remains in Python)_ |
| _(none)_ | `"version": "3"` |

Activity `start_offset` values are now written as `HH:MM:SS` rather than Python's `timedelta` text (e.g. `26:00:00`, not `1 day, 2:00:00`). To convert an old file, delete `sim_id`, replace `end_time` with `duration` (`end_time` minus `start_time`), and add `"version": "3"` and `"simulation_arguments": {}`.

`plans upload` and `PlanDevClient.create_activity_plan()` now go through the Gateway's `/importPlan` and wait for the import to finish before returning the plan ID. `--model-id` is required unless the file embeds a `model`, in which case the plan is imported read-only on a new non-executable model and `--model-id` is ignored. If an import fails, the CLI reports the reason and leaves the failed plan in PlanDev; delete it with `plans delete`. This needs PlanDev 4.5.0 or later.


## Getting Started

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "plandev-cli"
version = "2.12.0"
version = "2.13.0"
description = "A CLI application and Python API for interacting with PlanDev."
authors = []
license = "MIT"
Expand Down
23 changes: 14 additions & 9 deletions src/plandev_cli/commands/plans.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def download(
),
output: str = typer.Option(..., "--output", "-o", help="The output file destination", prompt=True)
):
"""Download a plan and save it locally as a JSON file."""
"""Download a plan and save it locally as a PlanTransfer v3 JSON file."""
plan = CommandContext.get_client().get_activity_plan_by_id(id, full_args)
with open(output, "w") as out_file:
out_file.write(plan.to_json(indent=2))
Expand Down Expand Up @@ -163,22 +163,27 @@ def download_resources(
@plans_app.command()
def upload(
input: str = typer.Option(
..., "--input", "-i", help="The input file from which to create an PlanDev plan", prompt=True
..., "--input", "-i", help="The PlanTransfer JSON file from which to create a PlanDev plan", prompt=True
),
model_id: int = typer.Option(
..., "--model-id", "-m", help="The mission model ID to associate with the plan", prompt=True
model_id: Union[int, None] = typer.Option(
None, "--model-id", "-m",
help="The mission model ID to associate with the plan. Required unless the file embeds its model, in which case it is ignored."
),
time_tag: bool = typer.Option(False, help="Append time tag to plan name"),
):
"""Create a plan from an input JSON file."""
"""Create a plan from a PlanTransfer JSON file, as exported by `plans download` or the PlanDev UI.

Waits for the import to finish. A file that embeds a `model` is imported read-only onto a new non-executable model."""
client = CommandContext.get_client()

with open(input) as in_file:
contents = in_file.read()
plan_to_create = ActivityPlanCreate.from_json(contents)
plan = json.load(in_file)
if "model" not in plan and model_id is None:
model_id = typer.prompt("Model ID", type=int)
name = plan.get("name")
if time_tag:
plan_to_create.name += arrow.utcnow().format("YYYY-MM-DDTHH-mm-ss")
plan_id = client.create_activity_plan(model_id, plan_to_create)
name = (name or "") + arrow.utcnow().format("YYYY-MM-DDTHH-mm-ss")
plan_id = client.import_plan(plan, model_id, name)
typer.echo(f"Created plan ID: {plan_id}")


Expand Down
Loading
Loading