33
44import math
55import time
6- from typing import TYPE_CHECKING , Any
6+ from typing import TYPE_CHECKING , Any , Dict , List , Optional
77from urllib .parse import quote
88
99from .errors import ExecutionTimeout
@@ -24,63 +24,63 @@ def __init__(self, client: Subfork):
2424
2525
2626class Nodes (Resource ):
27- def list (self , * , include_all_versions : bool = False ) -> list [ dict [str , Any ]]:
27+ def list (self , * , include_all_versions : bool = False ) -> List [ Dict [str , Any ]]:
2828 return self ._client ._request ('GET' , '/nodes' , params = {'include_all_versions' : include_all_versions })
2929
30- def get (self , node_id : str ) -> dict [str , Any ]:
30+ def get (self , node_id : str ) -> Dict [str , Any ]:
3131 return self ._client ._request ('GET' , '/nodes/' + segment (node_id ))
3232
3333
3434class Graphs (Resource ):
35- def list (self ) -> list [ dict [str , Any ]]:
35+ def list (self ) -> List [ Dict [str , Any ]]:
3636 return self ._client ._request ('GET' , '/graphs' )
3737
38- def get (self , graph_id : str ) -> dict [str , Any ]:
38+ def get (self , graph_id : str ) -> Dict [str , Any ]:
3939 return self ._client ._request ('GET' , '/graphs/' + segment (graph_id ))
4040
41- def validate (self , definition : dict [str , Any ], * , name : str | None = None ) -> dict [str , Any ]:
41+ def validate (self , definition : Dict [str , Any ], * , name : Optional [ str ] = None ) -> Dict [str , Any ]:
4242 return self ._client ._request ('POST' , '/graphs/validate' , json = {
4343 'name' : name if name is not None else definition .get ('name' , 'Untitled Graph' ), 'definition' : definition })
4444
45- def create (self , * , name : str , definition : dict [str , Any ], description : str = '' , tags : list [ str ] | None = None ) -> dict [str , Any ]:
45+ def create (self , * , name : str , definition : Dict [str , Any ], description : str = '' , tags : Optional [ List [ str ]] = None ) -> Dict [str , Any ]:
4646 return self ._client ._request ('POST' , '/graphs' , json = {
4747 'name' : name , 'description' : description , 'definition' : definition , 'tags' : tags or []})
4848
49- def update (self , graph_id : str , * , name : str , definition : dict [str , Any ], description : str = '' ) -> dict [str , Any ]:
49+ def update (self , graph_id : str , * , name : str , definition : Dict [str , Any ], description : str = '' ) -> Dict [str , Any ]:
5050 return self ._client ._request ('PUT' , '/graphs/' + segment (graph_id ), json = {
5151 'name' : name , 'description' : description , 'definition' : definition })
5252
53- def published (self ) -> list [ dict [str , Any ]]:
53+ def published (self ) -> List [ Dict [str , Any ]]:
5454 return self ._client ._request ('GET' , '/graphs/published' )
5555
56- def versions (self , graph_id : str ) -> list [ dict [str , Any ]]:
56+ def versions (self , graph_id : str ) -> List [ Dict [str , Any ]]:
5757 return self ._client ._request ('GET' , '/graphs/' + segment (graph_id ) + '/versions' )
5858
59- def published_version (self , graph_id : str , version : str ) -> dict [str , Any ]:
59+ def published_version (self , graph_id : str , version : str ) -> Dict [str , Any ]:
6060 return self ._client ._request ('GET' , '/graphs/published/' + segment (graph_id ) + '/versions/' + segment (version ))
6161
62- def interface (self , graph_id : str ) -> dict [str , Any ]:
62+ def interface (self , graph_id : str ) -> Dict [str , Any ]:
6363 return self ._client ._request ('GET' , '/graphs/' + segment (graph_id ) + '/interface-preview' )
6464
65- def publish (self , graph_id : str , * , version : str , interface : dict [ str , Any ] | None = None , comment : str = '' ) -> dict [str , Any ]:
66- payload : dict [str , Any ] = {'version' : version , 'comment' : comment }
65+ def publish (self , graph_id : str , * , version : str , interface : Optional [ Dict [ str , Any ]] = None , comment : str = '' ) -> Dict [str , Any ]:
66+ payload : Dict [str , Any ] = {'version' : version , 'comment' : comment }
6767 if interface is not None :
6868 payload ['interface' ] = interface
6969 return self ._client ._request ('POST' , '/graphs/' + segment (graph_id ) + '/versions' , json = payload )
7070
71- def execute (self , graph_id : str , * , version : str = 'draft' , inputs : dict [ str , Any ] | None = None ) -> dict [str , Any ]:
71+ def execute (self , graph_id : str , * , version : str = 'draft' , inputs : Optional [ Dict [ str , Any ]] = None ) -> Dict [str , Any ]:
7272 return self ._client ._request ('POST' , '/graphs/' + segment (graph_id ) + '/execute' ,
7373 params = {'version' : version }, json = {'inputs' : inputs or {}})
7474
7575
7676class Executions (Resource ):
77- def get (self , execution_id : str ) -> dict [str , Any ]:
77+ def get (self , execution_id : str ) -> Dict [str , Any ]:
7878 return self ._client ._request ('GET' , '/executions/' + segment (execution_id ))
7979
80- def cancel (self , execution_id : str ) -> dict [str , Any ]:
80+ def cancel (self , execution_id : str ) -> Dict [str , Any ]:
8181 return self ._client ._request ('POST' , '/executions/' + segment (execution_id ) + '/cancel' )
8282
83- def wait (self , execution_id : str , * , timeout : float = 120 , poll_interval : float = 2 ) -> dict [str , Any ]:
83+ def wait (self , execution_id : str , * , timeout : float = 120 , poll_interval : float = 2 ) -> Dict [str , Any ]:
8484 if not math .isfinite (timeout ) or timeout <= 0 or not math .isfinite (poll_interval ) or poll_interval <= 0 :
8585 raise ValueError ('timeout and poll_interval must be positive finite numbers.' )
8686 deadline = time .monotonic () + timeout
0 commit comments