{"id":50666084,"url":"https://github.com/dnv-opensource/pystclient","last_synced_at":"2026-06-08T06:30:48.480Z","repository":{"id":363052508,"uuid":"1223706481","full_name":"dnv-opensource/pystclient","owner":"dnv-opensource","description":"Python client for Simulation Trust Center stc.dnv.com","archived":false,"fork":false,"pushed_at":"2026-06-07T06:54:54.000Z","size":690,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-07T08:19:06.813Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://dnv-opensource.github.io/pystclient/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dnv-opensource.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-04-28T15:19:26.000Z","updated_at":"2026-06-03T13:57:03.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/dnv-opensource/pystclient","commit_stats":null,"previous_names":["dnv-opensource/pystclient"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/dnv-opensource/pystclient","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dnv-opensource%2Fpystclient","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dnv-opensource%2Fpystclient/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dnv-opensource%2Fpystclient/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dnv-opensource%2Fpystclient/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dnv-opensource","download_url":"https://codeload.github.com/dnv-opensource/pystclient/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dnv-opensource%2Fpystclient/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34051768,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-08T02:00:07.615Z","response_time":111,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-06-08T06:30:42.711Z","updated_at":"2026-06-08T06:30:48.472Z","avatar_url":"https://github.com/dnv-opensource.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![pypi](https://img.shields.io/pypi/v/pystclient.svg?color=blue)](https://pypi.python.org/pypi/pystclient)\r\n[![versions](https://img.shields.io/pypi/pyversions/pystclient.svg?color=blue)](https://pypi.python.org/pypi/pystclient)\r\n[![license](https://img.shields.io/pypi/l/pystclient.svg)](https://github.com/dnv-opensource/pystclient/blob/main/LICENSE)\r\n![ci](https://img.shields.io/github/actions/workflow/status/dnv-opensource/pystclient/.github%2Fworkflows%2Fnightly_build.yml?label=ci)\r\n[![docs](https://img.shields.io/github/actions/workflow/status/dnv-opensource/pystclient/.github%2Fworkflows%2Fpush_to_release.yml?label=docs)][pystclient_docs]\r\n\r\n# Pystclient - A Python client for Simulation Trust Center (STC)\r\n\r\n## Table of Contents\r\n\r\n- [Installation](#installation)\r\n- [Usage](#usage)\r\n  - [Logging in to STC](#logging-in-to-stc)\r\n  - [Running a Simulation](#running-a-simulation)\r\n  - [Fetching and Displaying Results](#fetching-and-displaying-results)\r\n  - [CLI Options](#cli-options)\r\n- [Development Setup](#development-setup)\r\n- [Meta](#meta)\r\n- [Contributing](#contributing)\r\n\r\n`pystclient` is a Python client library for **Simulation Trust Center (STC)**.\r\nIt provides a convenient, typed Python API for interacting with STC backend,\r\nso you can manage simulation projects and run simulations directly from Python\r\nscripts, notebooks, or CI pipelines without having to call the underlying\r\nHTTP API by hand.\r\n\r\n`pystclient` supports:\r\n\r\n* **Authentication** — interactive OAuth2 authorization-code flow via Veracity Identity with\r\n  automatic token caching and refresh.\r\n* **Project management** — create, configure, list, and delete STC projects;\r\n  manage their FMU model selections, parameter sets, variable connections,\r\n  and logging configuration.\r\n* **Simulator lifecycle management** — provision (create) one or more\r\n  simulators from a simulation configuration, wait for readiness, and start,\r\n  stop, or terminate them.\r\n* **Simulator control \u0026 monitoring** — query simulator status, start/stop\r\n  result recording, and gracefully end running simulations.\r\n* **Retrieving simulation data** — list per-instance measurement records,\r\n  query time-series variable data over arbitrary time windows, and iterate\r\n  through simulation results in configurable time steps.\r\n\r\n\r\n## Installation\r\n\r\n```sh\r\npip install git+https://github.com/dnv-opensource/pystclient.git\r\n```\r\n\r\n## Usage\r\n\r\n### Logging in to STC\r\n\r\n```py\r\nfrom pystclient.clients import PyStclient\r\n\r\n# Authenticate and create a client instance\r\nclient = PyStclient()\r\n\r\n# If you want to use interactive login (browser-based OAuth2):\r\nclient.authenticate()  # This will prompt for login if needed\r\n\r\n# Now you can use the client to interact with STC\r\nprojects = client.list_projects()\r\nprint(projects)\r\n```\r\n\r\n### Running a Simulation\r\n\r\nThe following example runs a **single non-interactive** distributed simulation\r\nusing a Spring-Mass-Damper project that has already been configured on the STC\r\nplatform. A simulation is non-interactive when the simulator runs to completion\r\nwithout user intervention (create → run → finish).\r\n\r\n```py\r\nimport time\r\n\r\nfrom pystclient.clients import PyStclient\r\nfrom pystclient.models import (\r\n    LoggingConfiguration,\r\n    ModelParameters,\r\n    ModelVariable,\r\n    SimulationConfig,\r\n    SimulationParameters,\r\n)\r\nfrom pystclient.types import SimulationType\r\n\r\n# 1 — Authenticate\r\nclient = PyStclient()\r\nclient.authenticate()\r\n\r\n# 2 — Select an existing project\r\nprojects = client.project.info_all()\r\nproject = next(p for p in projects if p.name == \"Spring-Mass-Damper\")\r\n\r\n# 3 — Configure simulation parameters\r\nsim_params = SimulationParameters(\r\n    base_step_size=0.01,\r\n    end_time=20,\r\n    config_name=\"Config 1\",\r\n    model_parameters=[\r\n        ModelParameters(\r\n            name=\"Mass1\",\r\n            step_size=0.02,\r\n            parameters=[ModelVariable(name=\"absTolerance\", initial_value=2e-4)],\r\n        ),\r\n        ModelParameters(\r\n            name=\"Spring1\",\r\n            parameters=[ModelVariable(name=\"absTolerance\", initial_value=2e-4)],\r\n        ),\r\n        ModelParameters(\r\n            name=\"Damper1\",\r\n            parameters=[ModelVariable(name=\"absTolerance\", initial_value=2e-4)],\r\n        ),\r\n    ],\r\n)\r\nclient.project.update_parameters(project.id, sim_params)\r\n\r\n# 4 — Enable post-plotting so results are persisted\r\nclient.project.update_log_config(\r\n    project.id, LoggingConfiguration(post_plotting=True)\r\n)\r\n\r\n# 5 — Create a non-interactive distributed simulator and wait until it is ready\r\nstatuses, future = client.simulator.create(\r\n    SimulationConfig(\r\n        project_id=project.id,\r\n        parameter_set_names=[\"Config 1\"],\r\n        type=SimulationType.DISTRIBUTED,\r\n    )\r\n)\r\nsimulator_id = statuses[0].id\r\nassert future.result(600), \"Simulator did not become ready in time!\"\r\n\r\n# 6 — Poll until the simulation finishes\r\nwhile not client.simulator.finished(simulator_id):\r\n    s = client.simulator.status(simulator_id)\r\n    print(f\"  simulation_time={s.simulation_time}  end_time={s.end_time}\")\r\n    time.sleep(1)\r\n\r\nprint(\"Simulation finished.\")\r\n```\r\n\r\n### Fetching and Displaying Results\r\n\r\nOnce a simulation has completed, you can retrieve it from the list of\r\ncompleted simulations and query time-series data for plotting with\r\n[matplotlib](https://matplotlib.org/):\r\n\r\n```py\r\nimport time\r\n\r\nimport matplotlib.pyplot as plt\r\n\r\nfrom pystclient.models import MeasurementQuery, QueryVariable, SimulationInfo\r\nfrom pystclient.types import FmuCausalityType\r\nfrom pystclient.utils.time import convert_to_timestamp\r\n\r\n# Wait for the simulation to appear in the completed list\r\ncompleted_simulations: list[SimulationInfo] = []\r\n\r\nwhile len(completed_simulations) != 1:\r\n    completed_simulations = client.project.completed_simulations(\r\n        project_id=project.id,\r\n        simulator_ids=[simulator_id],\r\n        limit=10,\r\n    )\r\n    time.sleep(5)\r\n\r\nsim = completed_simulations[0]\r\nprint(f\"Simulation {sim.id}  name={sim.name}  param_set={sim.parameter_set_name}\")\r\n\r\n# Retrieve measurements and query specific variable data\r\nsim_measurements = client.measurement.measurements(project.id, sim.id)\r\nassert sim_measurements, \"No measurements found!\"\r\n\r\nmeasurement = sim_measurements[0]\r\nq = MeasurementQuery(\r\n    variables=[\r\n        QueryVariable(\r\n            instance_name=\"Spring1\",\r\n            name=\"dis_yx\",\r\n            causality=FmuCausalityType.INPUT,\r\n        )\r\n    ],\r\n    time_from=0,\r\n    time_to=10,\r\n)\r\nresults = client.measurement.query(measurement.id, q)\r\n\r\n# Plot the displacement data\r\nfig, ax = plt.subplots(figsize=(10, 5))\r\n\r\nfor result in results:\r\n    x = convert_to_timestamp(result.x)\r\n    ax.plot(x, result.y, label=f\"{sim.parameter_set_name}\")\r\n\r\nax.set_xlabel(\"Time [s]\")\r\nax.set_ylabel(\"Displacement [m]\")\r\nax.set_title(\"Spring-Mass-Damper — Spring Displacement (dis_yx)\")\r\nax.legend()\r\nplt.tight_layout()\r\nplt.show()\r\n```\r\n\r\n\r\n\u003e **See also**: For complete, runnable notebooks check the\r\n\u003e [`examples/`](https://github.com/dnv-opensource/pystclient/tree/main/examples) directory.\r\n\r\n### CLI Options\r\n\r\nThe `pystclient` command-line interface supports the following options:\r\n\r\n| Option                | Description |\r\n|-----------------------|-------------|\r\n| `-c`, `--config \u003cfile\u003e`      | Name of the file containing the pystclient configuration. Optional. |\r\n| `--login`             | Login to Veracity Identity to retrieve and store an access token to a local cache. Mutually exclusive with `--delete-token`. Required unless `--delete-token` is used. |\r\n| `--delete-token`      | Delete an access token stored in a local cache. Mutually exclusive with `--login`. Required unless `--login` is used. |\r\n| `-q`, `--quiet`       | Console output will be quiet (sets log level to ERROR). Mutually exclusive with `--verbose`. |\r\n| `-v`, `--verbose`     | Console output will be verbose (sets log level to INFO). Mutually exclusive with `--quiet`. |\r\n| `--log \u003cfile\u003e`        | Name of log file. If specified, activates logging to file. Optional. |\r\n| `--log-level \u003clevel\u003e` | Set a specific log level for file logging. Choices: `DEBUG`, `INFO`, `WARNING`, `ERROR`, `CRITICAL`. Default: `WARNING`. |\r\n\r\n\r\n\r\n_For more examples and usage, please refer to pystclient's [documentation][pystclient_docs]._\r\n\r\n\r\n## Development Setup\r\n\r\n### 1. Install uv\r\nThis project uses `uv` as package manager.\r\nIf you haven't already, install [uv](https://docs.astral.sh/uv), preferably using it's [\"Standalone installer\"](https://docs.astral.sh/uv/getting-started/installation/#__tabbed_1_2) method: \u003cbr\u003e\r\n..on Windows:\r\n```sh\r\npowershell -ExecutionPolicy ByPass -c \"irm https://astral.sh/uv/install.ps1 | iex\"\r\n```\r\n..on MacOS and Linux:\r\n```sh\r\ncurl -LsSf https://astral.sh/uv/install.sh | sh\r\n```\r\n(see [docs.astral.sh/uv](https://docs.astral.sh/uv/getting-started/installation/) for all / alternative installation methods.)\r\n\r\nOnce installed, you can update `uv` to its latest version, anytime, by running:\r\n```sh\r\nuv self update\r\n```\r\n\r\n### 2. Clone the repository\r\nClone the pystclient repository into your local development directory:\r\n```sh\r\ngit clone https://github.com/dnv-opensource/pystclient path/to/your/dev/pystclient\r\n```\r\nChange into the project directory after cloning:\r\n```sh\r\ncd pystclient\r\n```\r\n\r\n### 3. Install dependencies\r\nRun `uv sync -U` to create a virtual environment and install all project dependencies into it:\r\n```sh\r\nuv sync -U\r\n```\r\n\u003e **Note**: Using `--no-dev` will omit installing development dependencies.\r\n\r\n\u003e **Explanation**: The `-U` option stands for `--update`. It forces `uv` to fetch and install the latest versions of all dependencies,\r\n\u003e ensuring that your environment is up-to-date.\r\n\r\n\u003e **Note**: `uv` will create a new virtual environment called `.venv` in the project root directory when running\r\n\u003e `uv sync -U` the first time. Optionally, you can create your own virtual environment using e.g. `uv venv`, before running\r\n\u003e `uv sync -U`.\r\n\r\n### 4. (Optional) Activate the virtual environment\r\nWhen using `uv`, there is in almost all cases no longer a need to manually activate the virtual environment. \u003cbr\u003e\r\n`uv` will find the `.venv` virtual environment in the working directory or any parent directory, and activate it on the fly whenever you run a command via `uv` inside your project folder structure:\r\n```sh\r\nuv run \u003ccommand\u003e\r\n```\r\n\r\nHowever, you still _can_ manually activate the virtual environment if needed.\r\nWhen developing in an IDE, for instance, this can in some cases be necessary depending on your IDE settings.\r\nTo manually activate the virtual environment, run one of the \"known\" legacy commands: \u003cbr\u003e\r\n..on Windows:\r\n```sh\r\n.venv\\Scripts\\activate.bat\r\n```\r\n..on Linux:\r\n```sh\r\nsource .venv/bin/activate\r\n```\r\n\r\n### 5. Install pre-commit hooks\r\nThe `.pre-commit-config.yaml` file in the project root directory contains a configuration for pre-commit hooks.\r\nTo install the pre-commit hooks defined therein in your local git repository, run:\r\n```sh\r\nuv run pre-commit install\r\n```\r\n\r\nAll pre-commit hooks configured in `.pre-commit-config.yaml` will now run each time you commit changes.\r\n\r\npre-commit can also manually be invoked, at anytime, using:\r\n```sh\r\nuv run pre-commit run --all-files\r\n```\r\n\r\nTo skip the pre-commit validation on commits (e.g. when intentionally committing broken code), run:\r\n```sh\r\nuv run git commit -m \u003cMSG\u003e --no-verify\r\n```\r\n\r\nTo update the hooks configured in `.pre-commit-config.yaml` to their newest versions, run:\r\n```sh\r\nuv run pre-commit autoupdate\r\n```\r\n\r\n### 6. Test that the installation works\r\nTo test that the installation works, run pytest in the project root folder:\r\n```sh\r\nuv run pytest\r\n```\r\n\r\n### 7. Generating the third-party license file\r\n\r\nA `THIRD_PARTY_LICENSES` file that aggregates the license texts of all\r\nruntime dependencies can be generated by running:\r\n\r\n```sh\r\npip-licenses --with-license-file --no-license-path --output-file THIRD_PARTY_LICENSES\r\n```\r\n\r\n\u003e **Note**: `pip-licenses` reports licenses of packages that are *installed*\r\n\u003e in the current environment. Make sure your project dependencies are\r\n\u003e installed (e.g. via `uv sync`) before running the command, otherwise the\r\n\u003e generated file will be empty or incomplete.\r\n\r\nUsing `uv`:\r\n\r\n```sh\r\nuv run pip-licenses --with-license-file --no-license-path --output-file THIRD_PARTY_LICENSES\r\n```\r\n\r\n\r\n## License\r\n\r\nThis project is licensed under the Mozilla Public License, v. 2.0 (MPL‑2.0).\r\n\r\nA copy of the license is included in the [LICENSE](LICENSE.md) file.\r\nYou may also obtain a copy at https://mozilla.org/MPL/2.0/.\r\n\r\n## Meta\r\n\r\nCopyright (c) 2026 [DNV](https://www.dnv.com) AS. All rights reserved.\r\n\r\npystclient is developed by DNV Group Research and Development in collaboration with DNV Maritime.\r\n\r\nAll code in pystclient is DNV intellectual property of DNV.\r\n\r\nHee Jong Park - [@LinkedIn](https://www.linkedin.com/in/heejongpark/) - hee.jong.park@dnv.com\r\n\r\nClaas Rostock - [@LinkedIn](https://www.linkedin.com/in/claasrostock/?locale=en_US) - claas.rostock@dnv.com\r\n\r\n## Contributing\r\n\r\n1. Fork it (\u003chttps://github.com/dnv-opensource/pystclient/fork\u003e)\r\n2. Create an issue in your GitHub repo\r\n3. Create your branch based on the issue number and type (`git checkout -b issue-name`)\r\n4. Evaluate and stage the changes you want to commit (`git add -i`)\r\n5. Commit your changes (`git commit -am 'place a descriptive commit message here'`)\r\n6. Push to the branch (`git push origin issue-name`)\r\n7. Create a new Pull Request in GitHub\r\n\r\nFor your contribution, please make sure you follow the [STYLEGUIDE](STYLEGUIDE.md) before creating the Pull Request.\r\n\r\n\u003c!-- Markdown link \u0026 img dfn's --\u003e\r\n[pystclient_docs]: https://dnv-opensource.github.io/pystclient/README.html\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdnv-opensource%2Fpystclient","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdnv-opensource%2Fpystclient","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdnv-opensource%2Fpystclient/lists"}