comfygit-core 0.2.0__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.
Files changed (93) hide show
  1. comfygit_core/analyzers/custom_node_scanner.py +109 -0
  2. comfygit_core/analyzers/git_change_parser.py +156 -0
  3. comfygit_core/analyzers/model_scanner.py +318 -0
  4. comfygit_core/analyzers/node_classifier.py +58 -0
  5. comfygit_core/analyzers/node_git_analyzer.py +77 -0
  6. comfygit_core/analyzers/status_scanner.py +362 -0
  7. comfygit_core/analyzers/workflow_dependency_parser.py +143 -0
  8. comfygit_core/caching/__init__.py +16 -0
  9. comfygit_core/caching/api_cache.py +210 -0
  10. comfygit_core/caching/base.py +212 -0
  11. comfygit_core/caching/comfyui_cache.py +100 -0
  12. comfygit_core/caching/custom_node_cache.py +320 -0
  13. comfygit_core/caching/workflow_cache.py +797 -0
  14. comfygit_core/clients/__init__.py +4 -0
  15. comfygit_core/clients/civitai_client.py +412 -0
  16. comfygit_core/clients/github_client.py +349 -0
  17. comfygit_core/clients/registry_client.py +230 -0
  18. comfygit_core/configs/comfyui_builtin_nodes.py +1614 -0
  19. comfygit_core/configs/comfyui_models.py +62 -0
  20. comfygit_core/configs/model_config.py +151 -0
  21. comfygit_core/constants.py +82 -0
  22. comfygit_core/core/environment.py +1635 -0
  23. comfygit_core/core/workspace.py +898 -0
  24. comfygit_core/factories/environment_factory.py +419 -0
  25. comfygit_core/factories/uv_factory.py +61 -0
  26. comfygit_core/factories/workspace_factory.py +109 -0
  27. comfygit_core/infrastructure/sqlite_manager.py +156 -0
  28. comfygit_core/integrations/__init__.py +7 -0
  29. comfygit_core/integrations/uv_command.py +318 -0
  30. comfygit_core/logging/logging_config.py +15 -0
  31. comfygit_core/managers/environment_git_orchestrator.py +316 -0
  32. comfygit_core/managers/environment_model_manager.py +296 -0
  33. comfygit_core/managers/export_import_manager.py +116 -0
  34. comfygit_core/managers/git_manager.py +667 -0
  35. comfygit_core/managers/model_download_manager.py +252 -0
  36. comfygit_core/managers/model_symlink_manager.py +166 -0
  37. comfygit_core/managers/node_manager.py +1378 -0
  38. comfygit_core/managers/pyproject_manager.py +1321 -0
  39. comfygit_core/managers/user_content_symlink_manager.py +436 -0
  40. comfygit_core/managers/uv_project_manager.py +569 -0
  41. comfygit_core/managers/workflow_manager.py +1944 -0
  42. comfygit_core/models/civitai.py +432 -0
  43. comfygit_core/models/commit.py +18 -0
  44. comfygit_core/models/environment.py +293 -0
  45. comfygit_core/models/exceptions.py +378 -0
  46. comfygit_core/models/manifest.py +132 -0
  47. comfygit_core/models/node_mapping.py +201 -0
  48. comfygit_core/models/protocols.py +248 -0
  49. comfygit_core/models/registry.py +63 -0
  50. comfygit_core/models/shared.py +356 -0
  51. comfygit_core/models/sync.py +42 -0
  52. comfygit_core/models/system.py +204 -0
  53. comfygit_core/models/workflow.py +914 -0
  54. comfygit_core/models/workspace_config.py +71 -0
  55. comfygit_core/py.typed +0 -0
  56. comfygit_core/repositories/migrate_paths.py +49 -0
  57. comfygit_core/repositories/model_repository.py +958 -0
  58. comfygit_core/repositories/node_mappings_repository.py +246 -0
  59. comfygit_core/repositories/workflow_repository.py +57 -0
  60. comfygit_core/repositories/workspace_config_repository.py +121 -0
  61. comfygit_core/resolvers/global_node_resolver.py +459 -0
  62. comfygit_core/resolvers/model_resolver.py +250 -0
  63. comfygit_core/services/import_analyzer.py +218 -0
  64. comfygit_core/services/model_downloader.py +422 -0
  65. comfygit_core/services/node_lookup_service.py +251 -0
  66. comfygit_core/services/registry_data_manager.py +161 -0
  67. comfygit_core/strategies/__init__.py +4 -0
  68. comfygit_core/strategies/auto.py +72 -0
  69. comfygit_core/strategies/confirmation.py +69 -0
  70. comfygit_core/utils/comfyui_ops.py +125 -0
  71. comfygit_core/utils/common.py +164 -0
  72. comfygit_core/utils/conflict_parser.py +232 -0
  73. comfygit_core/utils/dependency_parser.py +231 -0
  74. comfygit_core/utils/download.py +216 -0
  75. comfygit_core/utils/environment_cleanup.py +111 -0
  76. comfygit_core/utils/filesystem.py +178 -0
  77. comfygit_core/utils/git.py +1184 -0
  78. comfygit_core/utils/input_signature.py +145 -0
  79. comfygit_core/utils/model_categories.py +52 -0
  80. comfygit_core/utils/pytorch.py +71 -0
  81. comfygit_core/utils/requirements.py +211 -0
  82. comfygit_core/utils/retry.py +242 -0
  83. comfygit_core/utils/symlink_utils.py +119 -0
  84. comfygit_core/utils/system_detector.py +258 -0
  85. comfygit_core/utils/uuid.py +28 -0
  86. comfygit_core/utils/uv_error_handler.py +158 -0
  87. comfygit_core/utils/version.py +73 -0
  88. comfygit_core/utils/workflow_hash.py +90 -0
  89. comfygit_core/validation/resolution_tester.py +297 -0
  90. comfygit_core-0.2.0.dist-info/METADATA +939 -0
  91. comfygit_core-0.2.0.dist-info/RECORD +93 -0
  92. comfygit_core-0.2.0.dist-info/WHEEL +4 -0
  93. comfygit_core-0.2.0.dist-info/licenses/LICENSE.txt +661 -0
@@ -0,0 +1,116 @@
1
+ """Export/Import manager for bundling and extracting environments."""
2
+ from __future__ import annotations
3
+
4
+ import tarfile
5
+ from pathlib import Path
6
+ from typing import TYPE_CHECKING
7
+
8
+ from ..logging.logging_config import get_logger
9
+
10
+ if TYPE_CHECKING:
11
+ from .pyproject_manager import PyprojectManager
12
+
13
+ logger = get_logger(__name__)
14
+
15
+
16
+ class ExportImportManager:
17
+ """Manages environment export and import operations."""
18
+
19
+ def __init__(self, cec_path: Path, comfyui_path: Path):
20
+ self.cec_path = cec_path
21
+ self.comfyui_path = comfyui_path
22
+
23
+ def create_export(
24
+ self,
25
+ output_path: Path,
26
+ pyproject_manager: PyprojectManager
27
+ ) -> Path:
28
+ """Create export tarball.
29
+
30
+ Args:
31
+ output_path: Output .tar.gz file path
32
+ pyproject_manager: PyprojectManager for reading config
33
+
34
+ Returns:
35
+ Path to created tarball
36
+ """
37
+ logger.info(f"Creating export at {output_path}")
38
+
39
+ with tarfile.open(output_path, "w:gz") as tar:
40
+ # Add pyproject.toml
41
+ pyproject_path = self.cec_path / "pyproject.toml"
42
+ if pyproject_path.exists():
43
+ tar.add(pyproject_path, arcname="pyproject.toml")
44
+
45
+ # Add uv.lock
46
+ lock_path = self.cec_path / "uv.lock"
47
+ if lock_path.exists():
48
+ tar.add(lock_path, arcname="uv.lock")
49
+
50
+ # Add .python-version
51
+ python_version_path = self.cec_path / ".python-version"
52
+ if python_version_path.exists():
53
+ tar.add(python_version_path, arcname=".python-version")
54
+
55
+ # Add workflows
56
+ workflows_path = self.cec_path / "workflows"
57
+ if workflows_path.exists():
58
+ for workflow_file in workflows_path.glob("*.json"):
59
+ tar.add(workflow_file, arcname=f"workflows/{workflow_file.name}")
60
+
61
+ # Add dev nodes (read from pyproject.toml)
62
+ pyproject_data = pyproject_manager.load()
63
+ nodes_config = pyproject_data.get("tool", {}).get("comfygit", {}).get("nodes", {})
64
+ dev_nodes = [name for name, node in nodes_config.items() if node.get("source") == "development"]
65
+
66
+ custom_nodes_path = self.comfyui_path / "custom_nodes"
67
+ if custom_nodes_path.exists():
68
+ for node_name in dev_nodes:
69
+ node_path = custom_nodes_path / node_name
70
+ if node_path.exists():
71
+ self._add_filtered_directory(tar, node_path, f"dev_nodes/{node_name}")
72
+
73
+ logger.info(f"Export created successfully: {output_path}")
74
+ return output_path
75
+
76
+ def extract_import(self, tarball_path: Path, target_cec_path: Path) -> None:
77
+ """Extract import tarball to target .cec directory.
78
+
79
+ Args:
80
+ tarball_path: Path to .tar.gz file
81
+ target_cec_path: Target .cec directory (must not exist)
82
+
83
+ Raises:
84
+ ValueError: If target already exists
85
+ """
86
+ if target_cec_path.exists():
87
+ raise ValueError(f"Target path already exists: {target_cec_path}")
88
+
89
+ logger.info(f"Extracting import from {tarball_path}")
90
+
91
+ # Create target directory
92
+ target_cec_path.mkdir(parents=True)
93
+
94
+ # Extract tarball (use data filter for Python 3.14+ compatibility)
95
+ with tarfile.open(tarball_path, "r:gz") as tar:
96
+ tar.extractall(target_cec_path, filter='data')
97
+
98
+ logger.info(f"Import extracted successfully to {target_cec_path}")
99
+
100
+ def _add_filtered_directory(self, tar: tarfile.TarFile, source_path: Path, arcname: str):
101
+ """Add directory to tarball, filtering by .gitignore.
102
+
103
+ Args:
104
+ tar: Open tarfile
105
+ source_path: Source directory
106
+ arcname: Archive name prefix
107
+ """
108
+ # Simple implementation - add all files (MVP)
109
+ # TODO: Add .gitignore filtering if needed
110
+ for item in source_path.rglob("*"):
111
+ if item.is_file():
112
+ # Skip __pycache__ and .pyc files
113
+ if "__pycache__" in item.parts or item.suffix == ".pyc":
114
+ continue
115
+ relative = item.relative_to(source_path)
116
+ tar.add(item, arcname=f"{arcname}/{relative}")