Fix deduplication and make it possible to watch fridge files
This commit is contained in:
parent
9173c75a7f
commit
8b31948478
@ -100,7 +100,7 @@ class DependencyBook:
|
|||||||
}
|
}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _structure(dictionary: dict) -> "DependencyBook":
|
def _structure(dictionary: dict, _class: Any) -> "DependencyBook":
|
||||||
provided = {cattr.structure(k, Resource): v for k, v in dictionary["provided"]}
|
provided = {cattr.structure(k, Resource): v for k, v in dictionary["provided"]}
|
||||||
watching = {cattr.structure(k, Resource): v for k, v in dictionary["watching"]}
|
watching = {cattr.structure(k, Resource): v for k, v in dictionary["watching"]}
|
||||||
|
|
||||||
|
@ -17,10 +17,12 @@
|
|||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
import time
|
import time
|
||||||
from asyncio import Future, Queue
|
from asyncio import Future, Queue
|
||||||
from collections import deque
|
from collections import deque
|
||||||
from contextvars import ContextVar
|
from contextvars import ContextVar
|
||||||
|
from pathlib import Path
|
||||||
from typing import Any, Deque, Dict, Optional, Tuple, Type, TypeVar
|
from typing import Any, Deque, Dict, Optional, Tuple, Type, TypeVar
|
||||||
|
|
||||||
import cattr
|
import cattr
|
||||||
@ -168,7 +170,7 @@ class Kitchen:
|
|||||||
return await self._chanproheads[hostuser]
|
return await self._chanproheads[hostuser]
|
||||||
|
|
||||||
async def cook_all(self):
|
async def cook_all(self):
|
||||||
# TODO fridge emitter
|
await self._emit_fridge_resources()
|
||||||
|
|
||||||
num_workers = 8
|
num_workers = 8
|
||||||
|
|
||||||
@ -393,6 +395,25 @@ class Kitchen:
|
|||||||
context = recipe.recipe_context
|
context = recipe.recipe_context
|
||||||
return Resource(kind, id, context.sous, extra_params)
|
return Resource(kind, id, context.sous, extra_params)
|
||||||
|
|
||||||
|
async def _emit_fridge_resources(self):
|
||||||
|
from scone.default.steps.fridge_steps import get_fridge_dirs
|
||||||
|
|
||||||
|
for fridge_dir in get_fridge_dirs(self.head):
|
||||||
|
num_prefix_parts = len(fridge_dir.parts)
|
||||||
|
for root, _dirs, files in os.walk(fridge_dir):
|
||||||
|
for file in files:
|
||||||
|
full_path = Path(root, file)
|
||||||
|
parts = full_path.parts
|
||||||
|
if parts[0:num_prefix_parts] != fridge_dir.parts:
|
||||||
|
raise RuntimeError(
|
||||||
|
f"{parts[0:num_prefix_parts]!r} != {fridge_dir.parts!r}"
|
||||||
|
)
|
||||||
|
fridge_relative_path = "/".join(parts[num_prefix_parts:])
|
||||||
|
fridge_res = Resource("fridge", fridge_relative_path, None)
|
||||||
|
stat = os.stat(full_path)
|
||||||
|
mtime = int(stat.st_mtime_ns // 1e6)
|
||||||
|
self.head.dag.resource_time[fridge_res] = mtime
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# @attr.s(auto_attribs=True)
|
# @attr.s(auto_attribs=True)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user