Example #1
0
from hopeit.dataobjects import dataclass, dataobject
from hopeit.app.events import collector_step, Collector
from hopeit.app.logger import app_extra_logger

from hopeit.config_manager import RuntimeApps, RuntimeAppInfo

from hopeit.apps_visualizer.apps import get_runtime_apps
from hopeit.apps_visualizer.graphs import Edge, Node, Graph, add_app_connections, get_edges, get_nodes
from hopeit.apps_visualizer.site.visualization import CytoscapeGraph, VisualizationOptions, \
    visualization_options, visualization_options_api_args  # noqa: F401  # pylint: disable=unused-import

logger, extra = app_extra_logger()

__steps__ = [
    'visualization_options',
    collector_step(payload=VisualizationOptions).gather(
        'runtime_apps', 'config_graph', 'cytoscape_data'),
    'build_visualization'
]


@dataobject
@dataclass
class EventsGraphResult:
    runtime_apps: RuntimeApps
    graph: CytoscapeGraph
    options: VisualizationOptions


__api__ = event_api(
    summary="App Visualizer: Events Graph Data",
    description="App Visualizer: Events Graph Data",
from hopeit.fs_storage import FileStorage, FileStorageSettings
from model import ItemsInfo, Something, SomethingNotFound


@dataobject
@dataclass
class ItemsCollected:
    """
    Collected items. Need a dataclass in order to publish to stream
    """
    items: List[Something]


__steps__ = [
    collector_step(payload=ItemsInfo).gather(
        'load_first', 'load_second', 'combine'
    ), 'result', SHUFFLE, 'spawn'
]

__api__ = event_api(
    summary="Simple Example: Collect and Spawn",
    payload=(ItemsInfo, "Items to read concurrently"),
    responses={
        200: (int, "Number of items spawned (0,1 or 2)"),
    }
)

logger, extra = app_extra_logger()
fs: Optional[FileStorage] = None