Skip to main content

Python package to generate an n-dimensional case folder structure applying linear and spatial sampling strategies.

Project description

pypi versions license ci docs

farn

farn is an n-dimensional case generator.

Its primary design goal is to parameterize and execute simulation cases. However, at its core, farn is use-case agnostic and can support a wide spectrum of applications.

The name ‘farn’ is inspired by the Barnsley fractal

farn

  • runs the sampling of the design space (sampling strategies cover fixed, linSpace, uniformLHS)
  • generates the corresponding case folder structure
  • copies arbitrary files from a template folder to case folders
  • creates case specific parameter files in case folders
  • executes user-defined shell command sets in case folders
  • builds case specific OSP (co-)simulation files
  • runs simulation cases as batch process

Installation

pip install farn

farn requires the following two (sub-)packages:

  1. dictIO: foundation package, enabling farn to handle configuration files in dictIO dict file format.
  2. ospx: extension package, enabling farn to generate OSP (co-)simulation files.

However, both get installed automatically with farn (just pip install farn and you're done).

Usage Example

farn provides both an API for use inside Python as well as a CLI for shell execution of core functions.

Reading a farnDict file and creating the corresponding case folder structure:

from farn import run_farn

run_farn('farnDict', sample=True, generate=True)

The above task can also be invoked from the command line, using the 'farn' command line script installed with farn:

farn farnDict --sample --generate

For more examples and usage, please refer to farn's documentation.

Further, the farn-demo repository on GitHub is an excellent place for a jumpstart into farn. Simply clone the farn-demo repository to your local machine and click through the demos and related READMEs, by recommendation in the following sequence:

README in root folder -> guides you through installation of farn
\ospCaseBuilder Demo (see README in ospCaseBuilder folder)
\farn Demo (see README in farn folder)
\importSystemStructure  Demo (see README in importSystemStructure folder)

File Format

A farnDict is a file in dictIO dict file format used with farn.

For a documentation of the farnDict file format, see File Format in farn's documentation on GitHub Pages.

For a detailed documentation of the dictIO dict file format used by farn, see dictIO's documentation on GitHub Pages.

Development Setup

1. Install uv

This project uses uv as package manager. If you haven't already, install uv, preferably using it's "Standalone installer" method:
..on Windows:

powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"

..on MacOS and Linux:

curl -LsSf https://astral.sh/uv/install.sh | sh

(see docs.astral.sh/uv for all / alternative installation methods.)

Once installed, you can update uv to its latest version, anytime, by running:

uv self update

2. Install Python

This project requires Python 3.10 or later.
If you don't already have a compatible version installed on your machine, the probably most comfortable way to install Python is through uv:

uv python install

This will install the latest stable version of Python into the uv Python directory, i.e. as a uv-managed version of Python.

Alternatively, and if you want a standalone version of Python on your machine, you can install Python either via winget:

winget install --id Python.Python

or you can download and install Python from the python.org website.

3. Clone the repository

Clone the farn repository into your local development directory:

git clone https://github.com/dnv-opensource/farn path/to/your/dev/farn

Change into the project directory after cloning:

cd farn

4. Install dependencies

Run uv sync to create a virtual environment and install all project dependencies into it:

uv sync

Note: Using --no-dev will omit installing development dependencies.

Note: uv will create a new virtual environment called .venv in the project root directory when running uv sync the first time. Optionally, you can create your own virtual environment using e.g. uv venv, before running uv sync.

5. (Optional) Activate the virtual environment

When using uv, there is in almost all cases no longer a need to manually activate the virtual environment.
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:

uv run <command>

However, you still can manually activate the virtual environment if needed. When developing in an IDE, for instance, this can in some cases be necessary depending on your IDE settings. To manually activate the virtual environment, run one of the "known" legacy commands:
..on Windows:

.venv\Scripts\activate.bat

..on Linux:

source .venv/bin/activate

6. Install pre-commit hooks

The .pre-commit-config.yaml file in the project root directory contains a configuration for pre-commit hooks. To install the pre-commit hooks defined therein in your local git repository, run:

uv run pre-commit install

All pre-commit hooks configured in .pre-commit-config.yaml will now run each time you commit changes.

pre-commit can also manually be invoked, at anytime, using:

uv run pre-commit run --all-files

To skip the pre-commit validation on commits (e.g. when intentionally committing broken code), run:

uv run git commit -m <MSG> --no-verify

To update the hooks configured in .pre-commit-config.yaml to their newest versions, run:

uv run pre-commit autoupdate

7. Test that the installation works

To test that the installation works, run pytest in the project root folder:

uv run pytest

Meta

Copyright (c) 2026 DNV SE. All rights reserved.

Frank Lumpitzsch - @LinkedIn - frank.lumpitzsch@dnv.com

Claas Rostock - @LinkedIn - claas.rostock@dnv.com

Seunghyeon Yoo - @LinkedIn - seunghyeon.yoo@dnv.com

Distributed under the MIT license. See LICENSE for more information.

https://github.com/dnv-opensource/farn

Contributing

  1. Fork it (https://github.com/dnv-opensource/farn/fork)
  2. Create an issue in your GitHub repo
  3. Create your branch based on the issue number and type (git checkout -b issue-name)
  4. Evaluate and stage the changes you want to commit (git add -i)
  5. Commit your changes (git commit -am 'place a descriptive commit message here')
  6. Push to the branch (git push origin issue-name)
  7. Create a new Pull Request in GitHub

For your contribution, please make sure you follow the STYLEGUIDE before creating the Pull Request.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

farn-0.4.4.tar.gz (219.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

farn-0.4.4-py3-none-any.whl (36.0 kB view details)

Uploaded Python 3

File details

Details for the file farn-0.4.4.tar.gz.

File metadata

  • Download URL: farn-0.4.4.tar.gz
  • Upload date:
  • Size: 219.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for farn-0.4.4.tar.gz
Algorithm Hash digest
SHA256 d233599169df7dda56e6b413052143047edb22f8c7933d040d43fbab512c6581
MD5 ac215a808b43f322fa7acf9ae99703bb
BLAKE2b-256 7c60873af1f4734d873e9952c394c2a590dcee4dab16b4f1aef2a5f1d7bc358c

See more details on using hashes here.

Provenance

The following attestation bundles were made for farn-0.4.4.tar.gz:

Publisher: publish_release.yml on dnv-opensource/farn

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file farn-0.4.4-py3-none-any.whl.

File metadata

  • Download URL: farn-0.4.4-py3-none-any.whl
  • Upload date:
  • Size: 36.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for farn-0.4.4-py3-none-any.whl
Algorithm Hash digest
SHA256 f29f603ec0fcacb5090ffcf55550f65a377e76076145fe6dc46768f7d1e96895
MD5 2fe371fd62eaa62eb6882a24a436a4dc
BLAKE2b-256 9cb1eedd9020fc8e32053e22b70fc33fce3000a08b54e56499f603c02fc43f0f

See more details on using hashes here.

Provenance

The following attestation bundles were made for farn-0.4.4-py3-none-any.whl:

Publisher: publish_release.yml on dnv-opensource/farn

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page