mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
* objects.status: use object IDs instead of naive objects * objects.transfer: use object IDs instead of naive objects * objects: add ReferenceHashFile * odb: add ReferenceObjectDB * repo: collect used object IDs instead of naive objs * support basic/naive fs serialization * objects.stage: stage file objects in addition to trees * objects: remove save(), update transfer() * output/dep: update for osave removal * path_info: support both url and path attributes * status/gc: use object IDs instead of naive objs * diff: update staging usage * commit: update staging usage * tests: clean staging when needed * tests: update for save/transfer/stage changes * dvcfs: don't allow config serialization (repofs should be used instead) * utils: return mtime as str, size as int * tests: update unit tests for save/stage/transfer changes * objects: use Repo.open when needed in ReferenceHashFile * fix ls test staging * objects.stage: don't skip hash check when loading from state - individual hashes will still be loaded from state if they are still valid * ReferenceHashFile: serialize repo fs paths relative to repo root * preserve state when staging * objects.tree: skip hash computation in digest() when we have already loaded hash from state * always check file existence in referencehashfile * update repofs test since stage no longer allows nonexistent files * odb: only protect on check() if hash was verified * staging: use unique memfs namespace for staging per dest ODB * tests: clean full staging namespace * refodb: preserve repofs cache dir * repodependency: stage imports to local ODB and strict check circular imports * fetch: fetch staging last * staging: make dest odb mandatory and preserve state * refodb: cache nonlocal fs's * fix rebase errors * repofs: support full instantiation from fs config * repofs: preserve subrepo factory for erepos * tests: clarify repofs dirty file behavior
57 lines
1.2 KiB
Python
57 lines
1.2 KiB
Python
import csv
|
|
import os
|
|
from contextlib import contextmanager
|
|
|
|
import pytest
|
|
from funcy import first
|
|
|
|
from dvc.scm import Git
|
|
|
|
# rewrite assertions in assert, pytest does not rewrite for other modules
|
|
# than tests itself.
|
|
pytest.register_assert_rewrite("tests.utils.asserts")
|
|
|
|
|
|
def get_gitignore_content():
|
|
with open(Git.GITIGNORE) as gitignore:
|
|
return gitignore.read().splitlines()
|
|
|
|
|
|
@contextmanager
|
|
def cd(newdir):
|
|
prevdir = os.getcwd()
|
|
os.chdir(os.path.expanduser(newdir))
|
|
try:
|
|
yield
|
|
finally:
|
|
os.chdir(prevdir)
|
|
|
|
|
|
def to_posixpath(path):
|
|
return path.replace("\\", "/")
|
|
|
|
|
|
def dump_sv(stream, metrics, delimiter=",", header=True):
|
|
if header:
|
|
writer = csv.DictWriter(
|
|
stream, fieldnames=list(first(metrics).keys()), delimiter=delimiter
|
|
)
|
|
writer.writeheader()
|
|
writer.writerows(metrics)
|
|
else:
|
|
writer = csv.writer(stream)
|
|
for d in metrics:
|
|
writer.writerow(list(d.values()))
|
|
|
|
|
|
def clean_staging():
|
|
from dvc.fs.memory import MemoryFileSystem
|
|
from dvc.objects.stage import _STAGING_MEMFS_PATH
|
|
|
|
try:
|
|
MemoryFileSystem().fs.rm(
|
|
f"memory://{_STAGING_MEMFS_PATH}", recursive=True
|
|
)
|
|
except FileNotFoundError:
|
|
pass
|