@@ -113,6 +113,8 @@ def logger(body="", system_msg=False, head="", bad=False, timestamp=True, nl=Tru
113
113
"step" : "metaflow.cli_components.step_cmd.step" ,
114
114
"run" : "metaflow.cli_components.run_cmds.run" ,
115
115
"resume" : "metaflow.cli_components.run_cmds.resume" ,
116
+ "spin" : "metaflow.cli_components.run_cmds.spin" ,
117
+ "spin-internal" : "metaflow.cli_components.step_cmd.spin_internal" ,
116
118
},
117
119
)
118
120
def cli (ctx ):
@@ -151,7 +153,7 @@ def show(obj):
151
153
echo_always ("\n %s" % obj .graph .doc )
152
154
for node_name in obj .graph .sorted_nodes :
153
155
node = obj .graph [node_name ]
154
- echo_always ("\n Step *%s*" % node .name , err = False )
156
+ echo_always ("\n Step *%s* and type: *%s* " % ( node .name , node . type ) , err = False )
155
157
echo_always (node .doc if node .doc else "?" , indent = True , err = False )
156
158
if node .type != "end" :
157
159
echo_always (
@@ -349,7 +351,6 @@ def start(
349
351
)
350
352
351
353
ctx .obj .datastore_impl .datastore_root = datastore_root
352
-
353
354
FlowDataStore .default_storage_impl = ctx .obj .datastore_impl
354
355
355
356
# At this point, we are able to resolve the user-configuration options so we can
@@ -439,14 +440,10 @@ def start(
439
440
ctx .obj .event_logger = LOGGING_SIDECARS [event_logger ](
440
441
flow = ctx .obj .flow , env = ctx .obj .environment
441
442
)
442
- ctx .obj .event_logger .start ()
443
- _system_logger .init_system_logger (ctx .obj .flow .name , ctx .obj .event_logger )
444
443
445
444
ctx .obj .monitor = MONITOR_SIDECARS [monitor ](
446
445
flow = ctx .obj .flow , env = ctx .obj .environment
447
446
)
448
- ctx .obj .monitor .start ()
449
- _system_monitor .init_system_monitor (ctx .obj .flow .name , ctx .obj .monitor )
450
447
451
448
ctx .obj .metadata = [m for m in METADATA_PROVIDERS if m .TYPE == metadata ][0 ](
452
449
ctx .obj .environment , ctx .obj .flow , ctx .obj .event_logger , ctx .obj .monitor
@@ -461,6 +458,44 @@ def start(
461
458
)
462
459
463
460
ctx .obj .config_options = config_options
461
+ ctx .obj .is_spin = False
462
+
463
+ # Override values for spin
464
+ if hasattr (ctx , "saved_args" ) and ctx .saved_args and "spin" in ctx .saved_args [0 ]:
465
+ # For spin, we will only use the local metadata provider, datastore, environment
466
+ # and null event logger and monitor
467
+ ctx .obj .is_spin = True
468
+ ctx .obj .spin_metadata = [m for m in METADATA_PROVIDERS if m .TYPE == "local" ][0 ](
469
+ ctx .obj .environment , ctx .obj .flow , ctx .obj .event_logger , ctx .obj .monitor
470
+ )
471
+ # ctx.obj.event_logger = LOGGING_SIDECARS["nullSidecarLogger"](
472
+ # flow=ctx.obj.flow, env=ctx.obj.environment
473
+ # )
474
+ # ctx.obj.monitor = MONITOR_SIDECARS["nullSidecarMonitor"](
475
+ # flow=ctx.obj.flow, env=ctx.obj.environment
476
+ # )
477
+ # ctx.obj.spin_datastore_impl = [d for d in DATASTORES if d.TYPE == "local"][0]
478
+ ctx .obj .spin_datastore_impl = [d for d in DATASTORES if d .TYPE == "s3" ][0 ]
479
+ if datastore_root is None :
480
+ datastore_root = ctx .obj .spin_datastore_impl .get_datastore_root_from_config (
481
+ ctx .obj .echo
482
+ )
483
+ ctx .obj .spin_datastore_impl .datastore_root = datastore_root
484
+ ctx .obj .spin_flow_datastore = FlowDataStore (
485
+ ctx .obj .flow .name ,
486
+ ctx .obj .environment , # Same environment as run/resume
487
+ ctx .obj .spin_metadata , # local metadata provider
488
+ ctx .obj .event_logger , # null event logger
489
+ ctx .obj .monitor , # null monitor
490
+ storage_impl = ctx .obj .spin_datastore_impl ,
491
+ )
492
+
493
+ # Start event logger and monitor
494
+ ctx .obj .event_logger .start ()
495
+ _system_logger .init_system_logger (ctx .obj .flow .name , ctx .obj .event_logger )
496
+
497
+ ctx .obj .monitor .start ()
498
+ _system_monitor .init_system_monitor (ctx .obj .flow .name , ctx .obj .monitor )
464
499
465
500
decorators ._init (ctx .obj .flow )
466
501
@@ -470,14 +505,14 @@ def start(
470
505
ctx .obj .flow ,
471
506
ctx .obj .graph ,
472
507
ctx .obj .environment ,
473
- ctx .obj .flow_datastore ,
474
- ctx .obj .metadata ,
508
+ ctx .obj .flow_datastore if not ctx . obj . is_spin else ctx . obj . spin_flow_datastore ,
509
+ ctx .obj .metadata if not ctx . obj . is_spin else ctx . obj . spin_metadata ,
475
510
ctx .obj .logger ,
476
511
echo ,
477
512
deco_options ,
478
513
)
479
514
480
- # In the case of run/resume, we will want to apply the TL decospecs
515
+ # In the case of run/resume/spin , we will want to apply the TL decospecs
481
516
# *after* the run decospecs so that they don't take precedence. In other
482
517
# words, for the same decorator, we want `myflow.py run --with foo` to
483
518
# take precedence over any other `foo` decospec
@@ -493,7 +528,7 @@ def start(
493
528
parameters .set_parameter_context (
494
529
ctx .obj .flow .name ,
495
530
ctx .obj .echo ,
496
- ctx .obj .flow_datastore ,
531
+ ctx .obj .flow_datastore if not ctx . obj . is_spin else ctx . obj . spin_flow_datastore ,
497
532
{
498
533
k : ConfigValue (v )
499
534
for k , v in ctx .obj .flow .__class__ ._flow_state .get (
@@ -505,9 +540,9 @@ def start(
505
540
if (
506
541
hasattr (ctx , "saved_args" )
507
542
and ctx .saved_args
508
- and ctx .saved_args [0 ] not in ("run" , "resume" )
543
+ and ctx .saved_args [0 ] not in ("run" , "resume" , "spin" )
509
544
):
510
- # run/resume are special cases because they can add more decorators with --with,
545
+ # run/resume/spin are special cases because they can add more decorators with --with,
511
546
# so they have to take care of themselves.
512
547
all_decospecs = ctx .obj .tl_decospecs + list (
513
548
ctx .obj .environment .decospecs () or []
0 commit comments