Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ repos:
name: Check valid YAML syntax
- id: end-of-file-fixer
name: Check for newline at end of file
exclude: '^LICENSE$'
exclude: "^LICENSE$"
- id: debug-statements
name: Check for debugger imports
- id: trailing-whitespace
Expand All @@ -35,7 +35,7 @@ repos:
hooks:
- id: docformatter
name: Run docformatter (formatter for docstrings)
args: ["--in-place", "--config=./pyproject.toml", "-r", "src/fourc_webviewer/", "test/"]
args: ["--in-place", "--config=./pyproject.toml", "-r", "src/fourc_webviewer/", "tests/"]
- repo: https://github.com/econchick/interrogate
rev: 1.7.0
hooks:
Expand Down
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,9 @@ dependencies = { file = ["requirements.txt"] }

[tool.setuptools]
package-dir = { "" = "src" }

# External tools
[tool.pytest.ini_options]
testpaths = ["tests"]
addopts = '-m "not gui"' # deactivate tests that require a GUI
markers = ["gui: Tests that require a GUI."]
4 changes: 4 additions & 0 deletions requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@ numpy
# include fourcipp from github
git+https://github.com/4C-multiphysics/fourcipp.git
lnmmeshio>=5.6.3

# development
pytest
pre-commit
68 changes: 61 additions & 7 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ attrs==25.3.0
# fourcipp
# jsonschema
# referencing
certifi==2025.4.26
# via requests
cfgv==3.4.0
# via pre-commit
charset-normalizer==3.4.2
# via requests
contourpy==1.3.2
# via matplotlib
cycler==0.12.1
Expand All @@ -24,6 +30,10 @@ deprecation==2.1.0
# via
# fourcipp
# rapidyaml
distlib==0.3.9
# via virtualenv
filelock==3.18.0
# via virtualenv
fonttools==4.57.0
# via matplotlib
fourcipp @ git+https://github.com/4C-multiphysics/fourcipp.git
Expand All @@ -32,8 +42,14 @@ frozenlist==1.6.0
# via
# aiohttp
# aiosignal
identify==2.6.10
# via pre-commit
idna==3.10
# via yarl
# via
# requests
# yarl
iniconfig==2.1.0
# via pytest
jsonschema==4.23.0
# via fourcipp
jsonschema-rs==0.30.0
Expand All @@ -47,11 +63,15 @@ kiwisolver==1.4.8
lnmmeshio==5.6.3
# via -r requirements.in
loguru==0.7.3
# via fourcipp
# via
# fourcipp
# lnmmeshio
markdown-it-py==3.0.0
# via rich
matplotlib==3.10.1
# via vtk
# via
# pyvista
# vtk
mdurl==0.1.2
# via markdown-it-py
meshio==5.3.5
Expand All @@ -66,6 +86,8 @@ multidict==6.4.3
# yarl
narwhals==1.38.0
# via plotly
nodeenv==1.9.1
# via pre-commit
numpy==2.2.5
# via
# -r requirements.in
Expand All @@ -75,22 +97,35 @@ numpy==2.2.5
# matplotlib
# meshio
# pandas
# pyvista
packaging==25.0
# via
# deprecation
# fourcipp
# matplotlib
# plotly
# pooch
# pytest
pandas==2.2.3
# via -r requirements.in
pillow==11.2.1
# via matplotlib
# via
# matplotlib
# pyvista
platformdirs==4.3.8
# via
# pooch
# virtualenv
plotly==6.0.1
# via
# -r requirements.in
# trame-plotly
progress==1.6
# via lnmmeshio
pluggy==1.6.0
# via pytest
pooch==1.8.2
# via pyvista
pre-commit==4.2.0
# via -r requirements.in
propcache==0.3.1
# via
# aiohttp
Expand All @@ -99,6 +134,8 @@ pygments==2.19.1
# via rich
pyparsing==3.2.3
# via matplotlib
pytest==8.3.5
# via -r requirements.in
python-dateutil==2.9.0.post0
# via
# matplotlib
Expand All @@ -112,12 +149,18 @@ pyvista==0.45.0
pyyaml==6.0.2
# via trame
rapidyaml==0.9.0
# via
# lnmmeshio
# pre-commit
# trame
# via fourcipp
referencing==0.36.2
# via
# fourcipp
# jsonschema
# jsonschema-specifications
requests==2.32.3
# via pooch
rich==14.0.0
# via meshio
rpds-py==0.24.0
Expand All @@ -131,8 +174,12 @@ ruamel-yaml-clib==0.2.12
# via
# fourcipp
# ruamel-yaml
scooby==0.10.1
# via pyvista
six==1.17.0
# via python-dateutil
tqdm==4.66.5
# via lnmmeshio
trame==3.9.0
# via -r requirements.in
trame-client==3.8.2
Expand Down Expand Up @@ -160,11 +207,18 @@ typing-extensions==4.13.2
# via
# fourcipp
# python-utils
# pyvista
# referencing
tzdata==2025.2
# via pandas
urllib3==2.4.0
# via requests
virtualenv==20.31.2
# via pre-commit
vtk==9.4.2
# via -r requirements.in
# via
# -r requirements.in
# pyvista
wslink==2.3.3
# via
# trame
Expand Down
8 changes: 6 additions & 2 deletions src/fourc_webviewer/fourc_webserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,17 @@ class FourCWebServer:
components (e.g., state, controller) along with other relevant server-only
variables."""

def __init__(self, page_title, fourc_yaml_file):
def __init__(
self,
fourc_yaml_file,
page_title="4C Webviewer",
):
"""Constructor.
Args:
fourc_yaml_file (string|Path): path to the input fourc yaml file.
page_title (string): page title appearing in the browser
tab.
fourc_yaml_file (string|Path): path to the input fourc yaml file.
"""

self.server = get_server()
Expand Down
12 changes: 4 additions & 8 deletions src/fourc_webviewer/run_webserver.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
"""Utility to run the webserver on a defined port."""

from fourc_webviewer.fourc_webserver import FourCWebServer
from fourc_webviewer_default_files import (
DEFAULT_INPUT_FILE,
)
from fourc_webviewer_default_files import DEFAULT_INPUT_FILE

# specify server port for the app to run on
SERVER_PORT = 12345
Expand All @@ -13,13 +11,11 @@ def run_webviewer(fourc_yaml_file=None):
"""Runs the webviewer by creating a dedicated webserver object, starting it
and cleaning up afterwards."""

# use the default input file
if fourc_yaml_file is None:
fourc_yaml_file = str(DEFAULT_INPUT_FILE)
fourc_yaml_file = DEFAULT_INPUT_FILE

# create fourc webserver object
fourc_webserver = FourCWebServer(
page_title="4C Webviewer", fourc_yaml_file=fourc_yaml_file
)
fourc_webserver = FourCWebServer(fourc_yaml_file)

# start the server after everything is set up
fourc_webserver.server.start(port=SERVER_PORT)
Expand Down
64 changes: 0 additions & 64 deletions test/test_pyvista.py

This file was deleted.

26 changes: 26 additions & 0 deletions tests/test_fourcwebserver.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"""Test FourC webserver."""

import pytest
from fourcipp.fourc_input import FourCInput

from fourc_webviewer.fourc_webserver import FourCWebServer
from fourc_webviewer_default_files import DEFAULT_INPUT_FILE


@pytest.fixture(name="fourc_webserver")
def fixture_fourc_webserver():
"""FourC webserver fixture."""
return FourCWebServer(fourc_yaml_file=DEFAULT_INPUT_FILE)


@pytest.mark.parametrize(
"key, reference_value",
[
("render_count", {"change_selected_material": 0, "change_fourc_yaml_file": 0}),
("fourc_yaml_content", FourCInput.from_4C_yaml(DEFAULT_INPUT_FILE)),
("fourc_yaml_name", DEFAULT_INPUT_FILE.name),
],
)
def test_webserver_server_variables(fourc_webserver, key, reference_value):
"""Test if server variables are initialised correctly."""
assert fourc_webserver._server_vars[key] == reference_value
Loading