@@ -466,69 +466,3 @@ def get_yml_paths(config: Json) -> Dict[str, Dict[str, Path]]:
466466
467467def get_py_paths (config : Json ) -> Dict [str , Dict [str , Path ]]:
468468 return get_workflow_paths (config , 'py' )
469-
470-
471- def blindly_execute_python_workflows () -> None :
472- """This function imports (read: blindly executes) all python files in 'search_paths_wic'
473- The python files are assumed to have a top-level workflow() function
474- which returns a sophios.api.pythonapi.Workflow object.
475- The python files should NOT call the .run() method!
476- (from any code path that is automatically executed on import)
477- """
478- # I hope u like Remote Code Execution vulnerabilities!
479- # See https://en.wikipedia.org/wiki/Arithmetical_hierarchy
480- from sophios .api import pythonapi # pylint: disable=C0415:import-outside-toplevel
481- # Since this is completely different test path we have to copy
482- # default .txt files to default global_config.json
483- config_file = Path ().home ()/ 'wic' / 'global_config.json'
484- global_config = io .read_config_from_disk (config_file )
485- pythonapi .global_config = get_tools_cwl (global_config ) # Use path fallback in the CI
486- paths = get_py_paths (global_config )
487- # Above we are assuming that config is default
488- paths_tuples = [(path_str , path )
489- for namespace , paths_dict in paths .items ()
490- for path_str , path in paths_dict .items ()]
491- any_import_errors = False
492- for path_stem , path in paths_tuples :
493- if 'mm-workflows' in str (path ) or 'docs/tutorials/' in str (path ):
494- # Exclude paths that only contain 'regular' python files.
495- continue
496- # NOTE: Use anything (unique?) for the python_module_name.
497- try :
498- module = import_python_file (path_stem , path )
499- # Let's require all python API files to define a function, say
500- # def workflow() -> Workflow
501- # so we can programmatically call it here:
502- retval : pythonapi .Workflow = module .workflow () # no arguments
503- # which allows us to programmatically call Workflow methods:
504- compiler_info = retval .compile () # hopefully retval is actually a Workflow object!
505- # But since this is python (i.e. not Haskell) that in no way eliminates
506- # the above security considerations.
507-
508- # This lets us use path.parent to write a *.wic file in the
509- # auto-discovery path, and thus reuse the existing wic CI
510- retval .write_ast_to_disk (path .parent )
511-
512- # Programmatically blacklist subworkflows from running in config_ci.json
513- # (Again, because subworkflows are missing inputs and cannot run.)
514- config_ci = path .parent / 'config_ci.json'
515- json_contents = {}
516- if config_ci .exists ():
517- with open (config_ci , mode = 'r' , encoding = 'utf-8' ) as r :
518- json_contents = json .load (r )
519- run_blacklist : list [str ] = json_contents .get ('run_blacklist' , [])
520- # Use [1:] for proper subworkflows only
521- subworkflows : list [pythonapi .Workflow ] = retval .flatten_subworkflows ()[1 :]
522- run_blacklist += [wf .process_name for wf in subworkflows ]
523- json_contents ['run_blacklist' ] = run_blacklist
524- with open (config_ci , mode = 'w' , encoding = 'utf-8' ) as f :
525- json .dump (json_contents , f )
526-
527- except Exception as e :
528- any_import_errors = True
529- if sys .version_info >= (3 , 10 ):
530- traceback .print_exception (type (e ), value = e , tb = None )
531- else :
532- traceback .print_exception (etype = type (e ), value = e , tb = None )
533- if any_import_errors :
534- sys .exit (1 ) # Make sure the CI fails
0 commit comments