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
8 changes: 3 additions & 5 deletions docs/core-modules/client.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Fluidize Client
# Client Module

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

Expand All @@ -10,8 +10,7 @@ The Fluidize Client is the primary interface to create and edit projects. There
options:
show_source: false
heading_level: 3
extra:
show_root_heading: true
show_root_heading: true
members:
- mode
- adapters
Expand All @@ -22,8 +21,7 @@ The Fluidize Client is the primary interface to create and edit projects. There
options:
show_source: false
heading_level: 3
extra:
show_root_heading: true
show_root_heading: true
members:
- is_local_mode
- is_api_mode
12 changes: 5 additions & 7 deletions docs/core-modules/graph.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
options:
show_source: false
heading_level: 3
extra:
show_root_heading: true
show_root_heading: true
members:
- get
- add_node
Expand All @@ -20,30 +19,29 @@
options:
show_source: false
heading_level: 3
extra:
show_root_heading: true
show_root_heading: true

## Graph Types

::: fluidize.core.types.graph.GraphData
options:
heading_level: 3
show_root_heading: true
extra:
show_attributes: true
show_root_heading: true


::: fluidize.core.types.graph.GraphNode
options:
heading_level: 3
show_root_heading: true
extra:
show_attributes: true
show_root_heading: true


::: fluidize.core.types.graph.GraphEdge
options:
heading_level: 3
show_root_heading: true
extra:
show_attributes: true
show_root_heading: true
43 changes: 43 additions & 0 deletions docs/core-modules/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Core Modules

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.

## [Client](client.md)

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.

## [Projects](projects.md)

The **Projects** module provides tools for managing project lifecycles:

- [**Registry Manager**](projects.md#fluidize.managers.registry.RegistryManager):
Handles the user’s complete project registry, with functionality to create, edit, and delete projects.

- [**Project Manager**](projects.md#fluidize.managers.project.ProjectManager):
Focuses on individual projects, managing the project graph, nodes, and runs, and supporting execution of project-specific workflows.

## [Graph](graph.md)

The **Graph** module provides tools for managing the project graph, which is a representation of the simulation pipeline.

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:

- [**Graph Manager**](graph.md#fluidize.managers.graph.GraphManager):
Manages the project graph, and provides high level functionality to create, edit, and delete nodes and edges.

- [**Graph Processor**](graph.md#fluidize.managers.graph.graph_processor.GraphProcessor):
Manages specific operations on the graph data structure within the local filesystem.

## [Node](node.md)

The **Node** module provides tools for managing the metadata, properties, and parameters of individual nodes within a project.

## [Run](run.md)

The **Run** module provides tools for managing simulation pipeline runs within a project:

- [**Runs Manager**](run.md#fluidize.managers.run.RunsManager):
Manages the high level execution of runs and retrieving run status.

- [**Project Runner**](run.md#fluidize.core.modules.run.project.ProjectRunner):
Manages the specific execution details of a project pipeline, including environment preparation and node execution order.
7 changes: 7 additions & 0 deletions docs/core-modules/node.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Node Module

::: fluidize.managers.node.NodeManager
options:
show_source: false
heading_level: 3
show_root_heading: true
6 changes: 2 additions & 4 deletions docs/core-modules/projects.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@
options:
show_source: false
heading_level: 3
extra:
show_root_heading: true
show_root_heading: true

## Project
::: fluidize.managers.project.ProjectManager
options:
show_source: false
heading_level: 3
extra:
show_root_heading: true
show_root_heading: true
10 changes: 4 additions & 6 deletions docs/core-modules/run.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
options:
show_source: false
heading_level: 3
extra:
show_root_heading: true
show_root_heading: true
members:
- run_flow
- list
Expand All @@ -19,12 +18,11 @@
options:
show_source: false
heading_level: 3
extra:
show_root_heading: true
show_signature: false
show_root_heading: true

::: fluidize.core.modules.run.project.ProjectRunner
options:
show_source: false
heading_level: 3
extra:
show_root_heading: true
show_root_heading: true
14 changes: 14 additions & 0 deletions fluidize/core/modules/run/node/node_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@

# RunJob now uses a strategy instance to dynamically choose behavior.
class RunJob:
"""
A job that runs for a single node.
"""

def __init__(
self,
project: ProjectSummary,
Expand All @@ -18,6 +22,16 @@ def __init__(
run_id: Optional[str] = None,
run_metadata: Optional[object] = None, # Add run metadata
):
"""
Args:
project: The project this node belongs to
strategyClass: The strategy class to use for execution
nodeProperties_simulation: The node properties to run
prev_nodeProperties_simulation: The previous node properties (optional)
mlflow_tracker: The MLflow tracker (optional)
run_id: The run ID (optional)
run_metadata: The run metadata (optional)
"""
self.project = project
self.nodeProperties_simulation = nodeProperties_simulation
self.prev_nodeProperties_simulation = prev_nodeProperties_simulation
Expand Down
4 changes: 2 additions & 2 deletions fluidize/core/types/file_models/file_model_base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from typing import Any, TypeVar, Union
from typing import Any, Optional, TypeVar, Union

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

@classmethod
def from_dict_and_path(cls: type[T], data: dict, path: UPath) -> T:
def from_dict_and_path(cls: type[T], data: Any, path: Optional[UPath]) -> T:
"""Creates a model instance from a dictionary and a path, without reading the file again."""
if not data:
raise ValueError()
Expand Down
14 changes: 6 additions & 8 deletions fluidize/managers/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ class NodeManager:

def __init__(self, adapter: Any, project: ProjectSummary, node_id: str) -> None:
"""
Initialize node-scoped manager.

Args:
adapter: adapter adapter (FluidizeSDK or Localadapter)
project: The project this node belongs to
Expand Down Expand Up @@ -268,13 +266,13 @@ def update_parameter(self, parameter: Parameter) -> Parameter:

def set_parameters(self, parameters: list[Parameter]) -> list[Parameter]:
"""
Replace all parameters with the provided list.
Replace all parameters with the provided list.

Args:
parameters: List of parameters to set

Args:
parameters: List of parameters to set
W
Returns:
The list of parameters that were set
Returns:
The list of parameters that were set
"""
parameters_model = self.get_parameters_model()
parameters_model.parameters = parameters
Expand Down
33 changes: 33 additions & 0 deletions fluidize/managers/simulations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from typing import Any

from fluidize_sdk import FluidizeSDK

from fluidize.core.types.node import nodeMetadata_simulation


class SimulationsManager:
"""
Simulations manager that provides access to the Fluidize simulation library.
"""

def __init__(self, adapter: Any) -> None:
"""
Args:
adapter: adapter (FluidizeSDK or LocalAdapter)
"""
self._adapter = adapter
# TODO: Fix hardcoding of api_token and remove type ignore
self.fluidize_sdk = FluidizeSDK(api_token="placeholder") # noqa: S106

def list_simulations(self) -> list[Any]:
"""
List all simulations available in the Fluidize simulation library.

Returns:
List of simulation metadata
"""
simulations = self.fluidize_sdk.simulation.list_simulations(sim_global=True)
return [
nodeMetadata_simulation.from_dict_and_path(data=simulation.model_dump(), path=None)
for simulation in simulations
]
2 changes: 2 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ nav:
- Quickstart: getting-started/quickstart.md
- Examples: getting-started/examples.md
- Core Modules:
- core-modules/index.md
- Client: core-modules/client.md
- Projects: core-modules/projects.md
- Graph: core-modules/graph.md
- Node: core-modules/node.md
- Run: core-modules/run.md
plugins:
- search
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ classifiers = [
dependencies = [
"asciitree>=0.3.3",
"docker>=7.1.0",
"fluidize-sdk>=0.4.0",
"fluidize-sdk>=0.6.0",
"jinja2>=3.1.6",
"mlflow>=3.1.4",
"networkx>=3.2.1",
Expand Down
40 changes: 40 additions & 0 deletions tests/integration/test_simulations_manager.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
"""Integration tests for SimulationsManager - tests real API connectivity."""

import pytest

from fluidize.managers.simulations import SimulationsManager


class TestSimulationsManagerIntegration:
"""Integration test suite for SimulationsManager class."""

@pytest.fixture
def mock_adapter(self):
"""Create a mock adapter for testing."""
from unittest.mock import Mock

adapter = Mock()
return adapter

def test_list_simulations_integration(self, mock_adapter):
"""Integration test that actually calls the API and prints output."""

# Create manager without mocking SDK
manager = SimulationsManager(mock_adapter)

# Act - make real API call
result = manager.list_simulations()

# Assert basic functionality
assert isinstance(result, list)

# Print results for manual verification
print("\n=== Integration Test Results ===")
print(f"Number of simulations found: {len(result)}")
for sim in result:
print("Simulation details:")
print(f" Name: {sim.name}")
print(f" ID: {sim.id}")
print(f" Description: {sim.description}")
print(f" Version: {sim.version}")
print("\n")
Loading