Skip to content

Commit

Permalink
Merge pull request #12 from dnv-opensource/update-dependencies
Browse files Browse the repository at this point in the history
Update Dependencies
  • Loading branch information
ClaasRostock authored Jan 19, 2025
2 parents e57a2dc + 57747b8 commit 0e22490
Show file tree
Hide file tree
Showing 9 changed files with 204 additions and 54 deletions.
8 changes: 5 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,6 @@ cython_debug/
# PyCharm
.idea

# modules
modules.txt

# VS Code
.vscode/*
!.vscode/settings.json
Expand All @@ -154,3 +151,8 @@ modules.txt
!.vscode/extensions.json
!.vscode/*.code-snippets

# Cmake generated files
CMakeUserPresets.json

# modules
modules.txt
20 changes: 20 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: mixed-line-ending
args: [--fix=auto]
- id: trailing-whitespace
- id: check-yaml
- id: check-toml
- id: check-merge-conflict
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.9.2
hooks:
- id: ruff-format
- id: ruff
# - repo: https://github.com/pre-commit/mirrors-mypy
# rev: v1.14.1
# hooks:
# - id: mypy
exclude: '(.venv|.*_cache)/.*'
2 changes: 2 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
"sourcery.sourcery",
"njpwerner.autodocstring",
"editorconfig.editorconfig",
"ms-toolsai.jupyter",
"ms-toolsai.jupyter-renderers",
"ms-python.mypy-type-checker",
],
// List of extensions recommended by VS Code that should not be recommended for users of this workspace.
Expand Down
4 changes: 2 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"python.analysis.inlayHints.functionReturnTypes": false,
"python.analysis.inlayHints.pytestParameters": true,
"python.terminal.executeInFileDir": true,
"python.terminal.activateEnvironment": true,
"python.terminal.activateEnvironment": false,
"python.terminal.activateEnvInCurrentTerminal": false,
"python.analysis.packageIndexDepths": [
{
Expand All @@ -47,6 +47,6 @@
],
"mypy-type-checker.importStrategy": "fromEnvironment",
"mypy-type-checker.reportingScope": "workspace",
"mypy-type-checker.preferDaemon": false,
"mypy-type-checker.preferDaemon": true,
"ruff.configurationPreference": "filesystemFirst",
}
37 changes: 37 additions & 0 deletions CITATION.cff
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
title: farn-demo
version: 0.4.1
abstract: >-
Demo cases to get started with farn.
type: software
authors:
- name: DNV SE
address: 'Brooktorkai 18'
post-code: '20457'
city: Hamburg
country: DE
website: 'https://www.dnv.com/'
- given-names: Frank
family-names: Lumpitzsch
affiliation: DNV
email: [email protected]
website: 'https://www.linkedin.com/in/frank-lumpitzsch-23013196/'
- given-names: Claas
family-names: Rostock
affiliation: DNV
email: [email protected]
website: 'https://www.linkedin.com/in/claasrostock/?locale=en_US'
- given-names: Seunghyeon
family-names: Yoo
affiliation: DNV
email: [email protected]
website: 'https://www.linkedin.com/in/seunghyeon-yoo-3625173b/'
keywords:
- farn
- OSP
- fmi
license: MIT
license-url: 'https://dnv-opensource.github.io/farn/LICENSE.html'
url: 'https://dnv-opensource.github.io/farn/README.html'
repository-code: 'https://github.com/dnv-opensource/farn'
message: 'Please cite this software using these metadata.'
cff-version: 1.2.0
81 changes: 59 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# farn-demo
demo cases to get started with [farn][farn_docs]
Demo cases to get started with [farn][farn_docs].


## Development Setup
Expand Down Expand Up @@ -69,36 +69,25 @@ C:\path\of\your\choice\osp\cosim\bin
### 5. Clone the repository
Clone the farn-demo repository into your local development directory:
```sh
git clone https://github.com/dnv-innersource/farn-demo path/to/your/dev/farn-demo
git clone https://github.com/dnv-opensource/farn-demo path/to/your/dev/farn-demo
```
Change into the project directory after cloning:
```sh
cd farn-demo
```

### 6. Install dependencies
Run `uv sync` to create a virtual environment and install all project dependencies into it:
```sh
uv sync
```
> **Note**: Using `--no-dev` will omit installing development dependencies.
### 7. (Optional) Install CUDA support
Run `uv sync` with option `--extra cuda` to in addition install torch with CUDA support:
```sh
uv sync --extra cuda
```

Alternatively, you can manually install torch with CUDA support.
_Note 1_: Do this preferably _after_ running `uv sync`. That way you ensure a virtual environment exists, which is a prerequisite before you install torch with CUDA support using below `uv pip install` command.

To manually install torch with CUDA support, generate a `uv pip install` command matching your local machine's operating system using the wizard on the official [PyTorch website](https://pytorch.org/get-started/locally/).
_Note_: As we use `uv` as package manager, remember to replace `pip` in the command generated by the wizard with `uv pip`.

If you are on Windows, the resulting `uv pip install` command will most likely look something like this:
```sh
uv pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124
```
> **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`.
_Hint:_ If you are unsure which cuda version to indicate in above `uv pip install .. /cuXXX` command, you can use the shell command `nvidia-smi` on your local system to find out the cuda version supported by the current graphics driver installed on your system. When then generating the `uv pip install` command with the wizard from the [PyTorch website](https://pytorch.org/get-started/locally/), select the cuda version that matches the major version of what your graphics driver supports (major version must match, minor version may deviate).


### 8. (Optional) Activate the virtual environment
### 7. (Optional) Activate the virtual environment
When using `uv`, there is in almost all cases no longer a need to manually activate the virtual environment. <br>
`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:
```sh
Expand All @@ -117,6 +106,54 @@ To manually activate the virtual environment, run one of the "known" legacy comm
source .venv/bin/activate
```

### 8. 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:
```sh
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:
```sh
uv run pre-commit run --all-files
```

To skip the pre-commit validation on commits (e.g. when intentionally committing broken code), run:
```sh
uv run git commit -m <MSG> --no-verify
```

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

## Meta

Copyright (c) 2024 [DNV](https://www.dnv.com) SE. All rights reserved.

Frank Lumpitzsch - [@LinkedIn](https://www.linkedin.com/in/frank-lumpitzsch-23013196/) - [email protected]

Claas Rostock - [@LinkedIn](https://www.linkedin.com/in/claasrostock/?locale=en_US) - [email protected]

Seunghyeon Yoo - [@LinkedIn](https://www.linkedin.com/in/seunghyeon-yoo-3625173b/) - [email protected]

Distributed under the MIT license. See [LICENSE](LICENSE.md) for more information.

[https://github.com/dnv-opensource/farn-demo](https://github.com/dnv-opensource/farn-demo)

## Contributing

1. Fork it (<https://github.com/dnv-opensource/farn-demo/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


## farn Documentation on GitHub

Expand Down
6 changes: 3 additions & 3 deletions farn/hilbert_farnDict
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ _layers
);
_includeBoundingBox true;
_numberOfSamples 20;
// upscale re-sampling: _numberOfSamples += _numberOfSamples-1
// upscale re-sampling: _numberOfSamples += _numberOfSamples-1
_iterationDepth 5;
}
_comment 'hilbert sampling demo case dividend / (minuend - subtrahend) and filtering avoiding div_by_zero';
Expand All @@ -60,9 +60,9 @@ _layers
);
resampleRun
(
'if not exist results (if not exist *.csv (cosim run OspSystemStructure.xml -b 0 -d 10) )'
'if not exist results (if not exist *.csv (cosim run OspSystemStructure.xml -b 0 -d 10) )'
);

runjob
(
.\winjob.cmd
Expand Down
79 changes: 64 additions & 15 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,34 +1,78 @@
[project]
name = "farn-demo"
version = "0.4.0"
description = "examples of how to use the farn package."
version = "0.4.1"
description = "Demo cases to get started with farn."
readme = "README.md"
requires-python = ">= 3.10"
requires-python = ">= 3.10, < 3.14"
license = { file = "LICENSE" }
authors = [
{ name = "Frank Lumpitzsch", email = "[email protected]" },
{ name = "Claas Rostock", email = "[email protected]" },
{ name = "Seunghyeon Yoo", email = "[email protected]" },
]
maintainers = [
{ name = "Claas Rostock", email = "[email protected]" },
]
keywords = [
"farn",
"OSP",
"fmi",
]
classifiers = [
"Development Status :: 5 - Production/Stable",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX :: Linux",
"Operating System :: MacOS",
"Environment :: Console",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"Topic :: Scientific/Engineering",
"Topic :: Software Development :: Libraries :: Python Modules",
]
dependencies = [
"farn>=0.4.0",
"farn>=0.4.1",
]

[tool.uv]
dev-dependencies = [
"ruff>=0.8.3",
"pyright>=1.1.390",
"mypy>=1.13",
"sourcery>=1.27",
[project.urls]
Homepage = "https://github.com/dnv-opensource/farn"
Documentation = "https://dnv-opensource.github.io/farn/README.html"
Repository = "https://github.com/dnv-opensource/farn.git"
Issues = "https://github.com/dnv-opensource/farn/issues"
Changelog = "https://github.com/dnv-opensource/farn/blob/main/CHANGELOG.md"


[dependency-groups]
dev = [
"ruff>=0.9.2",
"pyright>=1.1.392",
"mypy>=1.14",
"sourcery>=1.31",
"pre-commit>=4.0",
"pandas-stubs>=2.2",
"types-psutil>=6.1",
"types-lxml>=2024.11",
"types-lxml>=2024.12",
]

[tool.uv]
default-groups = [
"dev",
]
native-tls = true

[tool.mypy]
plugins = [
"numpy.typing.mypy_plugin",
]
mypy_path = "stubs"
files = [
"src",
"tests",
"demos",
"farn",
"importSystemStructure",
"ospCaseBuilder",
]
exclude = [
"^src/folder_to_be_excluded/",
Expand All @@ -39,18 +83,23 @@ disable_error_code = [
"import-untyped",
]


[tool.pyright]
stubPath = "stubs"
include = [
"farn",
"importSystemStructure",
"ospCaseBuilder",
]
exclude = [
"src/folder_to_be_excluded",
]

typeCheckingMode = "basic"
useLibraryCodeForTypes = true
reportMissingParameterType = "error"
reportUnknownParameterType = "warning"
reportUnknownMemberType = "warning" # consider to set to `false` if you work a lot with matplotlib and pandas, which are both not properly typed and known to trigger this warning
reportUnknownMemberType = "warning" # consider to set to `false` if you work a lot with matplotlib and pandas, which are both not properly typed and known to trigger this warning
reportMissingTypeArgument = "error"
reportPropertyTypeMismatch = "error"
reportFunctionMemberAccess = "warning"
Expand Down
Loading

0 comments on commit 0e22490

Please sign in to comment.