@@ -308,21 +308,33 @@ def __init__(self, name_version_url: str, new_setup: bool = False):
308308
309309 def registered_workflows (self ) -> Dict [str , Dict ]:
310310 """
311- Parses :attr:`.registration` to return a dict of registered
312- compatible workflows, where the keys are workflow names.
311+ Parses :attr:`.registration` to return a dict of registered workflows,
312+ where the keys are workflow names.
313313 """
314314 if self .registration is None :
315315 debug ("pathogen does not have a registration" )
316316 return {}
317317
318- workflows = self .registration .get ("compatibility" , {}). get ( "nextstrain run " )
318+ workflows = self .registration .get ("workflows " )
319319 if not isinstance (workflows , dict ):
320- debug (f"pathogen registration.compatibility['nextstrain runs'] is not a dict (got a { type (workflows ).__name__ } )" )
320+ debug (f"pathogen registration.workflows is not a dict (got a { type (workflows ).__name__ } )" )
321321 return {}
322322
323323 return workflows
324324
325325
326+ def compatible_workflows (self , feature : str ) -> Dict [str , Dict ]:
327+ """
328+ Filters registered workflows to return a subset of workflows that are
329+ compatible with the provided *feature*.
330+ """
331+ return {
332+ name : info
333+ for name , info in self .registered_workflows ().items ()
334+ if isinstance (info , dict ) and info .get ("compatibility" , {}).get (feature )
335+ }
336+
337+
326338 def workflow_path (self , workflow : str ) -> Path :
327339 return self .path / workflow
328340
@@ -498,20 +510,13 @@ def test_compatibility() -> SetupTestResult:
498510 if self .registration is None :
499511 return msg + "\n (couldn't read registration)" , False
500512
501- try :
502- compatibility = self .registration ["compatibility" ]["nextstrain run" ]
503- except (KeyError , IndexError , TypeError ):
504- if DEBUGGING :
505- traceback .print_exc ()
506- return msg + "\n (couldn't find 'compatibility: nextstrain run: …' field)" , False
507-
508- if compatibility :
509- if workflows := self .registered_workflows ():
510- msg += f"\n Available workflows: { list (workflows .keys ())} "
511- else :
512- msg += f"\n No workflows listed, please refer to pathogen docs."
513+ if not self .registered_workflows ():
514+ return msg + "\n (no workflows registered)" , False
513515
514- return msg , bool (compatibility )
516+ if not self .compatible_workflows ("nextstrain run" ):
517+ return msg + "\n (no workflows registered as compatible)" , False
518+
519+ return msg , True
515520
516521 return [
517522 ('downloaded' ,
@@ -521,6 +526,9 @@ def test_compatibility() -> SetupTestResult:
521526 self .registration_path .is_file ()),
522527
523528 test_compatibility (),
529+
530+ * ((f'`nextstrain run` workflow { name !r} exists' , self .workflow_path (name ).is_dir ())
531+ for name in self .compatible_workflows ("nextstrain run" )),
524532 ]
525533
526534
@@ -690,6 +698,7 @@ def __init__(self, path: str):
690698 self .registration = read_pathogen_registration (self .registration_path )
691699
692700 registered_workflows = PathogenVersion .registered_workflows
701+ compatible_workflows = PathogenVersion .compatible_workflows
693702 workflow_path = PathogenVersion .workflow_path
694703
695704 def __str__ (self ) -> str :
0 commit comments