File tree 4 files changed +16
-9
lines changed
4 files changed +16
-9
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ def __init__(
24
24
_cache_age : Optional [int ] = None ,
25
25
_cache_keys : Optional [List [str ]] = None ,
26
26
_max_retries : Optional [int ] = None ,
27
- _depends : List ["CoreNode" ] = [] ,
27
+ _depends : Optional [ List ["CoreNode" ]] = None ,
28
28
** attr ,
29
29
):
30
30
self ._out_type = out_type
@@ -35,7 +35,7 @@ def __init__(
35
35
self ._cache_age = _cache_age
36
36
self ._cache_keys = _cache_keys
37
37
self ._max_retries = _max_retries
38
- self ._depends = _depends
38
+ self ._depends = [] if _depends is None else _depends
39
39
self ._should_output_globally : bool = not hide
40
40
self .SG = nx .DiGraph ()
41
41
if attr :
@@ -54,6 +54,10 @@ def __init__(
54
54
for referenced_future in depend_node .futures_from_args :
55
55
self .futures_from_args .append (referenced_future )
56
56
57
+ @property
58
+ def explicit_depends (self ) -> List ["CoreNode" ]:
59
+ return self ._depends
60
+
57
61
@property
58
62
def dependent_futures (self ) -> List [Future ]:
59
63
return find_futures_client (self .init_attrs )
Original file line number Diff line number Diff line change @@ -89,7 +89,7 @@ class TraceOperation:
89
89
@dataclass
90
90
class TraceDirective (BaseDirective ):
91
91
op_stack : List [TraceOperation ]
92
- origin_node : Any # Should be CoreNode, but am running into circular import
92
+ origin_node : " CoreNode"
93
93
type : Literal ["trace" ] = "trace"
94
94
95
95
def to_dict (self ) -> Dict :
Original file line number Diff line number Diff line change @@ -11,13 +11,13 @@ class RunPython(CoreNode[RunPythonOut]):
11
11
def __init__ (
12
12
self ,
13
13
function : Callable ,
14
- kwargs : Dict [ str , Any ] = {} ,
14
+ kwargs = None ,
15
15
pip_install : Optional [List [str ]] = None ,
16
16
hide : bool = False ,
17
17
_cache_age : Optional [int ] = None ,
18
18
_cache_keys : Optional [List [str ]] = None ,
19
19
_max_retries : Optional [int ] = None ,
20
- _depends : List [CoreNode ] = [] ,
20
+ _depends : Optional [ List [CoreNode ]] = None ,
21
21
):
22
22
"""
23
23
Args:
@@ -41,7 +41,7 @@ def __init__(
41
41
python_version = sys .version .split ()[0 ]
42
42
super ().__init__ (
43
43
pkl_function = fn_str ,
44
- kwargs = kwargs ,
44
+ kwargs = {} if kwargs is None else kwargs ,
45
45
pip_install = pip_install ,
46
46
hide = hide ,
47
47
python_version = python_version ,
Original file line number Diff line number Diff line change 1
1
import json
2
+ from typing import Optional , Any , Dict
3
+
2
4
import zlib
3
5
import base64
4
- from typing import Any , Dict
5
6
6
7
from substrate .streaming import SubstrateStreamingResponse
7
8
@@ -21,11 +22,13 @@ def __init__(
21
22
api_key : str ,
22
23
base_url : str = "https://api.substrate.run" ,
23
24
timeout : float = 60 * 5.0 ,
24
- additional_headers : Dict [str , Any ] = {} ,
25
+ additional_headers : Optional [ Dict [str , Any ]] = None ,
25
26
):
26
27
"""
27
28
Initialize the Substrate SDK.
28
29
"""
30
+ if additional_headers is None :
31
+ additional_headers = {}
29
32
self .api_key = api_key
30
33
self ._client = APIClient (
31
34
api_key = api_key ,
@@ -98,7 +101,7 @@ def collect_nodes(node):
98
101
for node in all_nodes :
99
102
if not graph .DAG .has_node (node ):
100
103
graph .add_node (node )
101
- for depend_node in node ._depends :
104
+ for depend_node in node .explicit_depends :
102
105
graph .add_edge (depend_node , node )
103
106
graph_serialized = graph .to_dict ()
104
107
return graph_serialized
You can’t perform that action at this time.
0 commit comments