foamlib 0.6.5__tar.gz → 0.6.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. {foamlib-0.6.5 → foamlib-0.6.6}/PKG-INFO +4 -2
  2. {foamlib-0.6.5 → foamlib-0.6.6}/README.md +3 -1
  3. {foamlib-0.6.5 → foamlib-0.6.6}/foamlib/__init__.py +1 -1
  4. {foamlib-0.6.5 → foamlib-0.6.6}/foamlib/_cases/_subprocess.py +19 -10
  5. {foamlib-0.6.5 → foamlib-0.6.6}/foamlib/_cases/_sync.py +0 -4
  6. {foamlib-0.6.5 → foamlib-0.6.6}/foamlib.egg-info/PKG-INFO +4 -2
  7. {foamlib-0.6.5 → foamlib-0.6.6}/LICENSE.txt +0 -0
  8. {foamlib-0.6.5 → foamlib-0.6.6}/foamlib/_cases/__init__.py +0 -0
  9. {foamlib-0.6.5 → foamlib-0.6.6}/foamlib/_cases/_async.py +0 -0
  10. {foamlib-0.6.5 → foamlib-0.6.6}/foamlib/_cases/_base.py +0 -0
  11. {foamlib-0.6.5 → foamlib-0.6.6}/foamlib/_cases/_run.py +0 -0
  12. {foamlib-0.6.5 → foamlib-0.6.6}/foamlib/_cases/_slurm.py +0 -0
  13. {foamlib-0.6.5 → foamlib-0.6.6}/foamlib/_cases/_util.py +0 -0
  14. {foamlib-0.6.5 → foamlib-0.6.6}/foamlib/_files/__init__.py +0 -0
  15. {foamlib-0.6.5 → foamlib-0.6.6}/foamlib/_files/_base.py +0 -0
  16. {foamlib-0.6.5 → foamlib-0.6.6}/foamlib/_files/_files.py +0 -0
  17. {foamlib-0.6.5 → foamlib-0.6.6}/foamlib/_files/_io.py +0 -0
  18. {foamlib-0.6.5 → foamlib-0.6.6}/foamlib/_files/_parsing.py +0 -0
  19. {foamlib-0.6.5 → foamlib-0.6.6}/foamlib/_files/_serialization.py +0 -0
  20. {foamlib-0.6.5 → foamlib-0.6.6}/foamlib/_files/_util.py +0 -0
  21. {foamlib-0.6.5 → foamlib-0.6.6}/foamlib/py.typed +0 -0
  22. {foamlib-0.6.5 → foamlib-0.6.6}/foamlib.egg-info/SOURCES.txt +0 -0
  23. {foamlib-0.6.5 → foamlib-0.6.6}/foamlib.egg-info/dependency_links.txt +0 -0
  24. {foamlib-0.6.5 → foamlib-0.6.6}/foamlib.egg-info/requires.txt +0 -0
  25. {foamlib-0.6.5 → foamlib-0.6.6}/foamlib.egg-info/top_level.txt +0 -0
  26. {foamlib-0.6.5 → foamlib-0.6.6}/pyproject.toml +0 -0
  27. {foamlib-0.6.5 → foamlib-0.6.6}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: foamlib
3
- Version: 0.6.5
3
+ Version: 0.6.6
4
4
  Summary: A Python interface for interacting with OpenFOAM
5
5
  Author-email: "Gabriel S. Gerlero" <ggerlero@cimec.unl.edu.ar>
6
6
  Project-URL: Homepage, https://github.com/gerlero/foamlib
@@ -68,9 +68,10 @@ Requires-Dist: foamlib[docs]; extra == "dev"
68
68
 
69
69
  It offers the following classes:
70
70
 
71
- * [`FoamFile`](https://foamlib.readthedocs.io/en/stable/files.html#foamlib.FoamFile) (and [`FoamFieldFile`](https://foamlib.readthedocs.io/en/stable/files.html#foamlib.FoamFieldFile)): read-write access to OpenFOAM configuration and field files as if they were Python `dict`s, using `foamlib`'s own parser. Supports both ASCII and binary field formats.
71
+ * [`FoamFile`](https://foamlib.readthedocs.io/en/stable/files.html#foamlib.FoamFile) (and [`FoamFieldFile`](https://foamlib.readthedocs.io/en/stable/files.html#foamlib.FoamFieldFile)): read-write access to OpenFOAM configuration and field files as if they were Python `dict`s, using `foamlib`'s own parser. Supports ASCII and binary field formats (with or without compression).
72
72
  * [`FoamCase`](https://foamlib.readthedocs.io/en/stable/cases.html#foamlib.FoamCase): a class for configuring, running, and accessing the results of OpenFOAM cases.
73
73
  * [`AsyncFoamCase`](https://foamlib.readthedocs.io/en/stable/cases.html#foamlib.AsyncFoamCase): variant of `FoamCase` with asynchronous methods for running multiple cases at once.
74
+ * [`AsyncSlurmFoamCase`](https://foamlib.readthedocs.io/en/stable/cases.html#foamlib.AsyncSlurmFoamCase): subclass of `AsyncFoamCase` used for running cases on a Slurm cluster.
74
75
 
75
76
  ## Get started
76
77
 
@@ -164,6 +165,7 @@ from foamlib import AsyncFoamCase
164
165
  from scipy.optimize import differential_evolution
165
166
 
166
167
  base = AsyncFoamCase(Path(os.environ["FOAM_TUTORIALS"]) / "incompressible/simpleFoam/pitzDaily")
168
+ # Replace with `AsyncSlurmFoamCase` if on a cluster and you want cases to be run as Slurm jobs
167
169
 
168
170
  async def cost(x):
169
171
  async with base.clone() as clone:
@@ -14,9 +14,10 @@
14
14
 
15
15
  It offers the following classes:
16
16
 
17
- * [`FoamFile`](https://foamlib.readthedocs.io/en/stable/files.html#foamlib.FoamFile) (and [`FoamFieldFile`](https://foamlib.readthedocs.io/en/stable/files.html#foamlib.FoamFieldFile)): read-write access to OpenFOAM configuration and field files as if they were Python `dict`s, using `foamlib`'s own parser. Supports both ASCII and binary field formats.
17
+ * [`FoamFile`](https://foamlib.readthedocs.io/en/stable/files.html#foamlib.FoamFile) (and [`FoamFieldFile`](https://foamlib.readthedocs.io/en/stable/files.html#foamlib.FoamFieldFile)): read-write access to OpenFOAM configuration and field files as if they were Python `dict`s, using `foamlib`'s own parser. Supports ASCII and binary field formats (with or without compression).
18
18
  * [`FoamCase`](https://foamlib.readthedocs.io/en/stable/cases.html#foamlib.FoamCase): a class for configuring, running, and accessing the results of OpenFOAM cases.
19
19
  * [`AsyncFoamCase`](https://foamlib.readthedocs.io/en/stable/cases.html#foamlib.AsyncFoamCase): variant of `FoamCase` with asynchronous methods for running multiple cases at once.
20
+ * [`AsyncSlurmFoamCase`](https://foamlib.readthedocs.io/en/stable/cases.html#foamlib.AsyncSlurmFoamCase): subclass of `AsyncFoamCase` used for running cases on a Slurm cluster.
20
21
 
21
22
  ## Get started
22
23
 
@@ -110,6 +111,7 @@ from foamlib import AsyncFoamCase
110
111
  from scipy.optimize import differential_evolution
111
112
 
112
113
  base = AsyncFoamCase(Path(os.environ["FOAM_TUTORIALS"]) / "incompressible/simpleFoam/pitzDaily")
114
+ # Replace with `AsyncSlurmFoamCase` if on a cluster and you want cases to be run as Slurm jobs
113
115
 
114
116
  async def cost(x):
115
117
  async with base.clone() as clone:
@@ -1,6 +1,6 @@
1
1
  """A Python interface for interacting with OpenFOAM."""
2
2
 
3
- __version__ = "0.6.5"
3
+ __version__ = "0.6.6"
4
4
 
5
5
  from ._cases import (
6
6
  AsyncFoamCase,
@@ -2,6 +2,7 @@ import asyncio
2
2
  import os
3
3
  import subprocess
4
4
  import sys
5
+ from io import BytesIO
5
6
  from typing import IO, Optional, Union
6
7
 
7
8
  if sys.version_info >= (3, 9):
@@ -48,22 +49,26 @@ def run_sync(
48
49
  shell=isinstance(cmd, str),
49
50
  )
50
51
 
51
- error = b""
52
-
53
52
  if stderr == STDOUT:
54
53
  stderr = stdout
55
54
  if stderr not in (PIPE, DEVNULL):
55
+ stderr_copy = BytesIO()
56
+
56
57
  assert not isinstance(stderr, int)
57
58
  if stderr is None:
58
59
  stderr = sys.stderr.buffer
59
60
 
60
61
  assert proc.stderr is not None
61
62
  for line in proc.stderr:
62
- error += line
63
63
  stderr.write(line)
64
+ stderr_copy.write(line)
65
+
66
+ output, _ = proc.communicate()
67
+ assert not _
68
+ error = stderr_copy.getvalue()
69
+ else:
70
+ output, error = proc.communicate()
64
71
 
65
- output, _ = proc.communicate()
66
- assert not _
67
72
  assert proc.returncode is not None
68
73
 
69
74
  if check and proc.returncode != 0:
@@ -108,22 +113,26 @@ async def run_async(
108
113
  stderr=PIPE,
109
114
  )
110
115
 
111
- error = b""
112
-
113
116
  if stderr == STDOUT:
114
117
  stderr = stdout
115
118
  if stderr not in (PIPE, DEVNULL):
119
+ stderr_copy = BytesIO()
120
+
116
121
  assert not isinstance(stderr, int)
117
122
  if stderr is None:
118
123
  stderr = sys.stderr.buffer
119
124
 
120
125
  assert proc.stderr is not None
121
126
  async for line in proc.stderr:
122
- error += line
123
127
  stderr.write(line)
128
+ stderr_copy.write(line)
129
+
130
+ output, _ = await proc.communicate()
131
+ assert not _
132
+ error = stderr_copy.getvalue()
133
+ else:
134
+ output, error = await proc.communicate()
124
135
 
125
- output, _ = await proc.communicate()
126
- assert not _
127
136
  assert proc.returncode is not None
128
137
 
129
138
  if check and proc.returncode != 0:
@@ -1,7 +1,6 @@
1
1
  import os
2
2
  import shutil
3
3
  import sys
4
- from pathlib import Path
5
4
  from types import TracebackType
6
5
  from typing import Any, Callable, Optional, Type, Union, overload
7
6
 
@@ -49,9 +48,6 @@ class FoamCase(FoamCaseRunBase):
49
48
 
50
49
  return calls.value
51
50
 
52
- def __init__(self, path: Union["os.PathLike[str]", str] = Path()):
53
- super().__init__(path)
54
-
55
51
  @staticmethod
56
52
  def _run(
57
53
  cmd: Union[Sequence[Union[str, "os.PathLike[str]"]], str],
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: foamlib
3
- Version: 0.6.5
3
+ Version: 0.6.6
4
4
  Summary: A Python interface for interacting with OpenFOAM
5
5
  Author-email: "Gabriel S. Gerlero" <ggerlero@cimec.unl.edu.ar>
6
6
  Project-URL: Homepage, https://github.com/gerlero/foamlib
@@ -68,9 +68,10 @@ Requires-Dist: foamlib[docs]; extra == "dev"
68
68
 
69
69
  It offers the following classes:
70
70
 
71
- * [`FoamFile`](https://foamlib.readthedocs.io/en/stable/files.html#foamlib.FoamFile) (and [`FoamFieldFile`](https://foamlib.readthedocs.io/en/stable/files.html#foamlib.FoamFieldFile)): read-write access to OpenFOAM configuration and field files as if they were Python `dict`s, using `foamlib`'s own parser. Supports both ASCII and binary field formats.
71
+ * [`FoamFile`](https://foamlib.readthedocs.io/en/stable/files.html#foamlib.FoamFile) (and [`FoamFieldFile`](https://foamlib.readthedocs.io/en/stable/files.html#foamlib.FoamFieldFile)): read-write access to OpenFOAM configuration and field files as if they were Python `dict`s, using `foamlib`'s own parser. Supports ASCII and binary field formats (with or without compression).
72
72
  * [`FoamCase`](https://foamlib.readthedocs.io/en/stable/cases.html#foamlib.FoamCase): a class for configuring, running, and accessing the results of OpenFOAM cases.
73
73
  * [`AsyncFoamCase`](https://foamlib.readthedocs.io/en/stable/cases.html#foamlib.AsyncFoamCase): variant of `FoamCase` with asynchronous methods for running multiple cases at once.
74
+ * [`AsyncSlurmFoamCase`](https://foamlib.readthedocs.io/en/stable/cases.html#foamlib.AsyncSlurmFoamCase): subclass of `AsyncFoamCase` used for running cases on a Slurm cluster.
74
75
 
75
76
  ## Get started
76
77
 
@@ -164,6 +165,7 @@ from foamlib import AsyncFoamCase
164
165
  from scipy.optimize import differential_evolution
165
166
 
166
167
  base = AsyncFoamCase(Path(os.environ["FOAM_TUTORIALS"]) / "incompressible/simpleFoam/pitzDaily")
168
+ # Replace with `AsyncSlurmFoamCase` if on a cluster and you want cases to be run as Slurm jobs
167
169
 
168
170
  async def cost(x):
169
171
  async with base.clone() as clone:
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes