PY-55
Write an Artifact Manifest
Task
Write write_artifact_manifest(base_path, manifest_name, source_id, config, schema_version, artifacts, status, digest_file, write_data).
config is a dictionary of settings. artifacts is a list of dictionaries
with path and count. Artifact paths use forward slashes and are relative to
base_path. A path is unsafe when it is empty, absolute, or contains a ..
part. Every path must be unique and name an existing regular file.
manifest_name follows the same safe-path rule and must not already exist.
Validate before writing. Return (None, reason) for the first applicable
failure in this order:
- unsafe manifest name:
"unsafe manifest path"; - manifest already exists:
"manifest exists"; - duplicate artifact path:
"duplicate artifact path"; - unsafe artifact path:
"unsafe artifact path"; - missing artifact:
"missing artifact".
Otherwise build this dictionary:
Use each file's byte size and digest_file(path). Keep artifact order. Call
write_data(manifest_path, manifest) exactly once, then return
(manifest, "ok"). The supplied writer owns the on-disk format.
Example
If rows.tsv contains five bytes and its supplied digest is "abc", an input
artifact {"path": "rows.tsv", "count": 2} becomes:
{"path": "rows.tsv", "count": 2, "bytes": 5, "digest": "abc"}
The manifest records both the declared row count and facts measured from the saved file.
Your implementation
Edit solution.py and keep this function signature:
You may import Path from pathlib. Do not choose a serialization format,
modify an input, overwrite a manifest, print, or ask for input.