oocana 0.16.10__tar.gz → 0.16.11__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: oocana
3
- Version: 0.16.10
3
+ Version: 0.16.11
4
4
  Summary: python implement of oocana to give a context for oocana block
5
5
  License: MIT
6
6
  Requires-Python: >=3.9
@@ -11,8 +11,33 @@ from .preview import PreviewPayload, TablePreviewData, DataFrame, ShapeDataFrame
11
11
  from .data import EXECUTOR_NAME
12
12
  import os.path
13
13
  import logging
14
+ import copy
14
15
 
15
- __all__ = ["Context"]
16
+ __all__ = ["Context", "HandleDefDict"]
17
+
18
+ class HandleDefDict(TypedDict):
19
+ """a dict that represents the handle definition, used in the block schema output and input defs.
20
+ """
21
+
22
+ handle: str
23
+ """the handle of the output, should be defined in the block schema output defs, the field name is handle
24
+ """
25
+
26
+ description: str | None
27
+ """the description of the output, should be defined in the block schema output defs, the field name is description
28
+ """
29
+
30
+ json_schema: Dict[str, Any] | None
31
+ """the schema of the output, should be defined in the block schema output defs, the field name is json_schema
32
+ """
33
+
34
+ kind: str | None
35
+ """the kind of the output, should be defined in the block schema output defs, the field name is kind
36
+ """
37
+
38
+ nullable: bool
39
+ """if the output can be None, should be defined in the block schema output defs, the field name is nullable
40
+ """
16
41
 
17
42
  class OnlyEqualSelf:
18
43
  def __eq__(self, value: object) -> bool:
@@ -35,6 +60,7 @@ class Context:
35
60
 
36
61
  __block_info: BlockInfo
37
62
  __outputs_def: Dict[str, HandleDef]
63
+ __inputs_def: Dict[str, Any]
38
64
  __store: Any
39
65
  __keep_alive: OnlyEqualSelf = OnlyEqualSelf()
40
66
  __session_dir: str
@@ -44,7 +70,7 @@ class Context:
44
70
  __pkg_dir: str
45
71
 
46
72
  def __init__(
47
- self, inputs: Dict[str, Any], blockInfo: BlockInfo, mainframe: Mainframe, store, outputs, session_dir: str, tmp_dir: str, package_name: str, pkg_dir: str
73
+ self, *, inputs: Dict[str, Any], blockInfo: BlockInfo, mainframe: Mainframe, store, inputs_def, outputs_def, session_dir: str, tmp_dir: str, package_name: str, pkg_dir: str
48
74
  ) -> None:
49
75
 
50
76
  self.__block_info = blockInfo
@@ -54,10 +80,11 @@ class Context:
54
80
  self.__inputs = inputs
55
81
 
56
82
  outputs_defs = {}
57
- if outputs is not None:
58
- for k, v in outputs.items():
83
+ if outputs_def is not None:
84
+ for k, v in outputs_def.items():
59
85
  outputs_defs[k] = HandleDef(**v)
60
86
  self.__outputs_def = outputs_defs
87
+ self.__inputs_def = inputs_def
61
88
  self.__session_dir = session_dir
62
89
  self.__tmp_dir = tmp_dir
63
90
  self.__package_name = package_name
@@ -104,6 +131,17 @@ class Context:
104
131
  @property
105
132
  def inputs(self):
106
133
  return self.__inputs
134
+
135
+ @property
136
+ def inputs_def(self) -> Dict[str, HandleDefDict]:
137
+ return copy.deepcopy(self.__inputs_def) if self.__inputs_def is not None else {}
138
+
139
+ @property
140
+ def outputs_def(self) -> Dict[str, HandleDefDict]:
141
+ outputs = {}
142
+ for k, v in self.__outputs_def.items():
143
+ outputs[k] = asdict(v)
144
+ return outputs
107
145
 
108
146
  @property
109
147
  def session_id(self):
@@ -11,12 +11,18 @@ class HandleDef:
11
11
  handle: str
12
12
  """The name of the handle. it should be unique in handle list."""
13
13
 
14
+ """The description of the handle. It is used to display in the UI."""
15
+ description: Optional[str] = None
16
+
14
17
  json_schema: Optional[FieldSchema] = None
15
18
  """The schema of the handle. It is used to validate the handle's content."""
16
19
 
17
- name: Optional[str] = None
20
+ kind: Optional[str] = None
18
21
  """A alias of the handle's type name. It is used to display in the UI and connect to the other handle match"""
19
22
 
23
+ nullable: bool = False
24
+ """If the handle value can be None. If True, the handle can be None, otherwise it must have a value."""
25
+
20
26
  def __init__(self, **kwargs):
21
27
  for key, value in kwargs.items():
22
28
  object.__setattr__(self, key, value)
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "oocana"
3
- version = "0.16.10"
3
+ version = "0.16.11"
4
4
  description = "python implement of oocana to give a context for oocana block"
5
5
  dependencies = [
6
6
  "paho-mqtt>=2",
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