composable-data-stack 0.5.1__py3-none-any.whl → 0.5.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
cli/getter.py CHANGED
@@ -5,6 +5,7 @@ import os
5
5
  import re
6
6
  import shlex
7
7
  import shutil
8
+ import sys
8
9
  import tarfile
9
10
  import tempfile
10
11
  from collections.abc import Iterator
@@ -667,15 +668,49 @@ def _write_tracking_manifest(
667
668
  def _read_tracking_manifest(path: Path) -> dict[str, Any]:
668
669
  if not path.exists():
669
670
  return {"version": 1, "profiles": {}}
671
+
670
672
  try:
671
- data = json.loads(path.read_text(encoding="utf-8"))
672
- except (OSError, json.JSONDecodeError):
673
- return {"version": 1, "profiles": {}}
674
- if not isinstance(data, dict):
673
+ raw_text = path.read_text(encoding="utf-8")
674
+ except OSError as exc:
675
+ # The file could not be read at all, so it cannot be backed up either;
676
+ # skip the doomed copy attempt and report the read failure directly.
677
+ print(
678
+ f"WARNING {path} could not be read ({exc}); resetting tracking manifest.",
679
+ file=sys.stderr,
680
+ )
675
681
  return {"version": 1, "profiles": {}}
676
- data.setdefault("version", 1)
677
- data.setdefault("profiles", {})
678
- return data
682
+
683
+ malformed_reason: str = ""
684
+ try:
685
+ data = json.loads(raw_text)
686
+ except json.JSONDecodeError as exc:
687
+ malformed_reason = f"invalid JSON: {exc}"
688
+ else:
689
+ if not isinstance(data, dict):
690
+ malformed_reason = "manifest root must be a JSON object"
691
+ else:
692
+ data.setdefault("version", 1)
693
+ data.setdefault("profiles", {})
694
+ return data
695
+
696
+ _backup_malformed_manifest(path, malformed_reason)
697
+ return {"version": 1, "profiles": {}}
698
+
699
+
700
+ def _backup_malformed_manifest(path: Path, reason: str) -> None:
701
+ timestamp = datetime.now(UTC).strftime("%Y%m%dT%H%M%S%fZ")
702
+ backup_path = path.with_name(f"{path.name}.corrupt-{timestamp}")
703
+ try:
704
+ shutil.copy2(path, backup_path)
705
+ backup_message = f"backed up to {backup_path}"
706
+ except OSError as exc:
707
+ backup_message = f"backup failed: {exc}"
708
+
709
+ print(
710
+ f"WARNING {path} is malformed ({reason}); resetting tracking manifest "
711
+ f"({backup_message}).",
712
+ file=sys.stderr,
713
+ )
679
714
 
680
715
 
681
716
  def _asset_root_relative_path(asset_root: Path, source_repo: Path) -> str:
cli/main.py CHANGED
@@ -114,12 +114,19 @@ def get_modules_root() -> Path:
114
114
  def find_project_root(start: Path | None = None) -> Path:
115
115
  """
116
116
  Walk up from `start` (default: current working directory) looking for a
117
- project root marker (pyproject.toml or .git). Falls back to `start` itself
118
- if no marker is found.
117
+ project root marker: `.cds` (CDS's own state directory, created by
118
+ `cds get`/`cds use`), `pyproject.toml`, or `.git`. `.cds` is checked first
119
+ at each level so a CDS working directory takes priority over an unrelated
120
+ ancestor repository (e.g. a dotfiles repo at $HOME) that happens to sit
121
+ further up the tree. Falls back to `start` itself if no marker is found.
119
122
  """
120
123
  current = (start or Path.cwd()).resolve()
121
124
  for directory in [current, *current.parents]:
122
- if (directory / "pyproject.toml").exists() or (directory / ".git").exists():
125
+ if (
126
+ (directory / ".cds").exists()
127
+ or (directory / "pyproject.toml").exists()
128
+ or (directory / ".git").exists()
129
+ ):
123
130
  return directory
124
131
  return current
125
132
 
@@ -335,13 +342,19 @@ def resolve_project_root(profile_path: str) -> Path:
335
342
  """
336
343
  Resolve a project root for output artifacts.
337
344
 
338
- The resolver walks up from the selected profile location and picks the first
339
- directory containing either pyproject.toml or .git. If no marker is found,
340
- it falls back to the current working directory.
345
+ The resolver walks up from the selected profile location and picks the
346
+ first directory containing `.cds` (CDS's own state directory, checked
347
+ first so it takes priority over an unrelated ancestor repository),
348
+ `pyproject.toml`, or `.git`. If no marker is found, it falls back to the
349
+ current working directory.
341
350
  """
342
351
  start = Path(profile_path).resolve().parent
343
352
  for directory in [start, *start.parents]:
344
- if (directory / "pyproject.toml").exists() or (directory / ".git").exists():
353
+ if (
354
+ (directory / ".cds").exists()
355
+ or (directory / "pyproject.toml").exists()
356
+ or (directory / ".git").exists()
357
+ ):
345
358
  return directory
346
359
  return Path.cwd().resolve()
347
360
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: composable-data-stack
3
- Version: 0.5.1
3
+ Version: 0.5.2
4
4
  Summary: CLI for validating and composing composable data stack profiles
5
5
  Author: Ronald Hensbergen
6
6
  License-Expression: Apache-2.0
@@ -1,12 +1,12 @@
1
1
  cli/__init__.py,sha256=l6DRCNT3MC_CLGYdX-E4o_DU0axjiZP1zPuEEgWja8E,18
2
2
  cli/constants.py,sha256=cp4135iisFhiOfhxm_jWI99sdQAi4SbSAX7qRJGNylQ,390
3
3
  cli/diagnostics.py,sha256=Vu_uY7OPJqrAvrG-DAcIjQVMiQ4WcGWSl32UYCtOCmA,260
4
- cli/getter.py,sha256=oCbZ7i2PNaegk8NyceF405Rv6BijmAMJs5cNAS6sP-0,22844
4
+ cli/getter.py,sha256=_wAB9huiuXYuMu2xYFFsDWuG9UN3DGyrlHpvHALUN7w,24002
5
5
  cli/graph.py,sha256=TNx0EuTVxN4G0EIs_9eX0_x7-So3XVMh6AYjgukMMZs,1828
6
6
  cli/image_updates.py,sha256=Hr4OFbIr1Kvh8naDJQt5UDno5B-nZ7BEfzdhxfxzqV0,11805
7
7
  cli/image_verification.py,sha256=ZmyQcanaXe4Z1H32xY7YLjX1T9mDcdCFIu6aKeEruaA,17961
8
8
  cli/loader.py,sha256=Hn50my3p6sYYlvp2SashktgrJ4pIYC0dC2K1mD5jpQs,5408
9
- cli/main.py,sha256=XU3EaaJgLOWTc-3dHBq8XTWzg5MfDetAa2ooG7Wtimo,70119
9
+ cli/main.py,sha256=UcLEH7JezZBF8pARxI44Af3XUbVPzQAEkfpF4DVCYaE,70672
10
10
  cli/overlay.py,sha256=UjJD5EFOhDwJihX9u64ZBWaYwP_b0JsQD9AOArYJB5Y,8426
11
11
  cli/planner.py,sha256=H4BL9JTD4H98ssC2zhkR_VFIDtNR2Cziu5T9Vm1IXJ4,22082
12
12
  cli/preflight.py,sha256=dChV9hwZwGAzrrIcB-KvUoUGXyGpKP5tTq9c_3S5PI0,13288
@@ -25,9 +25,9 @@ cli/resources/module.schema.json,sha256=Sn2pjrNrn4e4RzH6mus4sQ4Ji4B5vNw_duh1a5fl
25
25
  cli/resources/profile.schema.json,sha256=GbFr8QXQWLslOcF07Rzqps2t8Fp0_6onKurWqGf4zzM,6228
26
26
  cli/resources/rule-schema.json,sha256=uRhBGm7l18ey8lxEZsdJAOSrxUgcZuYUEvXi_f2bqyQ,6840
27
27
  cli/resources/rule-set.json,sha256=hHSJrJlCGh6gkh07KmG2qaN3k3pRSYowEbEeCAGOkXA,29411
28
- composable_data_stack-0.5.1.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
29
- composable_data_stack-0.5.1.dist-info/METADATA,sha256=WoZXT_jSHcdUzsv1V3aPNmb66h2hkYnjrLyLORVj9Ns,29557
30
- composable_data_stack-0.5.1.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
31
- composable_data_stack-0.5.1.dist-info/entry_points.txt,sha256=GBhnbsVzmlnBKLC5Do-tirjz3hTzOfgGXGuZNQxb5ak,38
32
- composable_data_stack-0.5.1.dist-info/top_level.txt,sha256=2ImG917oaVHlm0nP9oJE-Qrgs-fq_fGWgba2H1f8fpE,4
33
- composable_data_stack-0.5.1.dist-info/RECORD,,
28
+ composable_data_stack-0.5.2.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
29
+ composable_data_stack-0.5.2.dist-info/METADATA,sha256=fL6KkdCbTkW60mr8TueGLxiKaqS96JhGKieFd28U__M,29557
30
+ composable_data_stack-0.5.2.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
31
+ composable_data_stack-0.5.2.dist-info/entry_points.txt,sha256=GBhnbsVzmlnBKLC5Do-tirjz3hTzOfgGXGuZNQxb5ak,38
32
+ composable_data_stack-0.5.2.dist-info/top_level.txt,sha256=2ImG917oaVHlm0nP9oJE-Qrgs-fq_fGWgba2H1f8fpE,4
33
+ composable_data_stack-0.5.2.dist-info/RECORD,,