connectors-template

A template repository for creating new Connectors to add Simvue tracking functionality to Non-Python simulations.

https://github.com/simvue-io/connectors-template

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (16.7%) to scientific vocabulary
Last synced: 6 months ago · JSON representation ·

Repository

A template repository for creating new Connectors to add Simvue tracking functionality to Non-Python simulations.

Basic Info
  • Host: GitHub
  • Owner: simvue-io
  • License: apache-2.0
  • Language: Python
  • Default Branch: main
  • Size: 82 KB
Statistics
  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • Open Issues: 1
  • Releases: 0
Created 12 months ago · Last pushed 12 months ago
Metadata Files
Readme Changelog Contributing License Citation

README.md

Simvue Connectors - Template


Simvue

This is a template repository which allows you to quickly create new Connectors which provide Simvue tracking and monitoring functionality to Non-Python simulations.

WebsiteDocumentation

How to use this template

Naming your connector

First, make a name for your new connector. Typically, the module name is of the form simvue-{software_name}, and the connector class itself is of the form {SoftwareName}Run. Update the pyproject.toml file with the name of your module, and also update the directory currently called simvue_template with your module name.

Creating the code

Your connector class should be made in the connector.py file inside your module, with any extra functionality which it needs to work (but you don't want inside the class itself) put in files inside the extras directory. The connector should inherit from the WrappedRun class provided by the simvue-connector module, and should use multiparser to track and parse output files as they are being written. See an example in the connectors-generic repository, or check out any of our premade connectors for ideas:

Also look at the CONTRIBUTING.md file for expected coding standards.

Writing examples

In the examples directory, please provide at least one example of your connector being used to track your simulation software. Create this example inside a function so that it can be used in the integration tests. If your software is difficult to install, you may want to provide setup instructions for using a Docker container or similar, as well as instructions assuming that the software is already installed on the user's system.

Writing tests

You should create two types of tests:

  • Unit tests: Check each element of your connector independently, such as file parsers and callbacks, each method etc. You should use pytest, and use Mockers to mock out any functionality which your simulation software would typically provide so that the simulation software itself is not required to run these tests.
  • Integration tests: These check the end-to-end functionality of your connector when used with the actual simulation software. You should parametrize the test to include offline mode, as well as online. You can use the example(s) which you created earlier as the basis for these tests.

CI Workflows

Inside the .github directory, there are a number of workflows already created. You should adit these to work for your connector. They include:

  • test_macos, test_ubuntu, test_windows: These run the unit tests, should not need to be altered
  • test_integration: These run the integration tests, you will need to provide a docker container to use and whatever installation steps are required for your case
  • deploy: Automates deployment to test-PyPI and PyPI for tagged releases (see below). You need to update the module names in this file - search for 'your-module-name' and replace as required.

Deployment

When you are happy with your connector and are ready to deploy it to PyPI for the first time, you need to do the following:

  • Install poetry and twine if you haven't already: pip install poetry twine
  • Check your pyproject.toml file is valid by running poetry check
  • Install your module: poetry install
  • Build the distribution: poetry build
  • Go to test.pypi.org, create an account, and get a token
  • Upload your package with Twine: twine upload -r testpypi dist/*
  • Enter the token when prompted
  • Go to https://test.pypi.org/project/{your-package-name}, check it has been published
  • Click 'Manage Project'
  • If you wish to enable automatic deployments, click 'Publishing' -> 'Add a new publisher' and fill in the details for your repository, setting Workflow name to deploy.yaml and Environment name to test_pypi

If this was all successful, repeat with the real PyPI instance at pypi.org, using twine upload dist/*, and setting the Environment name in the publisher settings to pypi.

From now on, you can do deployments automatically. Simply:

  • Update the pyproject.toml with a new version number, eg v1.0.1
  • Update the CHANGELOG to reflect your newest changes
  • Tag a branch with a semantic version number, eg git tag v1.0.1
  • Push the tag: git push origin v1.0.1

This should automatically start the deployment workflow - check that it completes successfully on the Github UI.

Updating the README

When finished, delete all of the information above under the 'How to use this template' heading. Then update the information below to be relevant for your connector:

Implementation

{List here how your Connector works, and the things about the simulation it tracks by default.}

Installation

To install and use this connector, first create a virtual environment: python -m venv venv Then activate it: source venv/bin/activate And then use pip to install this module: pip install {your_module_name_here}

Configuration

The service URL and token can be defined as environment variables: sh export SIMVUE_URL=... export SIMVUE_TOKEN=... or a file simvue.toml can be created containing: toml [server] url = "..." token = "..." The exact contents of both of the above options can be obtained directly by clicking the Create new run button on the web UI. Note that the environment variables have preference over the config file.

Usage example

{Replace the example below with a similar example exhibiting how to use your Connector. The example for the FDS (Fire Dynamics Simulator) connector is given below:}

```python from simvue_fds.connector import FDSRun

...

if name == "main":

...

# Using a context manager means that the status will be set to completed automatically,
# and also means that if the code exits with an exception this will be reported to Simvue
with FDSRun() as run:

    # Specify a run name, along with any other optional parameters:
    run.init(
      name = 'my-fds-simulation',                                   # Run name
      metadata = {'number_fires': 3},                               # Metadata
      tags = ['fds', 'multiple-fires'],                             # Tags
      description = 'FDS simulation of fires in a parking garage.', # Description
      folder = '/fds/parking-garage/trial_1'                        # Folder path
    )

    # Set folder details if necessary
    run.set_folder_details(
      metadata = {'simulation_type': 'parking_garage'},             # Metadata
      tags = ['fds'],                                               # Tags
      description = 'FDS simulations with fires in different areas' # Description
    )

    # Can use the base Simvue Run() methods to upload extra information, eg:
    run.save_file(os.path.abspath(__file__), "code")

    # Can add alerts specific to your simulation, eg:
    run.create_metric_threshold_alert(
      name="visibility_below_five_metres",    # Name of Alert
      metric="eye_level_visibility",          # Metric to monitor
      frequency=1,                            # Frequency to evaluate rule at (mins)
      rule="is below",                        # Rule to alert on
      threshold=5,                            # Threshold to alert on
      notification='email',                   # Notification type
      trigger_abort=True                      # Abort simulation if triggered
    )

    # Launch the FDS simulation
    run.launch(
        fds_input_path='path/to/my/input_file.i',   # Path to your FDS input file
        workdir_path='path/to/my/results_dir',      # Path where results should be created
        run_in_parallel=True,                       # Whether to run in parallel using MPI
        num_processors=2                            # Number of cores to use if in parallel

        )

```

License

Released under the terms of the Apache 2 license.

Citation

To reference Simvue, please use the information outlined in this citation file.

Owner

  • Name: simvue
  • Login: simvue-io
  • Kind: organization
  • Location: United Kingdom

Citation (CITATION.cff)

# This CITATION.cff file was generated with cffinit.
# Visit https://bit.ly/cffinit to generate yours today!

cff-version: 1.2.0
title: Simvue
message: >-
  If you use this software, please cite it using the
  metadata from this file.
type: software
authors:
  - given-names: Andrew
    family-names: Lahiff
    affiliation: United Kingdom Atomic Energy Authority
    orcid: 'https://orcid.org/0000-0002-2785-4116'
  - given-names: Aby
    family-names: Abraham
    affiliation: United Kingdom Atomic Energy Authority
  - given-names: Vignesh
    family-names: Gopakumar
    orcid: 'https://orcid.org/0000-0002-6773-1049'
    affiliation: United Kingdom Atomic Energy Authority
  - given-names: Kristian
    family-names: Zarebski
    affiliation: United Kingdom Atomic Energy Authority
    orcid: 'https://orcid.org/0000-0002-6773-1049'
  - given-names: Matthew
    family-names: Field
    affiliation: United Kingdom Atomic Energy Authority
  - given-names: James
    family-names: Panayis
    affiliation: United Kingdom Atomic Energy Authority
repository-code: 'https://github.com/simvue-io/client'
url: 'https://simvue.io/'
abstract: >-
  Simvue allows users to organise and gain insights in simulations,
  processing tasks and AI/ML training by capturing metadata and
  data combined with real-time monitoring, logging and alerting.
keywords:
  - tracking
  - monitoring
  - metrics
  - alerting
  - simulation
license: Apache-2.0
commit: 64ff8a5344232d44fc7da5b6ff601d3023497977
version: 2.0.0a3
date-released: '2025-03-04'

GitHub Events

Total
  • Issues event: 1
  • Push event: 8
  • Public event: 1
  • Create event: 2
Last Year
  • Issues event: 1
  • Push event: 8
  • Public event: 1
  • Create event: 2

Dependencies

.github/workflows/deploy.yaml actions
  • actions/checkout v4 composite
  • actions/download-artifact v4 composite
  • actions/setup-python v5 composite
  • actions/upload-artifact v4 composite
  • pypa/gh-action-pypi-publish release/v1 composite
  • sigstore/gh-action-sigstore-python v3.0.0 composite
.github/workflows/test_integration.yml actions
  • actions/checkout v4 composite
  • actions/setup-python v5 composite
.github/workflows/test_macos.yml actions
  • actions/checkout v4 composite
  • actions/setup-python v5 composite
.github/workflows/test_ubuntu.yml actions
  • actions/checkout v4 composite
  • actions/setup-python v5 composite
.github/workflows/test_windows.yml actions
  • actions/checkout v4 composite
  • actions/setup-python v5 composite
poetry.lock pypi
  • annotated-types 0.7.0
  • anyio 4.8.0
  • arrow 1.3.0
  • certifi 2025.1.31
  • cffi 1.17.1
  • charset-normalizer 3.4.1
  • click 8.1.8
  • codecarbon 2.8.3
  • colorama 0.4.6
  • cryptography 44.0.2
  • deepmerge 2.0
  • dnspython 2.7.0
  • email-validator 2.2.0
  • exceptiongroup 1.2.2
  • f90nml 1.4.4
  • fief-client 0.20.0
  • fire 0.7.0
  • flatdict 4.0.1
  • gitdb 4.0.12
  • gitpython 3.1.44
  • h11 0.14.0
  • httpcore 1.0.7
  • httpx 0.27.2
  • humanfriendly 10.0
  • idna 3.10
  • iniconfig 2.0.0
  • jwcrypto 1.5.6
  • loguru 0.7.3
  • markdown-it-py 3.0.0
  • mdurl 0.1.2
  • msgpack 1.1.0
  • numpy 2.2.3
  • nvidia-ml-py 12.570.86
  • packaging 24.2
  • pandas 2.2.3
  • pluggy 1.5.0
  • prometheus-client 0.21.1
  • prompt-toolkit 3.0.50
  • psutil 6.1.1
  • py-cpuinfo 9.0.0
  • pycparser 2.22
  • pydantic 2.10.6
  • pydantic-core 2.27.2
  • pygments 2.19.1
  • pyjwt 2.10.1
  • pynvml 12.0.0
  • pyreadline3 3.5.4
  • pytest 8.3.5
  • python-dateutil 2.9.0.post0
  • pytz 2025.1
  • pyyaml 6.0.2
  • questionary 2.1.0
  • randomname 0.2.1
  • rapidfuzz 3.12.2
  • requests 2.32.3
  • rich 13.9.4
  • semver 3.0.4
  • shellingham 1.5.4
  • simvue 2.0.0a3
  • simvue-connector 1.0.0a2
  • six 1.17.0
  • smmap 5.0.2
  • sniffio 1.3.1
  • tabulate 0.9.0
  • tenacity 9.0.0
  • termcolor 2.5.0
  • toml 0.10.2
  • tomli 2.2.1
  • typer 0.15.2
  • types-python-dateutil 2.9.0.20241206
  • typing-extensions 4.12.2
  • tzdata 2025.1
  • ukaea-multiparser 1.0.4
  • urllib3 2.3.0
  • wcwidth 0.2.13
  • win32-setctime 1.2.0
  • yaspin 3.0.1
pyproject.toml pypi
  • pytest ^8.3.3 develop
  • f90nml (>1.4.3)
  • simvue-connector (==1.0.0a2)