Skip to content

Commit cfc8ce9

Browse files
authored
Merge pull request #25 from eriknw/magic_get
Allow the magic to use `afar.get` too using `-g` or `--get`
2 parents c388549 + 1ab2b13 commit cfc8ce9

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

afar/_magic.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from IPython.core.error import UsageError
55
from IPython.core.magic import Magics, line_cell_magic, magics_class, needs_local_scope
66

7-
from ._core import Run, run
7+
from ._core import Run, get, run
88
from ._where import Where, remotely
99

1010

@@ -16,14 +16,17 @@ def afar(self, line, cell=None, *, local_ns):
1616
"""Execute the cell on a dask.distributed cluster.
1717
1818
Usage, in line mode:
19-
%afar [-r run -d data -w where -c client] code_to_run
19+
%afar [-g -r run -d data -w where -c client] code_to_run
2020
Usage, in cell mode
21-
%%afar [-r run -d data -w where -c client <variable_names>]
21+
%%afar [-g -r run -d data -w where -c client <variable_names>]
2222
code...
2323
code...
2424
2525
Options:
2626
27+
-g/--get
28+
Get results as values, not as futures. This uses `afar.get` instead of `afar.run`.
29+
2730
-r/--run <run>
2831
A `Run` object from the local namespace such as `run = afar.run(data=mydata)`
2932
@@ -55,7 +58,8 @@ def afar(self, line, cell=None, *, local_ns):
5558
"""
5659
opts, line = self.parse_options(
5760
line,
58-
"r:d:w:c:",
61+
"gr:d:w:c:",
62+
"get",
5963
"run=",
6064
"data=",
6165
"where=",
@@ -81,6 +85,8 @@ def afar(self, line, cell=None, *, local_ns):
8185
raise UsageError(f"Variable name {runner!r} for -r or --run {not_found}")
8286
if not isinstance(runner, Run):
8387
raise UsageError(f"-r or --run argument must be of type Run; got: {type(runner)}")
88+
elif "g" in opts or "get" in opts:
89+
runner = get()
8490
else:
8591
runner = run()
8692
client = runner.client

0 commit comments

Comments
 (0)