Skip to content
Open
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
d923afb
feat: Add JAR files as runtime dependencies to pyhton package.
mheggelund Nov 14, 2025
e7f845a
chore: Implement cache to aviod rate limiting.
mheggelund Nov 21, 2025
5c27b8e
chore: Cleanup and make prod ready.
mheggelund Dec 4, 2025
cd68986
chore: yaml linting + remove macOS syntax
MarcusDragsten Dec 4, 2025
8edf653
chore: changed method name and moved import
MarcusDragsten Dec 5, 2025
aa14af6
refactor: ensure cleanup of temp folder
MarcusDragsten Dec 5, 2025
08e4fa5
fix: forgot to updare all JAR names
MarcusDragsten Dec 5, 2025
ba24933
chore: yaml linting
MarcusDragsten Dec 5, 2025
fd82fe5
fix: removed unnecessary comment + outdated logging
MarcusDragsten Dec 5, 2025
3548944
chore: removed unnecessary comments
MarcusDragsten Dec 5, 2025
760d442
test publishing package
MarcusDragsten Dec 5, 2025
7ff6e84
chore: move import statement
MarcusDragsten Dec 5, 2025
d7f2074
chore: Safer error string
MarcusDragsten Dec 5, 2025
ce0d3db
chore: removed top level comments
MarcusDragsten Dec 5, 2025
ff62094
chore: pre-commit lint
MarcusDragsten Dec 5, 2025
4a2714d
docs: readme saying that we use poetry install
MarcusDragsten Dec 5, 2025
4ffa927
chore: trimmed down comments
MarcusDragsten Dec 5, 2025
0678ca1
refactor: remove default fallback to java11 if no version
MarcusDragsten Dec 5, 2025
264b3ac
chore: pre-commit
MarcusDragsten Dec 5, 2025
4c35be4
debug
MarcusDragsten Dec 5, 2025
18fafba
feat: if version 0, default to version 11 for stubs
MarcusDragsten Dec 5, 2025
6532057
test: removed fallback version (11) in tests
MarcusDragsten Dec 5, 2025
68d2ae9
chore: comment on versioning
MarcusDragsten Dec 5, 2025
21f8eb3
chore: copilot comments
MarcusDragsten Dec 8, 2025
b49d0f4
feat: dont send slack message if package exists
MarcusDragsten Dec 8, 2025
f51f31c
feat: more validation for sending slack msg
MarcusDragsten Dec 8, 2025
4bf1094
chore: pypi_version in slack message
MarcusDragsten Dec 8, 2025
66af564
feat: use pypa for publishing
matsklevstad Dec 8, 2025
59ab8dd
fix: update package name to jneqsim
matsklevstad Dec 8, 2025
4c19d86
fix: update from jneqsimsmall in tests
matsklevstad Dec 8, 2025
9b62fc0
feat: remove check for publish as its not needed anymore
matsklevstad Dec 8, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/nightly-run.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ on:
workflow_dispatch:
schedule:
# Runs at 03:00 UTC on every day-of-week
- cron: '0 3 * * *'
- cron: "0 3 * * *"
permissions:
contents: read
jobs:
Expand Down Expand Up @@ -58,7 +58,6 @@ jobs:
secrets:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}


# Keeps the scheduled workflow from becoming disabled because of "no repo activity"
workflow-keepalive:
if: github.event_name == 'schedule'
Expand Down
41 changes: 28 additions & 13 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,8 @@ jobs:
python-version: "3.10"
cache: "poetry"

- name: Download JAR
run: |
VERSION=${{inputs.version}}
wget --output-document "jneqsim/neqsim-Java11.jar" "https://github.com/equinor/neqsim/releases/download/v$VERSION/neqsim-$VERSION.jar"
wget --output-document "jneqsim/neqsim-Java8.jar" "https://github.com/equinor/neqsim/releases/download/v$VERSION/neqsim-$VERSION-Java8.jar"
wget --output-document "jneqsim/neqsim-Java21.jar" "https://github.com/equinor/neqsim/releases/download/v$VERSION/neqsim-$VERSION-Java21.jar"
echo "Wrote JAR to jneqsim/neqsim-Java*.jar"
- name: Install build tools
run: pip install build hatch

- name: Install deps
run: poetry install --no-interaction
Expand All @@ -53,7 +48,26 @@ jobs:
run: poetry run python ./generate_stubs.py

- name: Fixup module naming
run: find jneqsim/neqsim -type f -name "*.pyi" -print0 | xargs -0 sed -i '' -e 's/neqsim./jneqsim.neqsim./g' || true
run: find jneqsim/neqsim -type f -name "*.pyi" -print0 | xargs -0 sed -i -e 's/neqsim./jneqsim.neqsim./g' || true

- name: Update NeqSim dependency version
run: |
NEQSIM_VERSION="${{ inputs.version }}"
echo "Updating NeqSim dependency to version '$NEQSIM_VERSION'"

# Get the current version to use as fallback
CURRENT_VERSION=$(grep -o 'version: "[^"]*"' jneqsim/dependencies.yaml | head -1 | sed 's/version: "\(.*\)"/\1/')
echo "Current version (will become fallback): '$CURRENT_VERSION'"
echo "New version: '$NEQSIM_VERSION'"

# Update the main version to the new version
sed -i 's/version: "[^"]*"/version: "'"$NEQSIM_VERSION"'"/' jneqsim/dependencies.yaml

# Set fallback version to the previous version (current before update)
sed -i 's/fallback_version: "[^"]*"/fallback_version: "'"$CURRENT_VERSION"'"/' jneqsim/dependencies.yaml

echo "Updated dependencies.yaml:"
grep -A 10 -B 5 "version:" jneqsim/dependencies.yaml

- name: Bump version
run: |
Expand All @@ -70,13 +84,14 @@ jobs:
cd tests
python -m venv .venv
source .venv/bin/activate
pip install ../dist/jneqsim-*.tar.gz pytest
pip install ../dist/jneqsimsmall-*.tar.gz pytest
pytest

- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
attestations: false
- name: Publish package to TestPyPI
run: hatch publish -r test
env:
HATCH_INDEX_USER: __token__
HATCH_INDEX_AUTH: ${{ secrets.TEST_PYPI_TOKEN_MAOHE }}
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Breaking change: Publishing to TestPyPI instead of PyPI. This appears to be a testing/development change that shouldn't be in a production release. The original code published to PyPI, but now it publishes to TestPyPI with a personal token (TEST_PYPI_TOKEN_MAOHE). This should either be reverted to publish to PyPI, or this should be documented as a temporary testing workflow.

Suggested change
- name: Publish package to TestPyPI
run: hatch publish -r test
env:
HATCH_INDEX_USER: __token__
HATCH_INDEX_AUTH: ${{ secrets.TEST_PYPI_TOKEN_MAOHE }}
- name: Publish package to PyPI
run: hatch publish
env:
HATCH_INDEX_USER: __token__
HATCH_INDEX_AUTH: ${{ secrets.PYPI_TOKEN }}

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will change this before merging!


- name: Notify publish success to Slack
if: ${{ success() }}
Expand Down
23 changes: 7 additions & 16 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
uses: actions/[email protected]
with:
python-version: "3.9"
cache: 'poetry'
cache: "poetry"

- name: Check pyproject.toml validity
run: poetry check --no-interaction
Expand All @@ -42,19 +42,10 @@ jobs:
uses: actions/[email protected]
with:
python-version: "3.12"
cache: 'poetry'
cache: "poetry"
- name: Install deps
run: poetry install --no-interaction

- name: Download JAR
run: |
VERSION=$(curl -L -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/repos/equinor/neqsim/releases/latest | jq '.tag_name' --raw-output)
VERSION="${VERSION:1}"
wget --output-document "jneqsim/neqsim-Java11.jar" "https://github.com/equinor/neqsim/releases/download/v$VERSION/neqsim-$VERSION.jar"
wget --output-document "jneqsim/neqsim-Java8.jar" "https://github.com/equinor/neqsim/releases/download/v$VERSION/neqsim-$VERSION-Java8.jar"
wget --output-document "jneqsim/neqsim-Java21.jar" "https://github.com/equinor/neqsim/releases/download/v$VERSION/neqsim-$VERSION-Java21.jar"
echo "Wrote JAR to jneqsim/neqsim-Java*.jar"

- name: Generate stubs
run: poetry run python ./generate_stubs.py

Expand All @@ -68,22 +59,22 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: jneqsim-test-package
path: ./dist/jneqsim-0.0.0.tar.gz
path: ./dist/jneqsimsmall-0.0.0.tar.gz

integration:
runs-on: ubuntu-latest
needs: build
strategy:
matrix:
java: [ '11', '17', '21' ]
java: ["8", "11", "17", "21"]
name: Java ${{ matrix.Java }}
steps:
- uses: actions/checkout@v4

- name: Setup java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
distribution: "temurin"
java-version: ${{ matrix.java }}

- name: Download dist artifact
Expand All @@ -96,5 +87,5 @@ jobs:
cd tests
python -m venv .venv
source .venv/bin/activate
pip install ../jneqsim-0.0.0.tar.gz pytest
pytest
pip install ../jneqsimsmall-0.0.0.tar.gz pytest
pytest
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

jpype-stubs
neqsim.jar
*.jar

# Test environments
test_venv/
venv/
env/

# Cache directories
.cache/

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,41 @@ def pressurize_gas():

- [jpype](https://jpype.readthedocs.io/en/latest/index.html#)

## Version Management

jneqsim uses a controlled release process to ensure compatibility:

- **Pinned Versions**: Each jneqsim release is pinned to a specific, tested NeqSim JAR version
- **Automated Updates**: The nightly CI workflow automatically checks for new NeqSim releases and publishes updated jneqsim packages when available
- **No Auto-Updates**: Applications using jneqsim will not automatically download newer NeqSim versions - they use the tested version that comes with their installed jneqsim package
- **Cache Management**: Downloaded JARs are cached locally in `~/.jneqsim/cache` for faster subsequent usage

## Development

### Running Tests

The project uses pytest with custom markers to categorize tests. Test dependencies are already included in the development dependencies.

```bash
# Install development dependencies (includes pytest and pytest-mock)
poetry install

# Run unit tests (fast, excludes tests marked as slow)
pytest -v -m "not slow" tests/

# Run all tests (may download JARs for integration tests)
pytest -v tests/

# Run with coverage (requires pytest-cov)
pip install pytest-cov
pytest --cov=jneqsim --cov-report=html tests/
```

**Test markers:**
- `slow`: Tests that may download files or take longer to run
- `integration`: Integration tests that require external dependencies
- `unit`: Fast unit tests (default)


<a id="Contributing"></a>

Expand Down
36 changes: 36 additions & 0 deletions jneqsim/dependencies.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# NeqSim Dependency Configuration
# This file defines how to resolve NeqSim Java dependencies

neqsim:
# Version to use (specific version that has been tested with this jneqsim release)
# This version is automatically updated by the CI/CD pipeline when a new NeqSim release is published
version: "3.0.43"

# Fallback version when GitHub API is unavailable (rate limited, network issues)
# This should be the previous tested version, providing a safety fallback mechanism
# The CI/CD pipeline automatically sets this to the previous version when updating
fallback_version: "3.0.42"

# GitHub Releases source
sources:
github:
enabled: true
repository: "equinor/neqsim"
base_url: "https://github.com/equinor/neqsim/releases/download"
# JAR file patterns for different Java versions
# Note: The code will try multiple naming patterns per Java version
# (e.g., Java21-Java21, Java21) to handle variations
assets:
java8: "neqsim-{version}-Java8.jar"
java11: "neqsim-{version}.jar" # Java 11+ version
java21: "neqsim-{version}-Java21.jar"

# Logging configuration
logging:
level: "INFO" # DEBUG, INFO, WARNING, ERROR
show_progress: true

# Cache stores one JAR file per version/Java version combination
cache:
enabled: true
verify_integrity: true
Loading
Loading