flowgraph 0.1.9__tar.gz → 0.1.10__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 (142) hide show
  1. {flowgraph-0.1.9/src/flowgraph.egg-info → flowgraph-0.1.10}/PKG-INFO +1 -1
  2. {flowgraph-0.1.9 → flowgraph-0.1.10}/pyproject.toml +1 -1
  3. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/adapters/file_conversion.py +34 -23
  4. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/adapters/files.py +61 -13
  5. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/adapters/readers.py +109 -24
  6. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/adapters/vector_tools.py +4 -3
  7. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/application/port_conversions.py +4 -0
  8. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/application/workflow_execution.py +2 -0
  9. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/server/http.py +6 -0
  10. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/server/workspace.py +9 -0
  11. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/version.py +1 -1
  12. {flowgraph-0.1.9 → flowgraph-0.1.10/src/flowgraph.egg-info}/PKG-INFO +1 -1
  13. {flowgraph-0.1.9 → flowgraph-0.1.10}/tests/test_extract_vector_value.py +15 -9
  14. {flowgraph-0.1.9 → flowgraph-0.1.10}/tests/test_file_conversion.py +133 -13
  15. {flowgraph-0.1.9 → flowgraph-0.1.10}/tests/test_local_server.py +22 -0
  16. flowgraph-0.1.10/tests/test_readers.py +388 -0
  17. {flowgraph-0.1.9 → flowgraph-0.1.10}/tests/test_release.py +20 -2
  18. {flowgraph-0.1.9 → flowgraph-0.1.10}/tests/test_workflow_execution.py +23 -0
  19. {flowgraph-0.1.9 → flowgraph-0.1.10}/tests/test_workflow_web_catalog.py +42 -0
  20. {flowgraph-0.1.9 → flowgraph-0.1.10}/tests/test_workspace_file.py +219 -0
  21. flowgraph-0.1.9/tests/test_readers.py +0 -206
  22. {flowgraph-0.1.9 → flowgraph-0.1.10}/LICENSE +0 -0
  23. {flowgraph-0.1.9 → flowgraph-0.1.10}/README.md +0 -0
  24. {flowgraph-0.1.9 → flowgraph-0.1.10}/setup.cfg +0 -0
  25. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/__init__.py +0 -0
  26. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/__main__.py +0 -0
  27. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/adapters/__init__.py +0 -0
  28. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/adapters/calculator.py +0 -0
  29. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/adapters/controls.py +0 -0
  30. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/adapters/cosapp.py +0 -0
  31. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/adapters/data_types.py +0 -0
  32. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/adapters/documentation.py +0 -0
  33. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/adapters/field_gradient.py +0 -0
  34. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/adapters/field_ops.py +0 -0
  35. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/adapters/filters.py +0 -0
  36. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/adapters/image_tools.py +0 -0
  37. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/adapters/imagej.py +0 -0
  38. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/adapters/mesh_analysis.py +0 -0
  39. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/adapters/mesh_composition.py +0 -0
  40. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/adapters/mesh_creation_tools.py +0 -0
  41. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/adapters/mesh_generations.py +0 -0
  42. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/adapters/mesh_ops.py +0 -0
  43. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/adapters/paraview.py +0 -0
  44. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/adapters/plaid_bridge.py +0 -0
  45. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/adapters/remote_files.py +0 -0
  46. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/adapters/simple_sources.py +0 -0
  47. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/adapters/sinks.py +0 -0
  48. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/adapters/table_tools.py +0 -0
  49. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/adapters/user_code.py +0 -0
  50. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/adapters/workflow.py +0 -0
  51. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/adapters/workflow_interfaces.py +0 -0
  52. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/adapters/writers.py +0 -0
  53. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/adapters/zones.py +0 -0
  54. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/application/__init__.py +0 -0
  55. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/application/file_dependencies.py +0 -0
  56. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/application/node_registry.py +0 -0
  57. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/application/plugins.py +0 -0
  58. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/application/wasm_packages.py +0 -0
  59. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/application/workflow_cli.py +0 -0
  60. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/application/workflow_core.py +0 -0
  61. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/application/workflow_defaults.py +0 -0
  62. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/application/workflow_history.py +0 -0
  63. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/application/workflow_io.py +0 -0
  64. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/application/workflow_layout.py +0 -0
  65. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/application/workflow_session.py +0 -0
  66. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/application/workflow_web_catalog.py +0 -0
  67. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/application/workflows.py +0 -0
  68. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/core_cli.py +0 -0
  69. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/domain/__init__.py +0 -0
  70. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/domain/filepath.py +0 -0
  71. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/domain/mesh_document.py +0 -0
  72. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/examples/AllFilters.py +0 -0
  73. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/examples/convert_format.py +0 -0
  74. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/paraview_gateway.py +0 -0
  75. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/resources.py +0 -0
  76. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/server/__init__.py +0 -0
  77. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/server/jobs.py +0 -0
  78. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/server/packages.py +0 -0
  79. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/server/worker.py +0 -0
  80. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/testdata/AllFilters.json +0 -0
  81. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/testdata/ColorCardboard.jpg +0 -0
  82. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/testdata/FlowGraph.h5 +0 -0
  83. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/testdata/FlowGraph.stl +0 -0
  84. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/testdata/FlowGraph.xdmf +0 -0
  85. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/testdata/ImageJBlur.json +0 -0
  86. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/testdata/SimpleReadMesh.json +0 -0
  87. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/testdata/SpherePoints.csv +0 -0
  88. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph/testdata/muscat-muscat-mesh-conversion.json +0 -0
  89. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph.egg-info/SOURCES.txt +0 -0
  90. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph.egg-info/dependency_links.txt +0 -0
  91. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph.egg-info/entry_points.txt +0 -0
  92. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph.egg-info/requires.txt +0 -0
  93. {flowgraph-0.1.9 → flowgraph-0.1.10}/src/flowgraph.egg-info/top_level.txt +0 -0
  94. {flowgraph-0.1.9 → flowgraph-0.1.10}/tests/test_array_nodes.py +0 -0
  95. {flowgraph-0.1.9 → flowgraph-0.1.10}/tests/test_array_types.py +0 -0
  96. {flowgraph-0.1.9 → flowgraph-0.1.10}/tests/test_audit_requirements.py +0 -0
  97. {flowgraph-0.1.9 → flowgraph-0.1.10}/tests/test_cache_policy.py +0 -0
  98. {flowgraph-0.1.9 → flowgraph-0.1.10}/tests/test_calculator.py +0 -0
  99. {flowgraph-0.1.9 → flowgraph-0.1.10}/tests/test_conditional_workflow.py +0 -0
  100. {flowgraph-0.1.9 → flowgraph-0.1.10}/tests/test_controls.py +0 -0
  101. {flowgraph-0.1.9 → flowgraph-0.1.10}/tests/test_core_gui_boundary.py +0 -0
  102. {flowgraph-0.1.9 → flowgraph-0.1.10}/tests/test_cosapp.py +0 -0
  103. {flowgraph-0.1.9 → flowgraph-0.1.10}/tests/test_directory_dependencies.py +0 -0
  104. {flowgraph-0.1.9 → flowgraph-0.1.10}/tests/test_extract_field.py +0 -0
  105. {flowgraph-0.1.9 → flowgraph-0.1.10}/tests/test_field_gradient.py +0 -0
  106. {flowgraph-0.1.9 → flowgraph-0.1.10}/tests/test_filepath.py +0 -0
  107. {flowgraph-0.1.9 → flowgraph-0.1.10}/tests/test_fluency_optimization.py +0 -0
  108. {flowgraph-0.1.9 → flowgraph-0.1.10}/tests/test_headless_boundary.py +0 -0
  109. {flowgraph-0.1.9 → flowgraph-0.1.10}/tests/test_image_roi.py +0 -0
  110. {flowgraph-0.1.9 → flowgraph-0.1.10}/tests/test_image_tools.py +0 -0
  111. {flowgraph-0.1.9 → flowgraph-0.1.10}/tests/test_imagej.py +0 -0
  112. {flowgraph-0.1.9 → flowgraph-0.1.10}/tests/test_mesh_analysis.py +0 -0
  113. {flowgraph-0.1.9 → flowgraph-0.1.10}/tests/test_mesh_composition.py +0 -0
  114. {flowgraph-0.1.9 → flowgraph-0.1.10}/tests/test_mesh_creation_tools.py +0 -0
  115. {flowgraph-0.1.9 → flowgraph-0.1.10}/tests/test_mesh_ops.py +0 -0
  116. {flowgraph-0.1.9 → flowgraph-0.1.10}/tests/test_muscat_vtk.py +0 -0
  117. {flowgraph-0.1.9 → flowgraph-0.1.10}/tests/test_native_packages.py +0 -0
  118. {flowgraph-0.1.9 → flowgraph-0.1.10}/tests/test_node_selector.py +0 -0
  119. {flowgraph-0.1.9 → flowgraph-0.1.10}/tests/test_packaging.py +0 -0
  120. {flowgraph-0.1.9 → flowgraph-0.1.10}/tests/test_paraview.py +0 -0
  121. {flowgraph-0.1.9 → flowgraph-0.1.10}/tests/test_plaid_bridge.py +0 -0
  122. {flowgraph-0.1.9 → flowgraph-0.1.10}/tests/test_plugins.py +0 -0
  123. {flowgraph-0.1.9 → flowgraph-0.1.10}/tests/test_remote_files.py +0 -0
  124. {flowgraph-0.1.9 → flowgraph-0.1.10}/tests/test_remove_lonely_nodes.py +0 -0
  125. {flowgraph-0.1.9 → flowgraph-0.1.10}/tests/test_scalars_to_array_1d.py +0 -0
  126. {flowgraph-0.1.9 → flowgraph-0.1.10}/tests/test_simple_sources.py +0 -0
  127. {flowgraph-0.1.9 → flowgraph-0.1.10}/tests/test_sinks.py +0 -0
  128. {flowgraph-0.1.9 → flowgraph-0.1.10}/tests/test_table_tools.py +0 -0
  129. {flowgraph-0.1.9 → flowgraph-0.1.10}/tests/test_transfer_fields.py +0 -0
  130. {flowgraph-0.1.9 → flowgraph-0.1.10}/tests/test_user_code_mesh.py +0 -0
  131. {flowgraph-0.1.9 → flowgraph-0.1.10}/tests/test_user_function_parameters.py +0 -0
  132. {flowgraph-0.1.9 → flowgraph-0.1.10}/tests/test_vector_field_gradient.py +0 -0
  133. {flowgraph-0.1.9 → flowgraph-0.1.10}/tests/test_vector_tools.py +0 -0
  134. {flowgraph-0.1.9 → flowgraph-0.1.10}/tests/test_wasm_packages.py +0 -0
  135. {flowgraph-0.1.9 → flowgraph-0.1.10}/tests/test_workflow_cli.py +0 -0
  136. {flowgraph-0.1.9 → flowgraph-0.1.10}/tests/test_workflow_core.py +0 -0
  137. {flowgraph-0.1.9 → flowgraph-0.1.10}/tests/test_workflow_history.py +0 -0
  138. {flowgraph-0.1.9 → flowgraph-0.1.10}/tests/test_workflow_io.py +0 -0
  139. {flowgraph-0.1.9 → flowgraph-0.1.10}/tests/test_workflow_session.py +0 -0
  140. {flowgraph-0.1.9 → flowgraph-0.1.10}/tests/test_workspace_directories.py +0 -0
  141. {flowgraph-0.1.9 → flowgraph-0.1.10}/tests/test_writers.py +0 -0
  142. {flowgraph-0.1.9 → flowgraph-0.1.10}/tests/test_zones.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: flowgraph
3
- Version: 0.1.9
3
+ Version: 0.1.10
4
4
  Summary: Headless typed workflow engine and execution runtime
5
5
  Author: Felipe Bordeu
6
6
  Maintainer: Felipe Bordeu
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "flowgraph"
7
- version = "0.1.9"
7
+ version = "0.1.10"
8
8
  description = "Headless typed workflow engine and execution runtime"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
@@ -12,6 +12,7 @@ from flowgraph.application.workflow_core import (
12
12
  PortDefinition,
13
13
  PortDirection,
14
14
  )
15
+ from flowgraph.domain.filepath import FilePath
15
16
 
16
17
  from .data_types import FILE, ParameterKind
17
18
 
@@ -20,6 +21,23 @@ class MeshFileConversionError(RuntimeError):
20
21
  """Raised when a mesh file conversion cannot be completed."""
21
22
 
22
23
 
24
+ TIMESTEP_OPTIONS = (
25
+ ParameterOption("first", "First time step"),
26
+ ParameterOption("last", "Last time step"),
27
+ ParameterOption("all", "All time steps"),
28
+ )
29
+
30
+
31
+ def get_available_mesh_times(reader: Any) -> Any:
32
+ """Load temporal metadata only when supported, without copying the times."""
33
+ if getattr(reader, "canHandleTemporal", False):
34
+ reader.ReadMetaData()
35
+ times = reader.GetAvailableTimes()
36
+ if times is not None:
37
+ return times
38
+ return ()
39
+
40
+
23
41
  class DelayInitialization:
24
42
  """Lazily resolve the reader or writer classes in a conversion catalog."""
25
43
 
@@ -231,9 +249,9 @@ def mesh_file_conversion(
231
249
  Parameters
232
250
  ----------
233
251
  inputs : collections.abc.Mapping[str, Any]
234
- Input and output filenames.
252
+ Connected inputs, already merged into parameters by the workflow executor.
235
253
  parameters : collections.abc.Mapping[str, Any]
236
- Reader, writer, temporal selection, and binary-output settings.
254
+ Input and output filenames, reader, writer, temporal selection, and binary-output settings.
237
255
 
238
256
  Returns
239
257
  -------
@@ -292,23 +310,24 @@ def mesh_file_conversion(
292
310
  **extras,
293
311
  )
294
312
 
295
- if reader.canHandleTemporal:
296
- reader.ReadMetaData()
297
- timesAvailable = reader.GetAvailableTimes()
313
+ times_available = get_available_mesh_times(reader)
314
+
315
+ # A temporal-capable reader can still be reading a static mesh.
316
+ if len(times_available) > 0:
298
317
  writer.SetFileName(outputfilename)
299
318
  if hasattr(writer, "SetBinary"):
300
319
  writer.SetBinary(binary)
301
320
 
302
321
  if timestep_to_read == "first":
303
- times = [0]
322
+ times = [times_available[0]]
304
323
  elif timestep_to_read == "last":
305
- times = [timesAvailable[-1]]
324
+ times = [times_available[-1]]
306
325
  elif timestep_to_read == "all":
307
- times = timesAvailable
326
+ times = times_available
308
327
  else:
309
328
  from Muscat.Helpers.ParserHelper import ReadInts
310
329
 
311
- times = timesAvailable[ReadInts(timestep_to_read)]
330
+ times = times_available[ReadInts(timestep_to_read)]
312
331
 
313
332
  if writer.canHandleTemporal:
314
333
  writer.SetTemporal()
@@ -321,7 +340,9 @@ def mesh_file_conversion(
321
340
  finally:
322
341
  writer.Close()
323
342
  else:
324
- writer.Open(outputfilename)
343
+ # A single-snapshot writer uses the last of the selected times.
344
+ reader.SetTimeToRead(times[-1])
345
+ writer.Open()
325
346
  try:
326
347
  DoWrite(reader.Read(), writer)
327
348
  finally:
@@ -338,7 +359,7 @@ def mesh_file_conversion(
338
359
  finally:
339
360
  writer.Close()
340
361
 
341
- return {"converted_filename": str(outputfilename)}
362
+ return {"converted_filename": FilePath(outputfilename)}
342
363
 
343
364
 
344
365
  MESH_FILE_CONVERSION = NodeDefinition(
@@ -359,7 +380,6 @@ MESH_FILE_CONVERSION = NodeDefinition(
359
380
  "auto",
360
381
  options=(ParameterOption("auto", "Auto"),)
361
382
  + tuple(ParameterOption(k, k) for k in ReaderMapping.keys()), # noqa: SIM118
362
- port=False,
363
383
  ),
364
384
  ParameterDefinition(
365
385
  "writer",
@@ -368,24 +388,15 @@ MESH_FILE_CONVERSION = NodeDefinition(
368
388
  "auto",
369
389
  options=(ParameterOption("auto", "Auto"),)
370
390
  + tuple(ParameterOption(k, k) for k in WriterMapping.keys()), # noqa: SIM118
371
- port=False,
372
391
  ),
373
392
  ParameterDefinition(
374
393
  "timestep_to_read",
375
394
  ParameterKind.STR_SELECT,
376
395
  "Timestep to read",
377
396
  "last",
378
- options=(
379
- ParameterOption("first", "First time step"),
380
- ParameterOption("last", "Last time step"),
381
- ParameterOption("all", "All time steps"),
382
- # ParameterOption("Selected time step", "selected")
383
- ),
384
- port=False,
385
- ),
386
- ParameterDefinition(
387
- "binary", ParameterKind.BOOLEAN, "binary (if available)", True, port=False
397
+ options=TIMESTEP_OPTIONS,
388
398
  ),
399
+ ParameterDefinition("binary", ParameterKind.BOOLEAN, "binary (if available)", True),
389
400
  # ParameterDefinition(
390
401
  # "timestep", ParameterKind.LIST_INT, "time step to read", [-1], port=True
391
402
  # ),
@@ -53,12 +53,13 @@ SELECT_FILE = NodeDefinition(
53
53
 
54
54
 
55
55
  def _select_server_file(
56
- _inputs: Mapping[str, Any],
56
+ inputs: Mapping[str, Any],
57
57
  parameters: Mapping[str, Any],
58
58
  _exec_context: ExecContext | None = None,
59
59
  ) -> Mapping[str, Any]:
60
- """Resolve a portable workspace file, preserving legacy absolute paths."""
61
- path = parameters.get("file name", "")
60
+ """Resolve selected files, or compose connected paths without filesystem validation."""
61
+ validate_selection = "workspace" not in inputs and "file name" not in inputs
62
+ path = inputs.get("file name", parameters.get("file name", ""))
62
63
  if not isinstance(path, str):
63
64
  raise TypeError("The selected file path parameter must be text")
64
65
  if len(path) == 0:
@@ -68,12 +69,19 @@ def _select_server_file(
68
69
  if source.is_absolute():
69
70
  return {"path": str(source)}
70
71
  root = _exec_context.workspace if _exec_context is not None else None
72
+ if "workspace" in inputs:
73
+ workspace = inputs["workspace"]
74
+ if not isinstance(workspace, (str, Path)):
75
+ raise TypeError("Workspace File workspace path must be text or a Path")
76
+ if workspace == "":
77
+ raise ValueError("Workspace File workspace path can't be empty")
78
+ root = Path(workspace).expanduser().resolve()
71
79
  if root is None:
72
80
  raise ValueError("Workspace File requires a configured workspace directory")
73
81
  source = (root / source).resolve()
74
- if not source.is_relative_to(root):
82
+ if validate_selection and not source.is_relative_to(root):
75
83
  raise ValueError("Workspace File path escapes the workspace directory")
76
- if not source.is_file():
84
+ if validate_selection and not source.is_file():
77
85
  raise ValueError(f"Workspace file does not exist or is not a file: {path}")
78
86
  return {"path": str(source)}
79
87
 
@@ -84,12 +92,28 @@ SELECT_SERVER_FILE = NodeDefinition(
84
92
  requirements=(),
85
93
  icon="mdi-cloud-upload-outline",
86
94
  label="Workspace File",
87
- description="Resolves a workspace-relative file path at runtime without reading the file. Legacy absolute paths remain external references.",
88
- ports=(PortDefinition("path", PortDirection.OUTPUT, STRING, "File path"),),
95
+ description="Resolves a workspace-relative file path without reading the file. Connected workspace or file name inputs compose paths without filesystem validation, including new writer destinations. Legacy absolute paths remain external references.",
96
+ ports=(
97
+ PortDefinition("path", PortDirection.OUTPUT, STRING, "File path"),
98
+ PortDefinition(
99
+ "workspace",
100
+ PortDirection.INPUT,
101
+ DIRECTORY,
102
+ "Workspace path",
103
+ required=False,
104
+ accepted_data_types=(STRING,),
105
+ ),
106
+ PortDefinition("file name", PortDirection.INPUT, STRING, "Workspace file", required=False),
107
+ ),
89
108
  executor=_select_server_file,
90
109
  parameters=(
91
110
  ParameterDefinition(
92
- "file name", ParameterKind.SELECT_SERVER_FILENAME, "Workspace file", "", port=False
111
+ "file name",
112
+ ParameterKind.SELECT_SERVER_FILENAME,
113
+ "Workspace file",
114
+ "",
115
+ port=False,
116
+ input_port="file name",
93
117
  ),
94
118
  ),
95
119
  )
@@ -100,12 +124,24 @@ class DirectoryReadError(ValueError):
100
124
 
101
125
 
102
126
  def _workspace_directory(
103
- _inputs: Mapping[str, Any],
127
+ inputs: Mapping[str, Any],
104
128
  parameters: Mapping[str, Any],
105
129
  _exec_context: ExecContext | None = None,
106
130
  ) -> Mapping[str, Any]:
107
- """Resolve the selected relative folder within the host-configured workspace."""
131
+ """Resolve the selector, or a node-local connected folder without filesystem checks."""
108
132
  root = _exec_context.workspace if _exec_context is not None else None
133
+ if "folder" in inputs:
134
+ selected = inputs["folder"]
135
+ if not isinstance(selected, (str, Path)):
136
+ raise TypeError("Workspace Folder input must be text or a Path")
137
+ if selected == "":
138
+ raise ValueError("Workspace Folder input can't be empty")
139
+ folder = Path(selected).expanduser()
140
+ if folder.is_absolute():
141
+ return {"path": folder.resolve()}
142
+ if root is None:
143
+ raise ValueError("Workspace Folder requires a configured workspace directory")
144
+ return {"path": (root / folder).resolve()}
109
145
  if root is None:
110
146
  raise ValueError("Workspace Folder requires a configured workspace directory")
111
147
  selected = parameters.get("folder", ".")
@@ -128,11 +164,23 @@ WORKSPACE = NodeDefinition(
128
164
  requirements=(),
129
165
  icon="mdi-folder-outline",
130
166
  label="Workspace Folder",
131
- description="Resolves a selected workspace-relative folder as an absolute directory path. Defaults to the workspace root.",
132
- ports=(PortDefinition("path", PortDirection.OUTPUT, DIRECTORY, "Directory path"),),
167
+ description="Resolves a selected workspace-relative folder as an absolute directory path. An optional folder input overrides this node only, without filesystem validation. Defaults to the workspace root.",
168
+ ports=(
169
+ PortDefinition("path", PortDirection.OUTPUT, DIRECTORY, "Directory path"),
170
+ PortDefinition(
171
+ "folder",
172
+ PortDirection.INPUT,
173
+ STRING,
174
+ "Workspace folder",
175
+ required=False,
176
+ accepted_data_types=(DIRECTORY,),
177
+ ),
178
+ ),
133
179
  executor=_workspace_directory,
134
180
  parameters=(
135
- ParameterDefinition("folder", ParameterKind.TEXT, "Workspace folder", ".", port=False),
181
+ ParameterDefinition(
182
+ "folder", ParameterKind.TEXT, "Workspace folder", ".", port=False, input_port="folder"
183
+ ),
136
184
  ),
137
185
  )
138
186
 
@@ -1,10 +1,13 @@
1
1
  """Workflow nodes that read external data into FlowGraph domain objects."""
2
2
 
3
3
  import logging
4
+ import xml.sax
4
5
  from collections.abc import Mapping
5
6
  from pathlib import Path
6
7
  from typing import Any
7
8
 
9
+ import numpy as np
10
+
8
11
  from flowgraph.application.workflow_core import (
9
12
  ExecContext,
10
13
  NodeDefinition,
@@ -14,7 +17,8 @@ from flowgraph.application.workflow_core import (
14
17
  )
15
18
  from flowgraph.domain.mesh_document import MeshDocument
16
19
 
17
- from .data_types import MESH_DOCUMENT, TABLE_DOCUMENT, ParameterKind
20
+ from .data_types import ARRAY_1D, MESH_DOCUMENT, TABLE_DOCUMENT, ParameterKind
21
+ from .file_conversion import get_available_mesh_times
18
22
 
19
23
  LOGGER = logging.getLogger(__name__)
20
24
 
@@ -64,35 +68,99 @@ def _load_muscat(
64
68
  parameters: Mapping[str, Any],
65
69
  _exec_context: ExecContext | None = None,
66
70
  ) -> Mapping[str, Any]:
67
- """Load *source* with Muscat's extension-aware universal mesh reader.
68
-
69
- The returned :class:`~flowgraph.domain.mesh_document.MeshDocument` is the
70
- canonical editable model. The caller can display its summary immediately;
71
- VTK conversion remains a separate, derived projection.
72
- """
71
+ """Read temporal metadata and materialize the selected snapshot if requested."""
72
+ from Muscat.MeshContainers.Mesh import Mesh
73
73
 
74
74
  source = _validate_source(inputs, parameters, "Muscat")
75
+ requested = (
76
+ {port.name for port in LOAD_MUSCAT.outputs}
77
+ if _exec_context is None
78
+ else _exec_context.connected_output_ports
79
+ )
80
+ want_mesh = "mesh" in requested
81
+ want_times = "available_timesteps" in requested
82
+ index = parameters.get("timestep_to_read", -1)
83
+ # Legacy saved dropdown values still select the same single snapshot.
84
+ if "timestep_to_read" not in inputs and isinstance(index, str):
85
+ index = {"first": 0, "last": -1, "all": -1}.get(index, index)
86
+ if want_mesh and (
87
+ isinstance(index, (bool, np.bool_)) or not isinstance(index, (int, np.integer))
88
+ ):
89
+ raise MeshLoadError(f"Timestep to read must be an integer index, got {index!r}")
90
+ document = None
91
+ times = ()
75
92
 
76
93
  try:
77
- from Muscat.IO.IOFactory import CreateReader, InitAllReaders
78
-
79
- LOGGER.debug("Initialising Muscat readers for %s", source)
80
- InitAllReaders()
81
- reader = CreateReader(source.suffix)
82
- LOGGER.info("Loading mesh with Muscat reader %s: %s", type(reader).__name__, source)
83
- reader.SetFileName(str(source))
84
- mesh = reader.Read()
94
+ if want_mesh or want_times:
95
+ from Muscat.IO.IOFactory import CreateReader, InitAllReaders
96
+ from Muscat.IO.XdmfReader import XdmfReader
97
+
98
+ InitAllReaders()
99
+ reader = CreateReader(source.suffix)
100
+ reader.SetFileName(str(source))
101
+ grids = None
102
+ if isinstance(reader, XdmfReader):
103
+ # ReadMetaData calls Read(), which materializes a grid even in
104
+ # lazy mode. Parse with Muscat's SAX handler without GetSupport.
105
+ reader.Reset()
106
+ reader.lazy = True
107
+ if not want_mesh:
108
+ # Ignore inline DataItem payloads; time values are attributes.
109
+ reader.characters = lambda _content: None
110
+ parser = xml.sax.make_parser()
111
+ parser.setContentHandler(reader)
112
+ parser.setFeature(xml.sax.handler.feature_external_ges, False)
113
+ with source.open("rb") as stream:
114
+ parser.parse(stream)
115
+ grids = [grid for grid in reader.xdmf.GetDomain(0).grids if grid.time is not None]
116
+ times = [grid.GetTime() for grid in grids]
117
+ elif want_mesh:
118
+ times = get_available_mesh_times(reader)
119
+ else:
120
+ times = _muscat_times_only(reader)
121
+
122
+ if want_mesh:
123
+ count = max(1, len(times))
124
+ if not -count <= int(index) < count:
125
+ raise ValueError(f"Time-step index {index} out of range for {count} snapshots")
126
+ index = int(index) % count
127
+ if len(times) == 0:
128
+ mesh = (
129
+ reader.Read()
130
+ if grids is None
131
+ else reader.xdmf.GetDomain(-1).GetGrid(-1).GetSupport()
132
+ )
133
+ document = MeshDocument(mesh=mesh.View())
134
+ else:
135
+ if grids is not None:
136
+ mesh = grids[index].GetSupport()
137
+ else:
138
+ reader.SetTimeToRead(None, timeIndex=index)
139
+ mesh = reader.Read()
140
+ document = MeshDocument(mesh=mesh.View())
85
141
  except Exception as error:
86
142
  LOGGER.exception("Muscat failed while loading %s", source)
87
143
  raise MeshLoadError(f"Muscat could not load '{source}': {error}") from error
88
144
 
89
- LOGGER.info(
90
- "Muscat loaded %s (%d nodes, %d elements)",
91
- source,
92
- mesh.GetNumberOfNodes(),
93
- mesh.GetNumberOfElements(),
94
- )
95
- return {"mesh": MeshDocument(mesh=mesh)}
145
+ available = np.asarray(times if want_times and len(times) else (0.0,), dtype=float).view()
146
+ available.flags.writeable = False
147
+ return {
148
+ "mesh": document if document is not None else MeshDocument(mesh=Mesh()),
149
+ "available_timesteps": available,
150
+ }
151
+
152
+
153
+ def _muscat_times_only(reader: Any) -> Any:
154
+ """Avoid backends' mesh-related metadata work when only times are requested."""
155
+ from Muscat.IO.RstReader import RstReader
156
+ from Muscat.IO.UtReader import UtReader
157
+
158
+ if isinstance(reader, UtReader):
159
+ reader.ReadUTMetaData()
160
+ return reader.GetAvailableTimes() if len(reader.time) else ()
161
+ if isinstance(reader, RstReader):
162
+ return reader.GetModel().metadata.time_freq_support.time_frequencies.data
163
+ return get_available_mesh_times(reader)
96
164
 
97
165
 
98
166
  def _load_meshio(
@@ -215,13 +283,30 @@ LOAD_MUSCAT = NodeDefinition(
215
283
  requirements=("py:muscat",),
216
284
  icon="/__flowgraph_ui/LOAD_MUSCAT.svg",
217
285
  label="Read Mesh (Muscat)",
218
- description="Loads a file path into the canonical mesh document. Companion changes must update the principal file timestamp.",
219
- ports=(PortDefinition("mesh", PortDirection.OUTPUT, MESH_DOCUMENT, "Mesh"),),
286
+ description=(
287
+ "Loads a mesh by time-step index (0 is first, -1 is last). "
288
+ "Lists available time steps without loading snapshots when only that output is used. "
289
+ "Companion changes must update the principal file timestamp."
290
+ ),
291
+ ports=(
292
+ PortDefinition("mesh", PortDirection.OUTPUT, MESH_DOCUMENT, "Mesh"),
293
+ PortDefinition(
294
+ "available_timesteps", PortDirection.OUTPUT, ARRAY_1D, "Available Time Steps"
295
+ ),
296
+ ),
220
297
  executor=_load_muscat,
221
298
  parameters=(
222
299
  ParameterDefinition(
223
300
  "path", ParameterKind.FILE, "File path", "", "/path/to/mesh", port=True
224
301
  ),
302
+ ParameterDefinition(
303
+ "timestep_to_read",
304
+ ParameterKind.INTEGER,
305
+ "Timestep to read",
306
+ -1,
307
+ "-1",
308
+ port=True,
309
+ ),
225
310
  ),
226
311
  )
227
312
 
@@ -63,7 +63,7 @@ def _extract_vector_value(
63
63
  parameters: Mapping[str, Any],
64
64
  _exec_context: ExecContext | None = None,
65
65
  ) -> Mapping[str, Any]:
66
- """Return one real vector component without copying or modifying its storage."""
66
+ """Return the selected component and its signed index without copying the vector."""
67
67
  vector = np.asarray(inputs["vector"])
68
68
  if vector.ndim != 1 or vector.size == 0:
69
69
  raise ValueError("Extract Vector Value requires a non-empty one-dimensional vector")
@@ -77,18 +77,19 @@ def _extract_vector_value(
77
77
  raise IndexError(
78
78
  f"Extract Vector Value index {index} is out of range for vector length {vector.size}"
79
79
  )
80
- return {"value": float(vector[index])}
80
+ return {"value": float(vector[index]), "index": index}
81
81
 
82
82
 
83
83
  EXTRACT_VECTOR_VALUE = NodeDefinition(
84
84
  id="extract-vector-value",
85
85
  label="Extract Vector Value",
86
86
  icon="mdi-vector-point",
87
- description="Extract a scalar by zero-based index; negative indices count from the end.",
87
+ description="Return the selected scalar and its index; negative indices count from the end.",
88
88
  requirements=("py:numpy",),
89
89
  ports=(
90
90
  PortDefinition("vector", PortDirection.INPUT, ARRAY_1D, "Vector"),
91
91
  PortDefinition("value", PortDirection.OUTPUT, FLOAT, "Value"),
92
+ PortDefinition("index", PortDirection.OUTPUT, INTEGER, "Index"),
92
93
  ),
93
94
  parameters=(ParameterDefinition("index", ParameterKind.INTEGER, "Index", 0, "0"),),
94
95
  executor=_extract_vector_value,
@@ -24,6 +24,7 @@ from flowgraph.adapters.data_types import (
24
24
  LIST_INT,
25
25
  MUSCAT_ELEMENT_FILTER,
26
26
  MUSCAT_NODE_FILTER,
27
+ STR_SELECT,
27
28
  STRING,
28
29
  VEC2D,
29
30
  VEC2DI,
@@ -73,6 +74,8 @@ FLOAT_TO_LIST_FLOAT = PortConversion(
73
74
 
74
75
  FILE_TO_STR = PortConversion("filename", "string", "FilePath → Text", str)
75
76
  STR_TO_FILE = PortConversion("string", "filename", "Text → FilePath", FilePath)
77
+ # Core already treats these as compatible strings; catalog clients compare type IDs.
78
+ TEXT_TO_STR_SELECT = PortConversion(STRING.id, STR_SELECT.id, "Text → select str", str)
76
79
 
77
80
 
78
81
  PATH_TO_STR = PortConversion("dirname", "string", "dirname → Text", str)
@@ -188,6 +191,7 @@ PORT_CONVERSIONS = (
188
191
  PILLOW_TO_IMAGEJ,
189
192
  FILE_TO_STR,
190
193
  STR_TO_FILE,
194
+ TEXT_TO_STR_SELECT,
191
195
  *VECTOR_CONVERSIONS,
192
196
  )
193
197
 
@@ -439,6 +439,8 @@ def _json_safe(value: Any) -> Any:
439
439
  return {str(key): _json_safe(item) for key, item in value.items()}
440
440
  if isinstance(value, (list, tuple, set)):
441
441
  return [_json_safe(item) for item in value]
442
+ if isinstance(value, np.ndarray):
443
+ return {"type": type(value).__name__, "description": str(value), "shape": list(value.shape)}
442
444
  if hasattr(value, "mode") and hasattr(value, "size"):
443
445
  return {"type": type(value).__name__, "mode": value.mode, "size": list(value.size)}
444
446
  return {"type": type(value).__name__, "description": str(value)}
@@ -205,6 +205,7 @@ class LocalServer(ThreadingHTTPServer):
205
205
  "workflow_format_version": WORKFLOW_FORMAT_VERSION,
206
206
  "capabilities": {
207
207
  "mountDirectory": False,
208
+ "createDirectory": True,
208
209
  "cancelExecution": True,
209
210
  "advisoryExecutionTimeout": 1,
210
211
  "incrementalExecution": 1,
@@ -251,6 +252,7 @@ class ApiHandler(BaseHTTPRequestHandler):
251
252
  "/api/v1/files",
252
253
  "/api/v1/files/demo",
253
254
  "/api/v1/files/content",
255
+ "/api/v1/files/directories",
254
256
  }
255
257
  endpoint = path if path in routes else "<unknown endpoint>"
256
258
  if path.startswith("/api/v1/executions/"):
@@ -421,6 +423,10 @@ class ApiHandler(BaseHTTPRequestHandler):
421
423
  elif path == "/api/v1/files/demo" and method == "POST":
422
424
  self._body()
423
425
  self._reply(200, self.server.workspace.copy_demos())
426
+ elif path == "/api/v1/files/directories" and method == "POST":
427
+ body = self._body(json_body=True)
428
+ self.server.workspace.create_directory(body.get("path"))
429
+ self._reply(201, {"status": "ok"})
424
430
  elif path == "/api/v1/files/content" and method in {"GET", "PUT", "DELETE"}:
425
431
  names = parse_qs(parsed.query).get("path", [])
426
432
  if len(names) != 1:
@@ -86,6 +86,15 @@ class Workspace:
86
86
  target.write_bytes(data)
87
87
  return self.listing()
88
88
 
89
+ def create_directory(self, name: str) -> None:
90
+ with self.lock:
91
+ target = self.path(name, allow_directory=True)
92
+ if any(not part.strip() for part in name.split("/")) or any(
93
+ ord(char) < 32 or ord(char) == 127 for char in name
94
+ ):
95
+ raise ValueError("Invalid workspace-relative directory path")
96
+ target.mkdir()
97
+
89
98
  def read(self, name: str, limit: int) -> bytes:
90
99
  with self.lock:
91
100
  target = self.path(name, allow_directory=True)
@@ -1,3 +1,3 @@
1
1
  """Version information for FlowGraph."""
2
2
 
3
- __version__ = "0.1.9"
3
+ __version__ = "0.1.10"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: flowgraph
3
- Version: 0.1.9
3
+ Version: 0.1.10
4
4
  Summary: Headless typed workflow engine and execution runtime
5
5
  Author: Felipe Bordeu
6
6
  Maintainer: Felipe Bordeu
@@ -28,8 +28,9 @@ def test_extract_value_without_copy_or_mutation(index, expected, dtype):
28
28
 
29
29
  with patch("flowgraph.adapters.vector_tools.np.asarray", side_effect=check_shared_storage):
30
30
  result = EXTRACT_VECTOR_VALUE.executor({"vector": vector}, {"index": index})
31
- assert result == {"value": expected}
31
+ assert result == {"value": expected, "index": index}
32
32
  assert type(result["value"]) is float
33
+ assert type(result["index"]) is int
33
34
  np.testing.assert_array_equal(vector, original)
34
35
  assert vector.flags.writeable
35
36
 
@@ -37,14 +38,14 @@ def test_extract_value_without_copy_or_mutation(index, expected, dtype):
37
38
  def test_default_index_and_readonly_array():
38
39
  vector = np.array([4.0, 5.0])
39
40
  vector.flags.writeable = False
40
- assert EXTRACT_VECTOR_VALUE.executor({"vector": vector}, {}) == {"value": 4.0}
41
+ assert EXTRACT_VECTOR_VALUE.executor({"vector": vector}, {}) == {"value": 4.0, "index": 0}
41
42
  assert not vector.flags.writeable
42
43
 
43
44
 
44
45
  def test_connected_index_overrides_parameter():
45
46
  assert EXTRACT_VECTOR_VALUE.executor(
46
47
  {"vector": [10, 20], "index": np.int64(1)}, {"index": 0}
47
- ) == {"value": 20.0}
48
+ ) == {"value": 20.0, "index": 1}
48
49
 
49
50
 
50
51
  @pytest.mark.parametrize("index", [2, -3, 10**100])
@@ -82,10 +83,11 @@ def test_registration_and_catalog():
82
83
  group = next(g for g in workflow_web_catalog()["groups"] if g["label"] == "Vector Tools")
83
84
  node = next(n for n in group["nodes"] if n["id"] == EXTRACT_VECTOR_VALUE.id)
84
85
  assert node["requirements"] == ["py:numpy"]
85
- assert [(p["name"], p["data_type_id"]) for p in node["ports"]] == [
86
- ("vector", "array-1d"),
87
- ("value", "float"),
88
- ("index", "integer"),
86
+ assert [(p["direction"], p["name"], p["data_type_id"]) for p in node["ports"]] == [
87
+ ("input", "vector", "array-1d"),
88
+ ("output", "value", "float"),
89
+ ("output", "index", "integer"),
90
+ ("input", "index", "integer"),
89
91
  ]
90
92
 
91
93
 
@@ -103,7 +105,11 @@ def test_workflow_roundtrip_and_execution(tmp_path, connected_index):
103
105
  if connected_index:
104
106
  graph.add_edge(WorkflowEdge("index", "value", "extract", "index"), registry)
105
107
  graph.export_output("selected", "extract", "value", registry)
108
+ graph.export_output("selected_index", "extract", "index", registry)
106
109
  path = tmp_path / "extract.json"
107
110
  save_workflow(graph, path)
108
- result = WorkflowExecutor(registry).run(load_workflow(path, registry))
109
- assert result.node_outputs["extract"] == {"value": 30.0 if connected_index else 20.0}
111
+ loaded = load_workflow(path, registry)
112
+ value, index = (30.0, -1) if connected_index else (20.0, 1)
113
+ result = WorkflowExecutor(registry).run(loaded)
114
+ assert result.node_outputs["extract"] == {"value": value, "index": index}
115
+ assert loaded.execute({}, registry) == {"selected": value, "selected_index": index}