Skip to content
Merged
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
1 change: 0 additions & 1 deletion src/daggerml_cli/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,6 @@ def walk_nodes(x):
return
out = [*heads, *[x for x in reversed(nodes.values()) if x not in heads]]
return out
# return print(json.dumps([asdict(x) for x in out], indent=2, sort_keys=True))


def revert_commit(config, commit):
Expand Down
27 changes: 15 additions & 12 deletions src/daggerml_cli/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ class Commit:
author: str
committer: str
message: str
dag_name: Optional[str] = None # -> dag name in tree
created: str = field(default_factory=now)
modified: str = field(default_factory=now)

Expand All @@ -258,7 +259,7 @@ class Tree:
dags: dict[str, Ref] # -> dag


@repo_type(hash=[])
@repo_type
@dataclass
class Dag:
nodes: list[Ref] # -> node
Expand All @@ -270,7 +271,7 @@ def nameof(self, ref):
return {v: k for k, v in self.names.items()}.get(ref)


@repo_type(hash=[])
@repo_type
@dataclass
class FnDag(Dag):
argv: Optional[Ref] = None # -> node(expr) (in this dag)
Expand Down Expand Up @@ -627,10 +628,10 @@ def merge_trees(base, a, b):
Commit(
[c1, c2],
merge_trees(self.get(c0).tree, self.get(c1).tree, self.get(c2).tree),
author or self.user,
self.user,
message or f"merge {c2.id} with {c1.id}",
created or now(),
author=author or self.user,
committer=self.user,
message=message or f"merge {c2.id} with {c1.id}",
created=created or now(),
Copy link

Copilot AI Aug 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parameter name should be updated to match the keyword argument syntax. Change created or now() to use the created= keyword argument pattern consistently with the function signature.

Copilot uses AI. Check for mistakes.
)
)

Expand Down Expand Up @@ -757,12 +758,13 @@ def begin(self, *, message, name=None, dump=None):
ctx = Ctx.from_head(self.head)
if dump is None:
dag = self(Dag([], {}, None, None))
ctx.dags[name] = dag
else:
loaded = self.load_ref(dump)
assert loaded is not None, "failed to load dump"
with self.tx(True):
argv = self(Node(Argv(self.load_ref(dump))))
argv = self(Node(Argv(loaded)))
dag = self(FnDag([argv], {}, None, None, argv))
Comment thread
amniskin marked this conversation as resolved.
commit = Commit([ctx.head.commit], self(ctx.tree), self.user, self.user, message)
commit = Commit([ctx.head.commit], self(ctx.tree), self.user, self.user, message, dag_name=name)
index = self(Index(self(commit), dag))
return index

Expand All @@ -773,10 +775,9 @@ def put_node(self, data, index: Ref, name=None, doc=None):
ctx.dag.nodes.append(node)
if name:
ctx.dag.names[name] = node
self(ctx.head.dag, ctx.dag)
ctx.commit.tree = self(ctx.tree)
ctx.commit.created = ctx.commit.modified = now()
self(index, Index(self(ctx.commit), ctx.head.dag))
self(index, Index(self(ctx.commit), self(ctx.dag)))
return node

def get_node_value(self, ref: Ref):
Expand Down Expand Up @@ -828,9 +829,11 @@ def commit(self, res_or_err, index: Ref):
assert (ctx.dag.result or ctx.dag.error) is None, "dag has been committed already"
ctx.dag.result = result
ctx.dag.error = error
ref = self(ctx.dag)
if ctx.commit.dag_name is not None:
ctx.tree.dags[ctx.commit.dag_name] = ref
ctx.commit.tree = self(ctx.tree)
ctx.commit.created = ctx.commit.modified = now()
ref = self(dag, ctx.dag)
commit = self.merge(self.get(self.head).commit, self(ctx.commit))
self.set_head(self.head, commit)
self.delete(index)
Expand Down
1 change: 1 addition & 0 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def test_create_dag(self):
with d0.tx():
assert d0.get_node("n0") == n0
assert n0().doc == "This is my data."
assert d0.unroll(n0) == data
d0.commit(n0)
d0.test_close(self)
with SimpleApi.begin("d1", config_dir=config_dir, cache_path=config_dir) as d1:
Expand Down
1 change: 1 addition & 0 deletions tests/test_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def tmp_repo(cache_path=None):
tmpdirs = [tempfile.mkdtemp() for _ in range(2)]
repo = Repo(tmpdirs[0], user="test", create=True, cache_path=cache_path or tmpdirs[1])
if cache_path is None:
assert repo.cache_path is not None
with Repo(repo.cache_path, create=True):
pass
try:
Expand Down