sier2 0.40__tar.gz → 1.0.0__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.
- {sier2-0.40 → sier2-1.0.0}/PKG-INFO +1 -1
- {sier2-0.40 → sier2-1.0.0}/pyproject.toml +1 -1
- {sier2-0.40 → sier2-1.0.0}/src/sier2/_block.py +1 -1
- {sier2-0.40 → sier2-1.0.0}/src/sier2/_dag.py +11 -13
- {sier2-0.40 → sier2-1.0.0}/src/sier2/panel/_panel.py +19 -5
- sier2-1.0.0/src/sier2/panel/tabulator_test.py +25 -0
- {sier2-0.40 → sier2-1.0.0}/LICENSE +0 -0
- {sier2-0.40 → sier2-1.0.0}/README.rst +0 -0
- {sier2-0.40 → sier2-1.0.0}/src/sier2/__init__.py +0 -0
- {sier2-0.40 → sier2-1.0.0}/src/sier2/__main__.py +0 -0
- {sier2-0.40 → sier2-1.0.0}/src/sier2/_config.py +0 -0
- {sier2-0.40 → sier2-1.0.0}/src/sier2/_library.py +0 -0
- {sier2-0.40 → sier2-1.0.0}/src/sier2/_logger.py +0 -0
- {sier2-0.40 → sier2-1.0.0}/src/sier2/_util.py +0 -0
- {sier2-0.40 → sier2-1.0.0}/src/sier2/_version.py +0 -0
- {sier2-0.40 → sier2-1.0.0}/src/sier2/panel/__init__.py +0 -0
- {sier2-0.40 → sier2-1.0.0}/src/sier2/panel/_chart.py +0 -0
- {sier2-0.40 → sier2-1.0.0}/src/sier2/panel/_feedlogger.py +0 -0
- {sier2-0.40 → sier2-1.0.0}/src/sier2/panel/_panel_util.py +0 -0
|
@@ -70,7 +70,7 @@ class Block(param.Parameterized):
|
|
|
70
70
|
There are three kinds of parameters:
|
|
71
71
|
* Input parameters start with ``in_``. These parameters are set before a block is executed.
|
|
72
72
|
* Output parameters start with ``out_``. The block sets these in its ``execute()`` method.
|
|
73
|
-
* Block parameters start with ``block_``.
|
|
73
|
+
* Block parameters start with ``block_``. These are reserved for use by blocks.
|
|
74
74
|
|
|
75
75
|
A typical block will have at least one input parameter, and an ``execute()``
|
|
76
76
|
method that is called when an input parameter value changes.
|
|
@@ -38,9 +38,7 @@ class _InputValues:
|
|
|
38
38
|
dst: Block
|
|
39
39
|
|
|
40
40
|
# The values to be set before the block executes.
|
|
41
|
-
#
|
|
42
|
-
# For an input block, if values is non-empty, prepare()
|
|
43
|
-
# will be called, else execute() will be called
|
|
41
|
+
# Values will be non-empty when execute() is called.
|
|
44
42
|
#
|
|
45
43
|
values: dict[str, Any] = field(default_factory=dict)
|
|
46
44
|
|
|
@@ -304,7 +302,7 @@ class Dag:
|
|
|
304
302
|
self._block_queue.append(item)
|
|
305
303
|
|
|
306
304
|
def execute_after_input(self, block: Block, *, dag_logger=None):
|
|
307
|
-
"""Execute the dag after running ``prepare()
|
|
305
|
+
"""Execute the dag after running ``prepare()``.
|
|
308
306
|
|
|
309
307
|
After prepare() executes, and the user has possibly
|
|
310
308
|
provided input, the dag must continue with execute() in the
|
|
@@ -340,8 +338,8 @@ class Dag:
|
|
|
340
338
|
that block's execute() method.
|
|
341
339
|
|
|
342
340
|
If the current destination block's ``block_pause_execution` is True,
|
|
343
|
-
the loop will call ``block.prepare()
|
|
344
|
-
|
|
341
|
+
the loop will call ``block.prepare()``, then stop; execute()
|
|
342
|
+
will return the block that is puased on.
|
|
345
343
|
The dag can then be restarted with ``dag.execute_after_input()``,
|
|
346
344
|
using the paused block as the parameter.
|
|
347
345
|
|
|
@@ -403,17 +401,17 @@ class Dag:
|
|
|
403
401
|
'sier2_block_': f'{item.dst}'
|
|
404
402
|
}
|
|
405
403
|
|
|
406
|
-
# If
|
|
407
|
-
#
|
|
408
|
-
#
|
|
409
|
-
if is_input_block and not is_restart
|
|
404
|
+
# If we need to wait for a user, just run prepare().
|
|
405
|
+
# If we are restarting, just run execute().
|
|
406
|
+
# Otherwise, run both.
|
|
407
|
+
if is_input_block and not is_restart:
|
|
410
408
|
self.logging(g.prepare, **logging_params)()
|
|
409
|
+
elif is_restart:
|
|
410
|
+
self.logging(g.execute, **logging_params)()
|
|
411
411
|
else:
|
|
412
|
+
self.logging(g.prepare, **logging_params)()
|
|
412
413
|
self.logging(g.execute, **logging_params)()
|
|
413
414
|
|
|
414
|
-
# print(f'{is_input_block=}')
|
|
415
|
-
# print(f'{is_restart=}')
|
|
416
|
-
# print(f'{item.values=}')
|
|
417
415
|
if is_input_block and not is_restart:# and item.values:
|
|
418
416
|
# If the current destination block requires user input,
|
|
419
417
|
# stop executing the dag immediately, because we don't
|
|
@@ -4,9 +4,11 @@ import html
|
|
|
4
4
|
import panel as pn
|
|
5
5
|
import sys
|
|
6
6
|
import threading
|
|
7
|
+
import warnings
|
|
7
8
|
from typing import Callable
|
|
8
9
|
|
|
9
10
|
import param.parameterized as paramp
|
|
11
|
+
from param.parameters import DataFrame
|
|
10
12
|
|
|
11
13
|
from sier2 import Block, BlockValidateError, BlockState, Dag, BlockError
|
|
12
14
|
from .._dag import _InputValues
|
|
@@ -252,7 +254,7 @@ def _prepare_to_show(dag: Dag):
|
|
|
252
254
|
|
|
253
255
|
cards.extend(BlockCard(parent_template=template, dag=dag, w=gw, dag_logger=dag_logger) for gw in dag.get_sorted() if gw.block_visible)
|
|
254
256
|
|
|
255
|
-
template.main.append(pn.Column(*cards))
|
|
257
|
+
template.main.append(pn.panel(pn.Column(*cards)))
|
|
256
258
|
template.sidebar.append(
|
|
257
259
|
pn.Column(
|
|
258
260
|
switch,
|
|
@@ -302,14 +304,26 @@ def _serveable_dag(dag: Dag):
|
|
|
302
304
|
template.servable()
|
|
303
305
|
|
|
304
306
|
def _default_panel(self) -> Callable[[Block], pn.Param]:
|
|
305
|
-
"""Provide a default __panel__() implementation for blocks that don't have one.
|
|
307
|
+
"""Provide a default __panel__() implementation for blocks that don't have one.param.parameters.
|
|
306
308
|
|
|
307
309
|
This default will display the in_ parameters.
|
|
308
310
|
"""
|
|
309
|
-
|
|
311
|
+
|
|
310
312
|
in_names = [name for name in self.param.values() if name.startswith('in_')]
|
|
311
313
|
|
|
312
|
-
|
|
314
|
+
# Check if we need tabulator installed.
|
|
315
|
+
# Ostensibly param uses the DataFrame widget if the tabulator extension isn't present,
|
|
316
|
+
# but this doesn't seem to work properly.
|
|
317
|
+
#
|
|
318
|
+
if any([isinstance(self.param[name], DataFrame) for name in in_names]):
|
|
319
|
+
if 'tabulator' not in pn.extension._loaded_extensions:
|
|
320
|
+
tabulator_warning = f'One of your blocks ({self.__class__.__name__}) requires Tabulator, a panel extension for showing data frames. You should explicitly load this with "pn.extension(\'tabulator\')" in your block'
|
|
321
|
+
warnings.warn(tabulator_warning)
|
|
322
|
+
pn.extension('tabulator')
|
|
323
|
+
|
|
324
|
+
param_pane = pn.Param(self, parameters=in_names, show_name=False)
|
|
325
|
+
|
|
326
|
+
return param_pane
|
|
313
327
|
|
|
314
328
|
class BlockCard(pn.Card):
|
|
315
329
|
"""A custom card to wrap around a block.
|
|
@@ -464,4 +478,4 @@ class PanelDag(Dag):
|
|
|
464
478
|
_show_dag(self)
|
|
465
479
|
|
|
466
480
|
def servable(self):
|
|
467
|
-
_serveable_dag(self)
|
|
481
|
+
_serveable_dag(self)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
from sier2 import Block, Connection
|
|
2
|
+
from sier2.panel import PanelDag
|
|
3
|
+
import param
|
|
4
|
+
import time
|
|
5
|
+
import pandas as pd
|
|
6
|
+
import panel as pn
|
|
7
|
+
|
|
8
|
+
class StartBlock(Block):
|
|
9
|
+
"""Starts the test dag"""
|
|
10
|
+
|
|
11
|
+
out_data = param.DataFrame()
|
|
12
|
+
|
|
13
|
+
def execute(self):
|
|
14
|
+
time.sleep(3)
|
|
15
|
+
self.out_data = pd.DataFrame({'A':[1,2,3,4], 'B':[5,6,7,8]})
|
|
16
|
+
|
|
17
|
+
class FinishBlock(Block):
|
|
18
|
+
"""Finishes the test dag"""
|
|
19
|
+
in_data = param.DataFrame()
|
|
20
|
+
|
|
21
|
+
sb = StartBlock(block_pause_execution=True)
|
|
22
|
+
fb = FinishBlock()
|
|
23
|
+
dag = PanelDag(doc='test', title='test')
|
|
24
|
+
dag.connect(sb, fb, Connection('out_data', 'in_data'))
|
|
25
|
+
dag.show()
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|