Add dissable VERSIONING+enable overwrite

This commit is contained in:
malkuthro
2025-10-26 18:32:37 +01:00
parent a0be253d74
commit b47b3253e4
2 changed files with 35 additions and 17 deletions
+15 -6
View File
@@ -55,6 +55,8 @@ class EasyAIPipeline:
"step": 1,
"display": "number"
}),
"disable_versioning": ("BOOLEAN", {"default": False}),
"enable_overwrite": ("BOOLEAN", {"default": False}),
}
}
@@ -64,18 +66,25 @@ class EasyAIPipeline:
CATEGORY = "Koolook/VFX"
OUTPUT_NODE = True # Marks it as an output node for workflow integration
def generate_pipeline(self, shot_duration, seed_value, instruction, base_directory_path, extension, shot_name, ai_method, version):
def generate_pipeline(self, shot_duration, seed_value, instruction, base_directory_path, extension, shot_name, ai_method, version, disable_versioning, enable_overwrite):
# Generate version string like 'v001'
version_str = f"v{version:03d}"
version_str = f"v{version:03d}" if not disable_versioning else ""
# Construct output path based on typical VFX structure: base_directory_path/shot_name/ai_method/version_str
# Construct output path based on typical VFX structure: base_directory_path/shot_name/ai_method[/version_str]
# Clean any double slashes for robustness
output_directory = os.path.join(base_directory_path.rstrip('/'), shot_name.lstrip('/'), ai_method.lstrip('/'), version_str.lstrip('/')).replace('\\', '/')
parts = [base_directory_path.rstrip('/'), shot_name.lstrip('/'), ai_method.lstrip('/')]
if not disable_versioning:
parts.append(version_str.lstrip('/'))
output_directory = os.path.join(*parts).replace('\\', '/')
while '//' in output_directory:
output_directory = output_directory.replace('//', '/')
# Construct full name: shot_name_ai_method_version_str.extension
name = f"{shot_name}_{ai_method}_{version_str}{extension}"
# Check for overwrite protection
if not enable_overwrite and os.path.exists(output_directory):
raise ValueError(f"Output directory already exists and overwrite is disabled. Enable 'enable_overwrite' or adjust parameters: {output_directory}")
# Construct full name: shot_name_ai_method[_version_str].extension
name = f"{shot_name}_{ai_method}_{version_str}{extension}" if not disable_versioning else f"{shot_name}_{ai_method}{extension}"
# Final file path: output_directory/name (with cleaning)
file_path = os.path.join(output_directory, name).replace('\\', '/')
+20 -11
View File
@@ -47,15 +47,19 @@ app.registerExtension({
base_directory_path: getEffectiveValue(this, "base_directory_path"),
shot_name: getEffectiveValue(this, "shot_name"),
ai_method: getEffectiveValue(this, "ai_method"),
version: getEffectiveValue(this, "version")
version: getEffectiveValue(this, "version"),
disable_versioning: getEffectiveValue(this, "disable_versioning"),
enable_overwrite: getEffectiveValue(this, "enable_overwrite")
};
if (Object.values(values).some(v => v === null)) {
displayWidget.value = "Cannot preview: complex inputs - execute node for accurate path.";
} else {
const version_str = `v${values.version.toString().padStart(3, '0')}`;
let output_directory = [values.base_directory_path, values.shot_name, values.ai_method, version_str]
.filter(part => part.toString().trim() !== "")
.join("/").replace(/\\/g, "/");
let parts = [values.base_directory_path, values.shot_name, values.ai_method];
if (!values.disable_versioning) {
const version_str = `v${values.version.toString().padStart(3, '0')}`;
parts.push(version_str);
}
let output_directory = parts.filter(part => part.toString().trim() !== "").join("/").replace(/\\/g, "/");
output_directory = output_directory.replace(/\/+/g, '/');
displayWidget.value = output_directory;
}
@@ -69,17 +73,22 @@ app.registerExtension({
shot_name: getEffectiveValue(this, "shot_name"),
ai_method: getEffectiveValue(this, "ai_method"),
extension: getEffectiveValue(this, "extension"),
version: getEffectiveValue(this, "version")
version: getEffectiveValue(this, "version"),
disable_versioning: getEffectiveValue(this, "disable_versioning"),
enable_overwrite: getEffectiveValue(this, "enable_overwrite")
};
if (Object.values(values).some(v => v === null)) {
displayWidget.value = "Cannot preview: complex inputs - execute node for accurate path.";
} else {
const version_str = `v${values.version.toString().padStart(3, '0')}`;
let output_directory = [values.base_directory_path, values.shot_name, values.ai_method, version_str]
.filter(part => part.toString().trim() !== "")
.join("/").replace(/\\/g, "/");
let parts = [values.base_directory_path, values.shot_name, values.ai_method];
let version_str = "";
if (!values.disable_versioning) {
version_str = `v${values.version.toString().padStart(3, '0')}`;
parts.push(version_str);
}
let output_directory = parts.filter(part => part.toString().trim() !== "").join("/").replace(/\\/g, "/");
output_directory = output_directory.replace(/\/+/g, '/');
const name = `${values.shot_name}_${values.ai_method}_${version_str}${values.extension}`;
const name = !values.disable_versioning ? `${values.shot_name}_${values.ai_method}_${version_str}${values.extension}` : `${values.shot_name}_${values.ai_method}${values.extension}`;
let file_path = `${output_directory}/${name}`.replace(/\\/g, "/");
file_path = file_path.replace(/\/+/g, '/');
displayWidget.value = file_path;