daggerml 0.0.26__tar.gz → 0.0.28__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {daggerml-0.0.26 → daggerml-0.0.28}/PKG-INFO +1 -1
- {daggerml-0.0.26 → daggerml-0.0.28}/src/daggerml/core.py +5 -5
- daggerml-0.0.28/tests/assets/fns/async.py +19 -0
- daggerml-0.0.28/tests/assets/fns/error.py +19 -0
- daggerml-0.0.28/tests/assets/fns/minimal_viable_fn.py +9 -0
- {daggerml-0.0.26 → daggerml-0.0.28}/tests/test_core.py +2 -0
- daggerml-0.0.26/tests/assets/fns/async.py +0 -18
- daggerml-0.0.26/tests/assets/fns/error.py +0 -18
- daggerml-0.0.26/tests/assets/fns/minimal_viable_fn.py +0 -8
- {daggerml-0.0.26 → daggerml-0.0.28}/.github/workflows/ci.yml +0 -0
- {daggerml-0.0.26 → daggerml-0.0.28}/.gitignore +0 -0
- {daggerml-0.0.26 → daggerml-0.0.28}/.gitmodules +0 -0
- {daggerml-0.0.26 → daggerml-0.0.28}/README.md +0 -0
- {daggerml-0.0.26 → daggerml-0.0.28}/pyproject.toml +0 -0
- {daggerml-0.0.26 → daggerml-0.0.28}/src/daggerml/__init__.py +0 -0
- {daggerml-0.0.26 → daggerml-0.0.28}/src/daggerml/util.py +0 -0
- {daggerml-0.0.26 → daggerml-0.0.28}/tests/assets/fns/timeout.py +0 -0
|
@@ -213,7 +213,7 @@ class Dml: # noqa: F811
|
|
|
213
213
|
self.cache_key = None
|
|
214
214
|
self.dump = None
|
|
215
215
|
|
|
216
|
-
def __call__(self, *args: str, as_text: bool = False) -> Any:
|
|
216
|
+
def __call__(self, *args: str, input=None, as_text: bool = False) -> Any:
|
|
217
217
|
"""
|
|
218
218
|
Call the dml cli with the given arguments.
|
|
219
219
|
|
|
@@ -239,7 +239,7 @@ class Dml: # noqa: F811
|
|
|
239
239
|
resp = None
|
|
240
240
|
path = shutil.which("dml")
|
|
241
241
|
argv = [path, *self.opts, *args]
|
|
242
|
-
resp = subprocess.run(argv, check=True, capture_output=True, text=True)
|
|
242
|
+
resp = subprocess.run(argv, check=True, capture_output=True, text=True, input=input)
|
|
243
243
|
if resp.stderr:
|
|
244
244
|
log.error(resp.stderr.rstrip())
|
|
245
245
|
try:
|
|
@@ -252,7 +252,7 @@ class Dml: # noqa: F811
|
|
|
252
252
|
def invoke(*args, **kwargs):
|
|
253
253
|
opargs = to_json([name, args, kwargs])
|
|
254
254
|
token = self.token or to_json([])
|
|
255
|
-
return raise_ex(from_data(self("api", "invoke", token, opargs)))
|
|
255
|
+
return raise_ex(from_data(self("api", "invoke", token, input=opargs)))
|
|
256
256
|
|
|
257
257
|
return invoke
|
|
258
258
|
|
|
@@ -305,8 +305,8 @@ class Dml: # noqa: F811
|
|
|
305
305
|
>>> with dml.new("dag name", "message") as dag:
|
|
306
306
|
... pass
|
|
307
307
|
"""
|
|
308
|
-
opts =
|
|
309
|
-
token = self("api", "create", *opts, name, message, as_text=True)
|
|
308
|
+
opts = kwargs2opts(dump="-") if self.dump else []
|
|
309
|
+
token = self("api", "create", *opts, name, message, input=self.dump, as_text=True)
|
|
310
310
|
return Dag(replace(self, token=token), self.dump, self.message_handler)
|
|
311
311
|
|
|
312
312
|
def load(self, name: Union[str, Node]) -> Dag:
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import os
|
|
3
|
+
import sys
|
|
4
|
+
|
|
5
|
+
from daggerml import Dml
|
|
6
|
+
|
|
7
|
+
with Dml(data=json.loads(sys.stdin.read())["dump"], message_handler=print) as dml:
|
|
8
|
+
cache_dir = os.getenv("DML_FN_CACHE_DIR", "")
|
|
9
|
+
cache_file = os.path.join(cache_dir, dml.cache_key)
|
|
10
|
+
debug_file = os.path.join(cache_dir, "debug")
|
|
11
|
+
|
|
12
|
+
with open(debug_file, "a") as f:
|
|
13
|
+
f.write("ASYNC EXECUTING\n")
|
|
14
|
+
|
|
15
|
+
if os.path.isfile(cache_file):
|
|
16
|
+
with dml.new("test", "test") as d0:
|
|
17
|
+
d0.result = sum(d0.argv[1:].value())
|
|
18
|
+
else:
|
|
19
|
+
open(cache_file, "w").close()
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import os
|
|
3
|
+
import sys
|
|
4
|
+
|
|
5
|
+
from daggerml import Dml
|
|
6
|
+
|
|
7
|
+
with Dml(data=json.loads(sys.stdin.read())["dump"], message_handler=print) as dml:
|
|
8
|
+
cache_dir = os.getenv("DML_FN_CACHE_DIR", "")
|
|
9
|
+
cache_file = os.path.join(cache_dir, dml.cache_key)
|
|
10
|
+
debug_file = os.path.join(cache_dir, "debug")
|
|
11
|
+
|
|
12
|
+
with open(debug_file, "a") as f:
|
|
13
|
+
f.write("ASYNC EXECUTING\n")
|
|
14
|
+
|
|
15
|
+
if os.path.isfile(cache_file):
|
|
16
|
+
with dml.new("test", "test") as d0:
|
|
17
|
+
d0.result = 1 / 0
|
|
18
|
+
else:
|
|
19
|
+
open(cache_file, "w").close()
|
|
@@ -69,6 +69,8 @@ class TestBasic(TestCase):
|
|
|
69
69
|
self.assertIsInstance(d0._dump, str)
|
|
70
70
|
dag = dml("dag", "list")[0]
|
|
71
71
|
self.assertEqual(dag["result"], result.ref.to.split("/", 1)[1])
|
|
72
|
+
dml("dag", "delete", dag["name"], "Deleting dag")
|
|
73
|
+
dml("repo", "gc", as_text=True)
|
|
72
74
|
|
|
73
75
|
def test_async_fn_ok(self):
|
|
74
76
|
with TemporaryDirectory() as fn_cache_dir:
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
import sys
|
|
3
|
-
|
|
4
|
-
from daggerml import Dml
|
|
5
|
-
|
|
6
|
-
with Dml(data=sys.stdin.read(), message_handler=print) as dml:
|
|
7
|
-
cache_dir = os.getenv('DML_FN_CACHE_DIR', '')
|
|
8
|
-
cache_file = os.path.join(cache_dir, dml.cache_key)
|
|
9
|
-
debug_file = os.path.join(cache_dir, 'debug')
|
|
10
|
-
|
|
11
|
-
with open(debug_file, 'a') as f:
|
|
12
|
-
f.write('ASYNC EXECUTING\n')
|
|
13
|
-
|
|
14
|
-
if os.path.isfile(cache_file):
|
|
15
|
-
with dml.new('test', 'test') as d0:
|
|
16
|
-
d0.result = sum(d0.argv[1:].value())
|
|
17
|
-
else:
|
|
18
|
-
open(cache_file, 'w').close()
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
import sys
|
|
3
|
-
|
|
4
|
-
from daggerml import Dml
|
|
5
|
-
|
|
6
|
-
with Dml(data=sys.stdin.read(), message_handler=print) as dml:
|
|
7
|
-
cache_dir = os.getenv('DML_FN_CACHE_DIR', '')
|
|
8
|
-
cache_file = os.path.join(cache_dir, dml.cache_key)
|
|
9
|
-
debug_file = os.path.join(cache_dir, 'debug')
|
|
10
|
-
|
|
11
|
-
with open(debug_file, 'a') as f:
|
|
12
|
-
f.write('ASYNC EXECUTING\n')
|
|
13
|
-
|
|
14
|
-
if os.path.isfile(cache_file):
|
|
15
|
-
with dml.new('test', 'test') as d0:
|
|
16
|
-
d0.result = 1/0
|
|
17
|
-
else:
|
|
18
|
-
open(cache_file, 'w').close()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|