12
12
class DropParser (Enum ):
13
13
RAW = "raw"
14
14
PICKLE = "pickle"
15
- EVAL = "eval"
15
+ EVAL = "eval"
16
16
NPY = "npy"
17
17
DILL = "dill"
18
18
# JSON = "json"
@@ -68,9 +68,7 @@ def serialize_applicationArgs(applicationArgs, prefix="--", separator=" "):
68
68
positional arguments and one for kw arguments that can be used to construct
69
69
the final command line.
70
70
"""
71
- applicationArgs = clean_applicationArgs (
72
- applicationArgs
73
- )
71
+ applicationArgs = clean_applicationArgs (applicationArgs )
74
72
pargs = []
75
73
kwargs = {}
76
74
for name , vdict in applicationArgs .items ():
@@ -144,7 +142,7 @@ def identify_named_ports(
144
142
if value is None :
145
143
value = "" # make sure we are passing NULL drop events
146
144
if key in positionalArgs :
147
- encoding = DropParser (positionalPortArgs [key ][' encoding' ])
145
+ encoding = DropParser (positionalPortArgs [key ][" encoding" ])
148
146
parser = get_port_reader_function (encoding )
149
147
if parser :
150
148
logger .debug ("Reading from port using %s" , parser .__repr__ ())
@@ -156,7 +154,7 @@ def identify_named_ports(
156
154
if addPositionalToKeyword :
157
155
keywordPortArgs .update ({key : positionalPortArgs [key ]})
158
156
elif key in keywordArgs :
159
- encoding = DropParser (keywordArgs [key ][' encoding' ])
157
+ encoding = DropParser (keywordArgs [key ][" encoding" ])
160
158
parser = get_port_reader_function (encoding )
161
159
if parser :
162
160
logger .debug ("Reading from port using %s" , parser .__repr__ ())
@@ -299,12 +297,14 @@ def replace_named_ports(
299
297
keywordArgs = _get_args (appArgs , positional = False )
300
298
301
299
# Extract values from dictionaries - "encoding" etc. are irrelevant
302
- appArgs = {arg : subdict ['value' ] for arg , subdict in appArgs .items ()}
303
- positionalArgs = {arg : subdict ['value' ] for arg , subdict in positionalArgs .items ()}
304
- keywordArgs = {arg : subdict ['value' ] for arg , subdict in keywordArgs .items ()}
305
- keywordPortArgs = {arg : subdict ['value' ] for arg , subdict in keywordPortArgs .items ()}
306
-
307
- # Construct the final keywordArguments and positionalPortArguments
300
+ appArgs = {arg : subdict ["value" ] for arg , subdict in appArgs .items ()}
301
+ positionalArgs = {arg : subdict ["value" ] for arg , subdict in positionalArgs .items ()}
302
+ keywordArgs = {arg : subdict ["value" ] for arg , subdict in keywordArgs .items ()}
303
+ keywordPortArgs = {
304
+ arg : subdict ["value" ] for arg , subdict in keywordPortArgs .items ()
305
+ }
306
+
307
+ # Construct the final keywordArguments and positionalPortArguments
308
308
for k , v in keywordPortArgs .items ():
309
309
if v not in [None , "" ]:
310
310
keywordArgs .update ({k : v })
@@ -376,8 +376,10 @@ def _get_args(appArgs, positional=False):
376
376
Separate out the arguments dependening on if we want positional or keyword style
377
377
"""
378
378
args = {
379
- arg : {"value" : appArgs [arg ]["value" ],
380
- "encoding" : appArgs [arg ].get ("encoding" , "dill" )}
379
+ arg : {
380
+ "value" : appArgs [arg ]["value" ],
381
+ "encoding" : appArgs [arg ].get ("encoding" , "dill" ),
382
+ }
381
383
for arg in appArgs
382
384
if (appArgs [arg ]["positional" ] == positional )
383
385
}
@@ -386,6 +388,7 @@ def _get_args(appArgs, positional=False):
386
388
logger .debug ("%s arguments: %s" , argType , args )
387
389
return args
388
390
391
+
389
392
def get_port_reader_function (input_parser : DropParser ):
390
393
"""
391
394
Return the function used to read input from a named port
@@ -413,7 +416,7 @@ def optionalEval(x):
413
416
elif input_parser is DropParser .DILL :
414
417
reader = drop_loaders .load_dill
415
418
elif input_parser is DropParser .BINARY :
416
- reader = drop_loaders .load_binary
419
+ reader = drop_loaders .load_binary
417
420
else :
418
421
raise ValueError (input_parser .__repr__ ())
419
422
return reader
0 commit comments