Skip to content

Commit e1e1b37

Browse files
authored
Merge pull request #16 from Fluidize-Inc/simulation-library
Simulation library management
2 parents ec05b32 + a514635 commit e1e1b37

15 files changed

Lines changed: 253 additions & 37 deletions

File tree

docs/core-modules/client.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Fluidize Client
1+
# Client Module
22

33
The Fluidize Client is the primary interface to create and edit projects. There are two interfaces for this, with more on the way.
44

@@ -10,8 +10,7 @@ The Fluidize Client is the primary interface to create and edit projects. There
1010
options:
1111
show_source: false
1212
heading_level: 3
13-
extra:
14-
show_root_heading: true
13+
show_root_heading: true
1514
members:
1615
- mode
1716
- adapters
@@ -22,8 +21,7 @@ The Fluidize Client is the primary interface to create and edit projects. There
2221
options:
2322
show_source: false
2423
heading_level: 3
25-
extra:
26-
show_root_heading: true
24+
show_root_heading: true
2725
members:
2826
- is_local_mode
2927
- is_api_mode

docs/core-modules/graph.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
options:
66
show_source: false
77
heading_level: 3
8-
extra:
9-
show_root_heading: true
8+
show_root_heading: true
109
members:
1110
- get
1211
- add_node
@@ -20,30 +19,29 @@
2019
options:
2120
show_source: false
2221
heading_level: 3
23-
extra:
24-
show_root_heading: true
22+
show_root_heading: true
2523

2624
## Graph Types
2725

2826
::: fluidize.core.types.graph.GraphData
2927
options:
3028
heading_level: 3
29+
show_root_heading: true
3130
extra:
3231
show_attributes: true
33-
show_root_heading: true
3432

3533

3634
::: fluidize.core.types.graph.GraphNode
3735
options:
3836
heading_level: 3
37+
show_root_heading: true
3938
extra:
4039
show_attributes: true
41-
show_root_heading: true
4240

4341

4442
::: fluidize.core.types.graph.GraphEdge
4543
options:
4644
heading_level: 3
45+
show_root_heading: true
4746
extra:
4847
show_attributes: true
49-
show_root_heading: true

docs/core-modules/index.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Core Modules
2+
3+
The Fluidize library is composed of a set of core modules that provide a high-level interface for managing Fluidize resources. These modules are designed to be used together to build and execute scientific computing pipelines.
4+
5+
## [Client](client.md)
6+
7+
The **Fluidize Client** provides a unified, high-level interface for managing Fluidize resources in both local and cloud API modes. It serves as the primary entry point for creating and running pipelines across these environments.
8+
9+
## [Projects](projects.md)
10+
11+
The **Projects** module provides tools for managing project lifecycles:
12+
13+
- [**Registry Manager**](projects.md#fluidize.managers.registry.RegistryManager):
14+
Handles the user’s complete project registry, with functionality to create, edit, and delete projects.
15+
16+
- [**Project Manager**](projects.md#fluidize.managers.project.ProjectManager):
17+
Focuses on individual projects, managing the project graph, nodes, and runs, and supporting execution of project-specific workflows.
18+
19+
## [Graph](graph.md)
20+
21+
The **Graph** module provides tools for managing the project graph, which is a representation of the simulation pipeline.
22+
23+
In a Fluidize project, pipelines are represented as a directed acyclic graph (DAG) where each node represents a module simulation and each edge represents the flow of data between nodes:
24+
25+
- [**Graph Manager**](graph.md#fluidize.managers.graph.GraphManager):
26+
Manages the project graph, and provides high level functionality to create, edit, and delete nodes and edges.
27+
28+
- [**Graph Processor**](graph.md#fluidize.managers.graph.graph_processor.GraphProcessor):
29+
Manages specific operations on the graph data structure within the local filesystem.
30+
31+
## [Node](node.md)
32+
33+
The **Node** module provides tools for managing the metadata, properties, and parameters of individual nodes within a project.
34+
35+
## [Run](run.md)
36+
37+
The **Run** module provides tools for managing simulation pipeline runs within a project:
38+
39+
- [**Runs Manager**](run.md#fluidize.managers.run.RunsManager):
40+
Manages the high level execution of runs and retrieving run status.
41+
42+
- [**Project Runner**](run.md#fluidize.core.modules.run.project.ProjectRunner):
43+
Manages the specific execution details of a project pipeline, including environment preparation and node execution order.

docs/core-modules/node.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Node Module
2+
3+
::: fluidize.managers.node.NodeManager
4+
options:
5+
show_source: false
6+
heading_level: 3
7+
show_root_heading: true

docs/core-modules/projects.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@
55
options:
66
show_source: false
77
heading_level: 3
8-
extra:
9-
show_root_heading: true
8+
show_root_heading: true
109

1110
## Project
1211
::: fluidize.managers.project.ProjectManager
1312
options:
1413
show_source: false
1514
heading_level: 3
16-
extra:
17-
show_root_heading: true
15+
show_root_heading: true

docs/core-modules/run.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
options:
77
show_source: false
88
heading_level: 3
9-
extra:
10-
show_root_heading: true
9+
show_root_heading: true
1110
members:
1211
- run_flow
1312
- list
@@ -19,12 +18,11 @@
1918
options:
2019
show_source: false
2120
heading_level: 3
22-
extra:
23-
show_root_heading: true
21+
show_signature: false
22+
show_root_heading: true
2423

2524
::: fluidize.core.modules.run.project.ProjectRunner
2625
options:
2726
show_source: false
2827
heading_level: 3
29-
extra:
30-
show_root_heading: true
28+
show_root_heading: true

fluidize/core/modules/run/node/node_runner.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88

99
# RunJob now uses a strategy instance to dynamically choose behavior.
1010
class RunJob:
11+
"""
12+
A job that runs for a single node.
13+
"""
14+
1115
def __init__(
1216
self,
1317
project: ProjectSummary,
@@ -18,6 +22,16 @@ def __init__(
1822
run_id: Optional[str] = None,
1923
run_metadata: Optional[object] = None, # Add run metadata
2024
):
25+
"""
26+
Args:
27+
project: The project this node belongs to
28+
strategyClass: The strategy class to use for execution
29+
nodeProperties_simulation: The node properties to run
30+
prev_nodeProperties_simulation: The previous node properties (optional)
31+
mlflow_tracker: The MLflow tracker (optional)
32+
run_id: The run ID (optional)
33+
run_metadata: The run metadata (optional)
34+
"""
2135
self.project = project
2236
self.nodeProperties_simulation = nodeProperties_simulation
2337
self.prev_nodeProperties_simulation = prev_nodeProperties_simulation

fluidize/core/types/file_models/file_model_base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import annotations
22

3-
from typing import Any, TypeVar, Union
3+
from typing import Any, Optional, TypeVar, Union
44

55
from pydantic import BaseModel, ConfigDict, PrivateAttr, ValidationError
66
from upath import UPath
@@ -49,7 +49,7 @@ def from_file(cls: type[T], directory: Union[str, UPath]) -> T:
4949
return instance
5050

5151
@classmethod
52-
def from_dict_and_path(cls: type[T], data: dict, path: UPath) -> T:
52+
def from_dict_and_path(cls: type[T], data: Any, path: Optional[UPath]) -> T:
5353
"""Creates a model instance from a dictionary and a path, without reading the file again."""
5454
if not data:
5555
raise ValueError()

fluidize/managers/node.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ class NodeManager:
2424

2525
def __init__(self, adapter: Any, project: ProjectSummary, node_id: str) -> None:
2626
"""
27-
Initialize node-scoped manager.
28-
2927
Args:
3028
adapter: adapter adapter (FluidizeSDK or Localadapter)
3129
project: The project this node belongs to
@@ -268,13 +266,13 @@ def update_parameter(self, parameter: Parameter) -> Parameter:
268266

269267
def set_parameters(self, parameters: list[Parameter]) -> list[Parameter]:
270268
"""
271-
Replace all parameters with the provided list.
269+
Replace all parameters with the provided list.
270+
271+
Args:
272+
parameters: List of parameters to set
272273
273-
Args:
274-
parameters: List of parameters to set
275-
W
276-
Returns:
277-
The list of parameters that were set
274+
Returns:
275+
The list of parameters that were set
278276
"""
279277
parameters_model = self.get_parameters_model()
280278
parameters_model.parameters = parameters

fluidize/managers/simulations.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
from typing import Any
2+
3+
from fluidize_sdk import FluidizeSDK
4+
5+
from fluidize.core.types.node import nodeMetadata_simulation
6+
7+
8+
class SimulationsManager:
9+
"""
10+
Simulations manager that provides access to the Fluidize simulation library.
11+
"""
12+
13+
def __init__(self, adapter: Any) -> None:
14+
"""
15+
Args:
16+
adapter: adapter (FluidizeSDK or LocalAdapter)
17+
"""
18+
self._adapter = adapter
19+
# TODO: Fix hardcoding of api_token and remove type ignore
20+
self.fluidize_sdk = FluidizeSDK(api_token="placeholder") # noqa: S106
21+
22+
def list_simulations(self) -> list[Any]:
23+
"""
24+
List all simulations available in the Fluidize simulation library.
25+
26+
Returns:
27+
List of simulation metadata
28+
"""
29+
simulations = self.fluidize_sdk.simulation.list_simulations(sim_global=True)
30+
return [
31+
nodeMetadata_simulation.from_dict_and_path(data=simulation.model_dump(), path=None)
32+
for simulation in simulations
33+
]

0 commit comments

Comments
 (0)