Skip to content

Commit

Permalink
add time duration component
Browse files Browse the repository at this point in the history
  • Loading branch information
superstar54 committed Dec 13, 2023
1 parent 6b02e80 commit 1eeaaa7
Show file tree
Hide file tree
Showing 7 changed files with 1,371 additions and 7 deletions.
6 changes: 3 additions & 3 deletions aiida_worktree/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ def get_parent_worktrees(pk):
return parent_worktrees


def get_node_latest(pk, node_name):
"""Get the latest info of a node from the process."""
def get_processes_latest(pk):
"""Get the latest info of all nodes from the process."""
import aiida

process = aiida.orm.load_node(pk)
Expand Down Expand Up @@ -213,7 +213,7 @@ def get_node_latest(pk, node_name):
"ctime": nodes.ctime,
"mtime": nodes.mtime,
}
return nodes.get(node_name)
return nodes


if __name__ == "__main__":
Expand Down
4 changes: 2 additions & 2 deletions aiida_worktree/web/backend/app/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def is_function_and_get_source(obj):

def node_to_short_json(worktree_pk, ndata):
"""Export a node to a rete js node."""
from aiida_worktree.utils import get_executor, get_node_latest
from aiida_worktree.utils import get_executor, get_processes_latest

executor, _ = get_executor(ndata["executor"])
is_function, source_code = is_function_and_get_source(executor)
Expand All @@ -58,7 +58,7 @@ def node_to_short_json(worktree_pk, ndata):
],
"executor": executor,
}
process_info = get_node_latest(worktree_pk, ndata["name"])
process_info = get_processes_latest(worktree_pk)[ndata["name"]]
ndata_short["process"] = process_info
if process_info is not None:
ndata_short["metadata"].append(["pk", process_info["pk"]])
Expand Down
4 changes: 3 additions & 1 deletion aiida_worktree/web/backend/app/worktree.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ async def read_worktree_item(id: int):
from .utils import worktree_to_short_json, get_node_summary
from aiida.cmdline.utils.common import get_workchain_report
from aiida.orm.utils.serialize import deserialize_unsafe
from aiida_worktree.utils import get_parent_worktrees
from aiida_worktree.utils import get_parent_worktrees, get_processes_latest

try:
node = orm.load_node(id)
Expand All @@ -73,9 +73,11 @@ async def read_worktree_item(id: int):
report = get_workchain_report(node, "REPORT")
parent_worktrees = get_parent_worktrees(id)
parent_worktrees.reverse()
processes_info = get_processes_latest(id)
content["summary"] = summary
content["logs"] = report.splitlines()
content["parent_worktrees"] = parent_worktrees
content["processes_info"] = processes_info
return content
except KeyError:
raise HTTPException(status_code=404, detail=f"Worktree {id} not found")
Expand Down
Loading

0 comments on commit 1eeaaa7

Please sign in to comment.