Skip to content

Commit a15a1ab

Browse files
authored
Merge pull request #3 from virtualcell/api-cleanup
cleanup API error handling
2 parents bafa346 + 024951a commit a15a1ab

File tree

17 files changed

+429
-121
lines changed

17 files changed

+429
-121
lines changed

.github/workflows/on-release-main.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,16 @@ jobs:
5959
mkdir -p dist
6060
cp wheelhouse/*.whl dist/
6161
62-
- name: Publish to PyPI
62+
- name: Publish to PyPI (dry run)
6363
run: |
6464
poetry config pypi-token.pypi "${{ secrets.PYPI_TOKEN }}"
6565
poetry publish --dry-run
66+
67+
- name: Publish to PyPI (release-only - push to PyPI)
68+
run: |
69+
poetry config pypi-token.pypi "${{ secrets.PYPI_TOKEN }}"
6670
poetry publish --skip-existing
71+
if: github.event_name == 'release'
6772

6873
- name: Setup tmate
6974
if: failure()

build.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ def main() -> None:
3030
run_command(
3131
"java -agentlib:native-image-agent=config-output-dir=target/recording "
3232
"-jar target/vcell-native-1.0-SNAPSHOT.jar "
33-
"src/test/resources/TinySpacialProject_Application0.xml "
33+
"src/test/resources/TinySpatialProject_Application0.xml "
34+
"src/test/resources/TinySpatialProject_Application0.vcml "
35+
"Simulation0 "
3436
"target/sbml-input",
3537
cwd=vcell_native_dir,
3638
)

docs/modules.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
# Modules
22

3-
## libvcell.libvcell
3+
## libvcell
44

5-
::: libvcell.libvcell
5+
::: libvcell
6+
7+
# Modules
8+
9+
## libvcell
10+
11+
::: libvcell
12+
13+
### Functions
14+
15+
#### sbml_to_finite_volume_input
16+
17+
::: libvcell.solver_utils.sbml_to_finite_volume_input
18+
19+
#### vcml_to_finite_volume_input
20+
21+
::: libvcell.solver_utils.vcml_to_finite_volume_input

libvcell/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from libvcell.solver_utils import sbml_to_finite_volume_input, vcml_to_finite_volume_input
2+
3+
__all__ = ["vcml_to_finite_volume_input", "sbml_to_finite_volume_input"]

libvcell/libvcell.py

Lines changed: 0 additions & 19 deletions
This file was deleted.

libvcell/solver_utils.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
from pathlib import Path
2+
3+
from libvcell._internal.native_calls import ReturnValue, VCellNativeCalls
4+
5+
6+
def vcml_to_finite_volume_input(vcml_content: str, simulation_name: str, output_dir_path: Path) -> tuple[bool, str]:
7+
"""
8+
Convert VCML content to finite volume input files
9+
10+
Args:
11+
vcml_content (str): VCML content
12+
simulation_name (str): simulation name
13+
output_dir_path (Path): output directory path
14+
15+
Returns:
16+
tuple[bool, str]: A tuple containing the success status and a message
17+
"""
18+
native = VCellNativeCalls()
19+
return_value: ReturnValue = native.vcml_to_finite_volume_input(vcml_content, simulation_name, output_dir_path)
20+
return return_value.success, return_value.message
21+
22+
23+
def sbml_to_finite_volume_input(sbml_content: str, output_dir_path: Path) -> tuple[bool, str]:
24+
"""
25+
Convert SBML content to finite volume input files
26+
27+
Args:
28+
sbml_content (str): SBML content
29+
output_dir_path (Path): output directory path
30+
31+
Returns:
32+
tuple[bool, str]: A tuple containing the success status and a message
33+
"""
34+
native = VCellNativeCalls()
35+
return_value: ReturnValue = native.sbml_to_finite_volume_input(sbml_content, output_dir_path)
36+
return return_value.success, return_value.message

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
44

55
[tool.poetry]
66
name = "libvcell"
7-
version = "0.0.4"
7+
version = "0.0.5"
88
description = "This is a python package which wraps a subset of VCell Java code as a native python package."
99
authors = ["Jim Schaff <[email protected]>", "Ezequiel Valencia <[email protected]>"]
1010
repository = "https://github.com/virtualcell/libvcell"

scripts/build_native.sh renamed to scripts/local_build_native.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ mvn clean install
3333
# run with native-image-agent to record configuration for native-image
3434
java -agentlib:native-image-agent=config-output-dir=target/recording \
3535
-jar target/vcell-native-1.0-SNAPSHOT.jar \
36-
"$ROOT_DIR/vcell-native/src/test/resources/TinySpacialProject_Application0.xml" \
36+
"$ROOT_DIR/vcell-native/src/test/resources/TinySpatialProject_Application0.xml" \
37+
"$ROOT_DIR/vcell-native/src/test/resources/TinySpatialProject_Application0.vcml" \
38+
"Simulation0" \
3739
"$ROOT_DIR/vcell-native/target/sbml-input"
3840

3941
# build vcell-native as native shared object library

tests/test_libvcell.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
from pathlib import Path
22

3-
from libvcell.libvcell import libvcell
3+
from libvcell import sbml_to_finite_volume_input, vcml_to_finite_volume_input
44

55

66
def test_vcml_to_finite_volume_input(temp_output_dir: Path, vcml_file_path: Path, vcml_sim_name: str) -> None:
77
vcml_content = vcml_file_path.read_text()
8-
libvcell.vcml_to_finite_volume_input(
8+
success, msg = vcml_to_finite_volume_input(
99
vcml_content=vcml_content, simulation_name=vcml_sim_name, output_dir_path=temp_output_dir
1010
)
1111
assert len(list(temp_output_dir.iterdir())) > 0
12+
assert success is True
13+
assert msg == "Success"
1214

1315

1416
def test_sbml_to_finite_volume_input(temp_output_dir: Path, sbml_file_path: Path, vcml_sim_name: str) -> None:
1517
sbml_content = sbml_file_path.read_text()
16-
libvcell.sbml_to_finite_volume_input(sbml_content=sbml_content, output_dir_path=temp_output_dir)
18+
success, msg = sbml_to_finite_volume_input(sbml_content=sbml_content, output_dir_path=temp_output_dir)
1719
assert len(list(temp_output_dir.iterdir())) > 0
20+
assert success is True
21+
assert msg == "Success"

vcell-native/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<maven.compiler.source>${java.specification.version}</maven.compiler.source>
2424
<maven.compiler.target>${java.specification.version}</maven.compiler.target>
2525
<imageName>libvcell</imageName>
26-
<mainClass>org.vcell.libvcell.Entrypoints</mainClass>
26+
<mainClass>org.vcell.libvcell.MainRecorder</mainClass>
2727
</properties>
2828

2929
<dependencies>

0 commit comments

Comments
 (0)