mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-01 23:08:43 +01:00
serialization: reorder files section metadata (#8950
serialization: reorder files section
This commit is contained in:
+15
-1
@@ -1,6 +1,8 @@
|
||||
import logging
|
||||
import os
|
||||
import posixpath
|
||||
from collections import defaultdict
|
||||
from operator import itemgetter
|
||||
from typing import TYPE_CHECKING, Dict, List, Optional, Set, Tuple, Type, cast
|
||||
from urllib.parse import urlparse
|
||||
|
||||
@@ -229,6 +231,17 @@ def merge_file_meta_from_cloud(entry: Dict) -> Dict:
|
||||
return entry
|
||||
|
||||
|
||||
def _serialize_tree_obj_to_files(obj: "Tree") -> List[Dict[str, Any]]:
|
||||
key = obj.PARAM_RELPATH
|
||||
return sorted(
|
||||
(
|
||||
{key: posixpath.sep.join(parts), **hi.to_dict(), **meta.to_dict()}
|
||||
for parts, meta, hi in obj
|
||||
),
|
||||
key=itemgetter(key),
|
||||
)
|
||||
|
||||
|
||||
class OutputDoesNotExistError(DvcException):
|
||||
def __init__(self, path):
|
||||
msg = f"output '{path}' does not exist"
|
||||
@@ -823,7 +836,8 @@ class Output:
|
||||
if obj:
|
||||
obj = cast("Tree", obj)
|
||||
ret[self.PARAM_FILES] = [
|
||||
split_file_meta_from_cloud(f) for f in obj.as_list(with_meta=True)
|
||||
split_file_meta_from_cloud(f)
|
||||
for f in _serialize_tree_obj_to_files(obj)
|
||||
]
|
||||
return ret
|
||||
|
||||
|
||||
@@ -154,7 +154,7 @@ def to_pipeline_file(stage: "PipelineStage"):
|
||||
|
||||
|
||||
def to_single_stage_lockfile(stage: "Stage", **kwargs) -> dict:
|
||||
from dvc.output import split_file_meta_from_cloud
|
||||
from dvc.output import _serialize_tree_obj_to_files, split_file_meta_from_cloud
|
||||
|
||||
assert stage.cmd
|
||||
|
||||
@@ -165,7 +165,8 @@ def to_single_stage_lockfile(stage: "Stage", **kwargs) -> dict:
|
||||
if obj:
|
||||
obj = cast("Tree", obj)
|
||||
ret[item.PARAM_FILES] = [
|
||||
split_file_meta_from_cloud(f) for f in obj.as_list(with_meta=True)
|
||||
split_file_meta_from_cloud(f)
|
||||
for f in _serialize_tree_obj_to_files(obj)
|
||||
]
|
||||
else:
|
||||
meta_d = item.meta.to_dict()
|
||||
|
||||
Reference in New Issue
Block a user