-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from d-krupke/development
v0.9.0
- Loading branch information
Showing
12 changed files
with
164 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import inspect | ||
import typing | ||
from .guard import on_slurm_node | ||
|
||
def node_setup(func: typing.Callable): | ||
""" | ||
Decorator: Call this function on the node before running any function calls. | ||
""" | ||
if on_slurm_node(): | ||
func() | ||
else: | ||
# check if the function has no arguments | ||
sig = inspect.signature(func) | ||
if sig.parameters: | ||
msg = "The node setup function must not have any arguments." | ||
raise ValueError(msg) | ||
return func |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
import slurminade | ||
from pytest import raises | ||
|
||
def test_dispatch_limit_batch(): | ||
@slurminade.slurmify() | ||
def f(): | ||
pass | ||
|
||
slurminade.set_entry_point(__file__) | ||
|
||
with raises(KeyError): | ||
f.distribute() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import slurminade | ||
from pathlib import Path | ||
|
||
test_file_path = Path("./f_test_file.txt") | ||
|
||
@slurminade.node_setup | ||
def f(): | ||
with open(test_file_path, "w") as file: | ||
file.write('node_setup') | ||
|
||
@slurminade.slurmify | ||
def nil(): | ||
pass | ||
|
||
def test_node_setup(): | ||
slurminade.set_entry_point(__file__) | ||
if test_file_path.exists(): | ||
test_file_path.unlink() | ||
dispatcher = slurminade.SubprocessDispatcher() | ||
slurminade.set_dispatcher(dispatcher) | ||
slurminade.set_dispatch_limit(100) | ||
nil.distribute() | ||
with open(test_file_path) as file: | ||
assert file.readline() == 'node_setup' | ||
if test_file_path.exists(): # delete the file | ||
test_file_path.unlink() |