zipseq ignore _archive

This commit is contained in:
Nathan
2025-11-06 12:35:07 -07:00
parent da70801c87
commit ded87cdc68
2 changed files with 344 additions and 8 deletions

View File

@@ -1594,6 +1594,326 @@ _**User (2025-11-06 17:01Z)**_
_**Agent (model gpt-5-codex, mode Agent)**_
<think><details><summary>Thought Process</summary>
**Updating batch scripts for project root context**
Im adjusting the ZipSeqArchv.bat and Unzip scripts so they run inside the Renders folder but set the working directory to the project root (parent folder). This involves setting RENDERS_DIR and PROJECT_ROOT variables properly, using pushd to switch directory, and adding logs for missing scripts or Python. I plan to update both bat files, ensure paths are sanitized, preserve the absolute Python script path, add setlocal, and test running from actual Renders project folders like `251106_NewProject`.</details></think>
---
<tool-use data-tool-type="write" data-tool-name="edit_file">
<details><summary>Tool use: **code_edit** • Edit file: ZipSeqArchv.bat</summary>
**Chunk 1**
Lines added: 4, lines removed: 4
```diff
@@ -2,14 +2,14 @@
setlocal
- set &quot;REPO_ROOT=%~dp0&quot;
+ set &quot;REN_DIR=%~dp0&quot;
+ for %%I in (&quot;%REN_DIR%..&quot;) do set &quot;PROJ_ROOT=%%~fI&quot;
set &quot;PY_SCRIPT=A:\1 Amazon_Active_Projects\3 ProjectStructure\zip_sequences.py&quot;
-
- pushd &quot;%REPO_ROOT%&quot; &gt;nul 2&gt;&amp;1
if not exist &quot;%PY_SCRIPT%&quot; (
echo Missing %PY_SCRIPT%
- popd &gt;nul 2&gt;&amp;1
exit /b 1
)
+
+ pushd &quot;%PROJ_ROOT%&quot; &gt;nul 2&gt;&amp;1
python &quot;%PY_SCRIPT%&quot; --verbose %*
```
</details>
</tool-use>
---
<think><details><summary>Thought Process</summary>
**Applying equivalent update to Unzip**</details></think>
---
<tool-use data-tool-type="write" data-tool-name="edit_file">
<details><summary>Tool use: **code_edit** • Edit file: UnzipSeqArchv.bat</summary>
**Chunk 1**
Lines added: 4, lines removed: 4
```diff
@@ -2,14 +2,14 @@
setlocal
- set &quot;REPO_ROOT=%~dp0&quot;
+ set &quot;REN_DIR=%~dp0&quot;
+ for %%I in (&quot;%REN_DIR%..&quot;) do set &quot;PROJ_ROOT=%%~fI&quot;
set &quot;PY_SCRIPT=A:\1 Amazon_Active_Projects\3 ProjectStructure\zip_sequences.py&quot;
-
- pushd &quot;%REPO_ROOT%&quot; &gt;nul 2&gt;&amp;1
if not exist &quot;%PY_SCRIPT%&quot; (
echo Missing %PY_SCRIPT%
- popd &gt;nul 2&gt;&amp;1
exit /b 1
)
+
+ pushd &quot;%PROJ_ROOT%&quot; &gt;nul 2&gt;&amp;1
python &quot;%PY_SCRIPT%&quot; --mode expand --verbose %*
```
</details>
</tool-use>
---
<think><details><summary>Thought Process</summary>
**Running tests in Renders folder**</details></think>
---
<tool-use data-tool-type="bash" data-tool-name="run_terminal_cmd">
<details><summary>Tool use: **command** • Run command: Set-Location "A:\1 Amazon_Active_Projects\3 ProjectStructure\251106_NewProject\Renders"</summary>
```bash
Set-Location "A:\1 Amazon_Active_Projects\3 ProjectStructure\251106_NewProject\Renders"
```
```
Set-Location : Cannot find path &#39;A:\1 Amazon_Active_Projects\3 ProjectStructure\251106_NewProject\Renders&#39; because it
does not exist.
At C:\Users\Nathan\AppData\Local\Temp\ps-script-f2559d15-436e-4f73-b30d-da4abcba7dc8.ps1:7 char:1
+ Set-Location &quot;A:\1 Amazon_Active_Projects\3 ProjectStructure\251106_N ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (A:\1 Amazon_Act...Project\Renders:String) [Set-Location], ItemNotFoundE
xception
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.SetLocationCommand
```
</details>
</tool-use>
---
<think><details><summary>Thought Process</summary>
**Verifying project path existence**</details></think>
---
<tool-use data-tool-type="bash" data-tool-name="run_terminal_cmd">
<details><summary>Tool use: **command** • Run command: Set-Location "A:\1 Amazon_Active_Projects\3 ProjectStructure"</summary>
```bash
Set-Location "A:\1 Amazon_Active_Projects\3 ProjectStructure"
```
</details>
</tool-use>
---
<think><details><summary>Thought Process</summary>
**Listing directories**</details></think>
---
<tool-use data-tool-type="bash" data-tool-name="run_terminal_cmd">
<details><summary>Tool use: **command** • Run command: Get-ChildItem -Directory</summary>
```bash
Get-ChildItem -Directory
```
```
Directory: A:\1 Amazon_Active_Projects\3 ProjectStructure
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 10/30/2025 11:25 AM components
d----- 10/10/2025 3:30 PM scripts_old
```
</details>
</tool-use>
---
<think><details><summary>Thought Process</summary>
**Verifying project folder paths and test setup**
Im trying to figure out if the project folder really got created or if path mapping issues are hiding it, especially with network shares involved. To test reliably, Im thinking of creating a temporary folder that mimics the scenario and running the zipped script there with a controlled environment to check for proper messages and behavior.</details></think>
---
<tool-use data-tool-type="bash" data-tool-name="run_terminal_cmd">
<details><summary>Tool use: **command** • Run command: cmd /c "cd /d \"A:\1 Amazon_Active_Projects\3 ProjectStructure\Renders\" && ZipSeqArchv.bat"</summary>
```bash
cmd /c "cd /d \"A:\1 Amazon_Active_Projects\3 ProjectStructure\Renders\" && ZipSeqArchv.bat"
```
```
The specified path is invalid.
```
</details>
</tool-use>
---
<think><details><summary>Thought Process</summary>
**Verifying project folder existence and path mapping**</details></think>
---
<tool-use data-tool-type="generic" data-tool-name="list_dir">
<details>
<summary>Tool use: **list_directory** • Listed directory undefined • **0** results</summary>
No results found
</details>
</tool-use>
---
<think><details><summary>Thought Process</summary>
**Testing manual project creation**</details></think>
---
<tool-use data-tool-type="bash" data-tool-name="run_terminal_cmd">
<details><summary>Tool use: **command** • Run command: cmd /c "mkdir tmp_proj_test\Renders"</summary>
```bash
cmd /c "mkdir tmp_proj_test\Renders"
```
</details>
</tool-use>
---
<think><details><summary>Thought Process</summary>
**Considering file copy with PowerShell**</details></think>
---
<tool-use data-tool-type="bash" data-tool-name="run_terminal_cmd">
<details><summary>Tool use: **command** • Run command: Copy-Item ZipSeqArchv.bat,tmp_proj_test\Renders</summary>
```bash
Copy-Item ZipSeqArchv.bat,tmp_proj_test\Renders
```
```
Copy-Item : Cannot overwrite the item A:\1 Amazon_Active_Projects\3 ProjectStructure\ZipSeqArchv.bat with itself.
At C:\Users\Nathan\AppData\Local\Temp\ps-script-73400a4c-252e-4d0e-b43c-c55ba309a066.ps1:78 char:1
+ Copy-Item ZipSeqArchv.bat,tmp_proj_test\Renders
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (A:\1 Amazon_Act...ZipSeqArchv.bat:String) [Copy-Item], IOException
+ FullyQualifiedErrorId : CopyError,Microsoft.PowerShell.Commands.CopyItemCommand
```
</details>
</tool-use>
---
<think><details><summary>Thought Process</summary>
**Specifying copy command**</details></think>
---
<tool-use data-tool-type="bash" data-tool-name="run_terminal_cmd">
<details><summary>Tool use: **command** • Run command: Copy-Item ZipSeqArchv.bat tmp_proj_test\Renders\</summary>
```bash
Copy-Item ZipSeqArchv.bat tmp_proj_test\Renders\
```
</details>
</tool-use>
---
<think><details><summary>Thought Process</summary>
**Copying Unzip utility**</details></think>
---
<tool-use data-tool-type="bash" data-tool-name="run_terminal_cmd">
<details><summary>Tool use: **command** • Run command: Copy-Item UnzipSeqArchv.bat tmp_proj_test\Renders\</summary>
```bash
Copy-Item UnzipSeqArchv.bat tmp_proj_test\Renders\
```
</details>
</tool-use>
---
<think><details><summary>Thought Process</summary>
**Running command inside environment**</details></think>
---
Cancelled
---
_**User (2025-11-06 19:07Z)**_
let's make it so @zip_sequences.py ignores everything in _archive folders.
---
_**Agent (model gpt-5-codex, mode Agent)**_
<tool-use data-tool-type="grep" data-tool-name="grep">
<details>
<summary>Tool use: **grep** • Grep for "archive" in "zip_sequences.py" • 18 matches</summary>
Output mode: content
| File | Content | Line |
|------|------|------|
| `zip_sequences.py` | `Default mode scans `Renders/`, produces ZIP archives under `Renders/_zipped/`,` | L4 |
| `zip_sequences.py` | `and stages any updated archives so commits only track compact files. Switch to` | L5 |
| `zip_sequences.py` | ``--mode expand` to inflate the tracked archives back into the ignored working` | L6 |
| `zip_sequences.py` | `parser = argparse.ArgumentParser(description="Sync render sequences with zipped archives.")` | L36 |
| `zip_sequences.py` | `help="zip sequences for commit (default) or expand tracked archives",` | L41 |
| `zip_sequences.py` | `def archive_path_for(seq_dir: Path) -> Path:` | L108 |
| `zip_sequences.py` | `with ZipFile(zip_path, "w", compression=ZIP_STORED) as archive:` | L126 |
| `zip_sequences.py` | `archive.write(file_path, arcname=file_path.name)` | L130 |
| `zip_sequences.py` | `with ZipFile(zip_path, "r") as archive:` | L141 |
| `zip_sequences.py` | `archive.extractall(target_dir)` | L142 |
| `zip_sequences.py` | `zip_path = archive_path_for(seq_dir)` | L171 |
| `zip_sequences.py` | `log("zip", f"Updated \{updated_count\} sequence archive(s).", verbose=verbose)` | L206 |
| `zip_sequences.py` | `removed = cleanup_orphan_archives(verbose=verbose)` | L215 |
| `zip_sequences.py` | `log("zip", f"Removed \{removed\} orphan archive(s).", verbose=verbose)` | L217 |
| `zip_sequences.py` | `log("expand", "No archives to expand (missing 'Renders/_zipped').")` | L224 |
| `zip_sequences.py` | `log("expand", "Working folders already match archives; nothing to expand.")` | L243 |
| `zip_sequences.py` | `def cleanup_orphan_archives(*, verbose: bool) -> int:` | L266 |
| `zip_sequences.py` | `log("zip", f"Removing orphan archive \{rel\}", verbose_only=True, verbose=verbose)` | L278 |
</details>
</tool-use>
---
---

View File

@@ -59,24 +59,42 @@ def log(mode: str, message: str, *, verbose_only: bool = False, verbose: bool =
print(f"[{mode}] {message}")
def is_archive_path(path: Path) -> bool:
return any(part == "_archive" for part in path.parts)
def find_sequence_dirs(root: Path) -> Iterator[Path]:
for dirpath, dirnames, filenames in os.walk(root):
path = Path(dirpath)
if ARCHIVE_ROOT in path.parents or path == ARCHIVE_ROOT:
dirnames.clear()
dirnames[:] = [d for d in dirnames if d != "_archive"]
if is_archive_path(path):
continue
has_frames = any(Path(dirpath, f).suffix.lower() in SEQUENCE_EXTENSIONS for f in filenames)
if has_frames:
yield path
def iter_sequence_files(seq_dir: Path) -> Iterator[Path]:
for dirpath, dirnames, filenames in os.walk(seq_dir):
path = Path(dirpath)
dirnames[:] = [d for d in dirnames if d != "_archive"]
if is_archive_path(path):
continue
for filename in filenames:
yield path / filename
def compute_state(seq_dir: Path) -> dict:
entries = []
for file_path in sorted(p for p in seq_dir.iterdir() if p.is_file()):
files = sorted(
iter_sequence_files(seq_dir),
key=lambda p: p.relative_to(seq_dir).as_posix(),
)
for file_path in files:
stat = file_path.stat()
entries.append(
{
"path": file_path.name,
"path": file_path.relative_to(seq_dir).as_posix(),
"size": stat.st_size,
"mtime_ns": stat.st_mtime_ns,
}
@@ -124,10 +142,8 @@ def zip_sequence(seq_dir: Path, zip_path: Path) -> None:
zip_path.parent.mkdir(parents=True, exist_ok=True)
with ZipFile(zip_path, "w", compression=ZIP_STORED) as archive:
for file_path in sorted(seq_dir.iterdir()):
if not file_path.is_file():
continue
archive.write(file_path, arcname=file_path.name)
for file_path in iter_sequence_files(seq_dir):
archive.write(file_path, arcname=file_path.relative_to(seq_dir).as_posix())
def expand_sequence(zip_path: Path, seq_state: dict) -> None: