Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion resource_secretary/providers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,14 @@ def find_provider_classes(root_path=None):
yield category, obj


def discover_providers(probe=True, path=None) -> Dict[str, List[BaseProvider]]:
def discover_catalogs(probe=True, path=None):
"""
Discover catalogs, user specific and asked for groups of tools.
"""
return discover_providers(probe=probe, path=path, is_catalog=True)


def discover_providers(probe=True, path=None, is_catalog=False) -> Dict[str, List[BaseProvider]]:
"""
Recursively discovers and probes providers in subdirectories.
Returns a dictionary categorized by the subdirectory name.
Expand All @@ -61,6 +68,9 @@ def discover_providers(probe=True, path=None) -> Dict[str, List[BaseProvider]]:
# that might have accidentally left is_provider=True
try:
instance = cls()
# Loading catalogs or not
if instance.is_catalog != is_catalog:
continue
instance.category = category
if not probe or instance.probe():
if category not in catalog:
Expand Down
14 changes: 12 additions & 2 deletions resource_secretary/providers/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def wrapper(*args, **kwargs):

# Attach categorical metadata
wrapper.is_tool = True

# Right now this can be secretary or dispatch
wrapper.tool_category = category

Expand Down Expand Up @@ -52,7 +53,6 @@ def wrapper(*args, **kwargs):

def secretary_tool(func: Callable):
"""
Labels a method as a tool for discovery and status retrieval.
Used by the secretary agent primarily. We don't want the secretary to make
system changes, it's like read only.
"""
Expand All @@ -61,12 +61,18 @@ def secretary_tool(func: Callable):

def dispatch_tool(func: Callable):
"""
Labels a method as a tool for actions and state changes.
Used by the dispatcher agent to actually interact with a system (submit, cancel, etc).
"""
return _base_tool_decorator(func, "dispatch")


def workflow_tool(func: Callable):
"""
Used by the workflow agent to execute workflow steps.
"""
return _base_tool_decorator(func, "workflow")


class BaseProvider:
"""
BaseProvider is that - a base provider class. Note that we set is_provider by default
Expand All @@ -78,6 +84,10 @@ class BaseProvider:

is_provider = True

# A catalog needs to be requested on demand, usually because
# it requires additional work at probe (e.g., snakemake wrappers)
is_catalog = False

def __init__(self, *args, **kwargs):
self.tools: Dict[str, Callable] = {}
self.category: str = "unknown"
Expand Down
1 change: 1 addition & 0 deletions resource_secretary/providers/workflow/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .snakemake import SnakemakeProvider
Loading