Skip to content

nablaflow/cli

Repository files navigation

nf - The NablaFlow CLI   built with nix

A command-line interface for creating simulations on AeroCloud and ArchiWind.

Installation

Stand-alone (Linux, macOS, Windows)

Linux/MacOS

curl --proto '=https' --tlsv1.2 -LsSf https://github.com/nablaflow/cli/releases/download/v1.2.0/nf-installer.sh | sh

Windows

powershell -ExecutionPolicy Bypass -c "irm https://github.com/nablaflow/cli/releases/download/v1.2.0/nf-installer.ps1 | iex"

As flake (Nix users)

Can be run directly using

cachix use nablaflow-public
nix run github:nablaflow/cli/v1.2.0

Getting started

After installing the CLI, open the terminal and run the nf -V command to verify it's correctly installed.

In order to use the CLI, a personal access token is required. Head to your AeroCloud API settings page and generate one with read and write permissions. The token should never be shared; keep it safe because it grants access to your account data.

Configure the CLI with the generated token by running:

nf aerocloud set-auth-token $TOKEN

Working with projects

Commands below use v7 to target the AeroCloud API version.

To list the existing projects:

nf aerocloud v7 list-projects

To create a new project:

nf aerocloud v7 create-project "project name"

Creating a model

To create a model, start by defining a JSON manifest for it, see examples/aerocloud/v7/create_model.json as starting point.

Then run:

nf aerocloud v7 create-model $PATH_TO_JSON

Creating a simulation

To create a simulation you need:

  • a target project
  • an input model

Follow the instructions in the previous steps to create both, note down project ID and model ID.

Then define a JSON manifest for it, see examples/aerocloud/v7/create_simulation.json as starting point.

Then run:

nf aerocloud v7 create-simulation --model-id $MODEL_ID --project-id $PROJECT_ID $PATH_TO_JSON

Tip

All commands accept --json after nf to output JSON instead of human readable text, so that the CLI can be comfortably used in scripts.

Tip

Use --help on every subcommand to see their documentation.

Tip

All commands that consume a JSON from a path also accept JSON from stdin, be sure to pass - instead of the file.
This facilitates usage from scripts.

Batch mode

The CLI can be used in batch mode to create multiple simulations at once.

First, prepare a folder with the JSON manifests for your simulation and the models to upload. Use the following structure as an example:

dir
├── simulation-1      # `simulation-1` is going to be the name of the simulation.
│   ├── model-1.stl   # `model` can be any valid UTF-8 filename.
│   ├── model-1.json  # Provides additional params on the `.stl` above (unit, parts, ...). *File names must match!*
│   ├── model-2.obj
│   ├── model-2.json
│   ├── params.json   # Simulation params.
└── simulation-2
    ├── donut-with-parts.json
    ├── donut-with-parts.obj
    ├── params.json

An example is available under examples/aerocloud/v7/batch.

Tip

You can skip uploading files and use a reusable model by just setting its ID in each simulation's params.json:

{
  "model_id": "b7203095-f9fd-4270-ac6d-03c46b02932b",
  ...
}

With the folder ready, run the following command to enter the Batch mode:

nf aerocloud v7 batch $directory

An interactive UI will be started where you can review and submit your simulations.

Follow the instructions and available commands at the bottom of the user interface.

Tip

When submitting simulations, stuff can go wrong: network timeouts, invalid parameters and such.
Each successfully submitted simulation will be marked as such and won't be resent, while allowing you to make changes to JSON files and reload them.

About

CLI to access our API and interact with our products.

Resources

License

Stars

Watchers

Forks

Contributors