Skip to content

Commit

Permalink
FIX: entry point stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
d-krupke committed Feb 27, 2024
1 parent 2722fc2 commit b97b518
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/slurminade/dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ def dispatch(
"""
funcs = list(funcs) if not isinstance(funcs, FunctionCall) else [funcs]
for func in funcs:
if not FunctionMap.check_id(func.func_id):
if not FunctionMap.check_id(func.func_id, entry_point):
msg = f"Function '{func.func_id}' cannot be called from the given entry point."
raise KeyError(msg)
return get_dispatcher()(funcs, options, entry_point, block)
Expand Down
8 changes: 5 additions & 3 deletions src/slurminade/function_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,13 @@ def call(
return FunctionMap._data[func_id](*args, **kwargs)

@staticmethod
def check_id(func_id: str) -> bool:
def check_id(func_id: str, entry_point: Path) -> bool:
if func_id in FunctionMap._ids:
return True
FunctionMap._ids = call_slurminade_to_get_function_ids(get_entry_point())
FunctionMap._ids = call_slurminade_to_get_function_ids(entry_point)
logging.getLogger("slurminade").info(
"Entry point '%s' has functions %s",
get_entry_point(),
entry_point,
list(FunctionMap._ids),
)
return func_id in FunctionMap._ids
Expand Down Expand Up @@ -138,6 +138,8 @@ def get_entry_point() -> Path:
raise FileNotFoundError("No entry point known.")

entry_point = __main__.__file__
if not Path(entry_point).is_file() or Path(entry_point).suffix != ".py":
raise FileNotFoundError("No entry point known.")

set_entry_point(entry_point)
assert FunctionMap.entry_point is not None
Expand Down

0 comments on commit b97b518

Please sign in to comment.