Skip to content

Commit

Permalink
Draft: fluidimage-monitor with textual
Browse files Browse the repository at this point in the history
  • Loading branch information
paugier committed Apr 10, 2024
1 parent 5ba8936 commit 5d3642e
Show file tree
Hide file tree
Showing 10 changed files with 810 additions and 63 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
develop: sync

sync:
pdm sync
pdm sync --clean

lock:
pdm lock
Expand Down
518 changes: 490 additions & 28 deletions pdm.lock

Large diffs are not rendered by default.

177 changes: 159 additions & 18 deletions pixi.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 11 additions & 9 deletions pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,21 @@ h5netcdf = ">=1.3.0"
h5py = ">=3.10.0"
matplotlib = ">=3.5"
scipy = ">=1.11.4"
rich = ">=13.7.1"
ipython = ">=8.21.0,<8.22"
opencv = ">=4.8.1,<4.10"
trio = ">=0.24.0,<0.25"
dask = ">=2024.2.0,<2024.3"
pyfftw = ">=0.13.1,<0.14"
textual = ">=0.56.4"
# build deps
pip = ">=23.3.2"
pkg-config = ">=0.29.2"
meson-python = ">=0.15.0"
ninja = ">=1.11.1"
meson = ">=1.3.2"
pythran = ">=0.15.0"
# tests
pytest = ">=8.0.0"
pytest-cov = ">=4.1.0"
coverage = ">=7.4.1"
ninja = ">=1.11.1"
meson = ">=1.3.2"
pythran = ">=0.15.0,<0.16"
ipython = ">=8.21.0,<8.22"
opencv = ">=4.8.1,<4.10"
trio = ">=0.24.0,<0.25"
dask = ">=2024.2.0,<2024.3"
pyfftw = ">=0.13.1,<0.14"
rich = ">=13.7.1,<13.8"
10 changes: 7 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ dependencies = [
"dask[array]",
"ipython",
"rich>=13.7.1",
"textual",
]
requires-python = ">=3.9,<3.13"
readme = "README.md"
Expand All @@ -52,16 +53,17 @@ classifiers = [
Homepage = "https://foss.heptapod.net/fluiddyn/fluidimage"

[project.scripts]
fluidimviewer-pg = "fluidimage.gui.pg_main:main"
fluidimviewer = "fluidimage.gui.imviewer:main"
fluidimlauncher = "fluidimage.gui.launcher.main:main"
fluidimage-monitor = "fluidimage.gui.monitor:main"
fluidimviewer = "fluidimage.gui.imviewer:main"
fluidimviewer-pg = "fluidimage.gui.pg_main:main"
fluidpivviewer = "fluidimage.gui.piv_viewer:main"

[project.optional-dependencies]
pims = ["pims"]
opencv = ["opencv-python"]
graph = ["gprof2dot"]
pytest = ["pytest"]
pytest = ["pytest", "pytest-asyncio"]
all = ["fluidimage[pims, opencv-python, gprof2dot, pytest]"]
# qt = ["PySide6"]

Expand Down Expand Up @@ -110,6 +112,7 @@ test = [
"pytest",
"coverage",
"pytest-cov",
"pytest-asyncio",
"fluidimage"
]
# test-qt = ["pytest-qt"]
Expand All @@ -120,6 +123,7 @@ dev = [
"pylint",
"isort",
"ipdb>=0.13.13",
"textual-dev",
]

[tool.pdm.scripts]
Expand Down
33 changes: 31 additions & 2 deletions src/fluidimage/executors/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

from fluiddyn import time_as_str
from fluiddyn.io.tee import MultiFile
from fluiddyn.util.paramcontainer import ParamContainer
from fluidimage.config import get_config
from fluidimage.topologies.nb_cpu_cores import nb_cores
from fluidimage.util import (
Expand Down Expand Up @@ -66,6 +67,9 @@ class ExecutorBase:
"""

info_job: dict
path_job_data: Path

def _init_log_path(self):
name = f"log_{self._unique_postfix}"
self.path_dir_exceptions = self.path_dir_result / name
Expand Down Expand Up @@ -183,12 +187,32 @@ def _init_compute(self):

def _init_compute_log(self):
log_memory_usage(time_as_str(2) + ": starting execution. mem usage")
print(" topology:", str_short(type(self.topology)))
print(" executor:", str_short(type(self)))

topology_name = str_short(type(self.topology))
executor_name = str_short(type(self))
print(" topology:", topology_name)
print(" executor:", executor_name)
print(" nb_cpus_allowed =", nb_cores)
print(" nb_max_workers =", self.nb_max_workers)
print(" path_dir_result =", self.path_dir_result)

self.info_job = {
"topology": topology_name,
"executor": executor_name,
"nb_cpus_allowed": nb_cores,
"nb_max_workers": self.nb_max_workers,
"path_dir_result": self.path_dir_result,
}

def _save_job_data(self):
self.path_job_data = self.path_dir_result / f"job_{self._unique_postfix}"
self.path_job_data.mkdir(exist_ok=True)
self.topology.params._save_as_xml(self.path_job_data / "params.xml")

self.info_job["num_expected_results"] = self.num_expected_results
info_job = ParamContainer("info", attribs=self.info_job)
info_job._save_as_xml(self.path_job_data / "info.xml")

def _reset_std_as_default(self):
sys.stdout = self._old_stdout
sys.stderr = self._old_stderr
Expand Down Expand Up @@ -327,6 +351,11 @@ def handler_signals(signal_number, stack):
signal.signal(12, handler_signals)

self._start_processes()

# _start_processes has to initialize num_expected_results
# so _save_job_data can be called
self._save_job_data()

self._wait_for_all_processes()
self._finalize_compute()

Expand Down
2 changes: 0 additions & 2 deletions src/fluidimage/executors/exec_sequential.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@

import time

from fluidimage.util import cstring, log_memory_usage, logger

from .base import ExecutorBase


Expand Down
Loading

0 comments on commit 5d3642e

Please sign in to comment.