Skip to content

Commit

Permalink
finish to correct pull workable for silex_maya
Browse files Browse the repository at this point in the history
  • Loading branch information
Shlule committed Nov 6, 2023
1 parent fd36e5d commit 0ae06eb
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 68 deletions.
1 change: 0 additions & 1 deletion silex_client/commands/build_render_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ async def _get_gazu_output_path(
name=task_name,
mode = "render"
)
print(output_path)
return pathlib.Path(output_path)

@CommandBase.conform_command()
Expand Down
2 changes: 2 additions & 0 deletions silex_client/commands/build_work_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@


class BuildWorkPath(CommandBase):

print("je suis dans le build work path")
"""
Build the path where the work files should be saved to
"""
Expand Down
4 changes: 2 additions & 2 deletions silex_client/commands/farm/houdini_render_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class HoudiniRenderTasksCommand(CommandBase):
parameters = {
"scene_file": {
"label": "Scene file",
"type": TaskFileParameterMeta(extensions=[".hip", ".hipnc"]),
"type": TaskFileParameterMeta(),
},
"frame_range": {
"label": "Frame range",
Expand Down Expand Up @@ -110,7 +110,6 @@ async def __call__(
logger: logging.Logger,
):
scene: pathlib.Path = parameters["scene_file"]
print(scene)
frame_range: FrameSet = parameters["frame_range"]
skip_existing = parameters["skip_existing"]
parameter_overrides: bool = parameters["parameter_overrides"]
Expand Down Expand Up @@ -171,6 +170,7 @@ async def setup(
logger: logging.Logger,
):
scene: pathlib.Path = parameters["scene_file"]
print(scene)
rop_from_hip: bool = parameters["rop_from_hip"]
previous_hip_value = action_query.store.get(
"submit_houdini_temp_hip_filepath", None
Expand Down
1 change: 1 addition & 0 deletions silex_client/commands/pull_workable.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ async def work_and_full_path(version: int) -> tuple[str, str]:
launch_cmd.param("action")
launch_cmd.value('rename')

print(launch_cmd)

os.system(str(launch_cmd))

Expand Down
177 changes: 113 additions & 64 deletions silex_client/commands/rename_startup.py
Original file line number Diff line number Diff line change
@@ -1,84 +1,133 @@
# from __future__ import annotations

# import logging
# import os
# import pathlib
# import re
# import typing
# from typing import Any, Dict
# import gazu.files
# import fileseq


# import asyncio
# from silex_client.action.command_base import CommandBase
# from silex_client.action.parameter_buffer import ParameterBuffer
# from silex_client.commands.build_work_path import BuildWorkPath
# from silex_client.utils import command_builder
# from silex_client.core.context import Context
# from silex_client.utils.files import expand_path
# from silex_client.utils.log import flog
# from silex_client.utils.parameter_types import TaskFileParameterMeta, TextParameterMeta

# # Forward references
# if typing.TYPE_CHECKING:
# from silex_client.action.action_query import ActionQuery



# class RenameStartup(BuildWorkPath):

# print("je suis dans l'action rename de silex_client")

# @CommandBase.conform_command()
# async def __call__(
# self,
# parameters: Dict[str, Any],
# action_query: ActionQuery,
# logger: logging.Logger,
# ):

# task = await gazu.task.get_task(action_query.context_metadata["task_id"])
# async def work_and_full_path(version: int) -> tuple[str, str]:
# work_path: str = await gazu.files.build_working_file_path(
# task, software=None, revision=version, sep=os.path.sep
# )
# full_path = f"{work_path}{extension}"
# return work_path, full_path
# print(work_path + " test ")
# # Build the work path
# initial_version = 1
# version = initial_version
# work_path, full_path = await work_and_full_path(initial_version)

# existing_sequences = fileseq.findSequencesOnDisk(os.path.dirname(full_path))

# # Change to the good version ===================================================================================
# matching_sequence = None
# for sequence in existing_sequences:
# # Check if the filename is present in any of the file sequences
# if pathlib.Path(full_path) in [
# pathlib.Path(path) for path in sequence
# ]:
# # Set the version to the latest of that sequence
# last_version = sequence.frameSet()[-1] + 1

# # If the version is greater, use that
# if last_version > version:
# version = last_version
# matching_sequence = sequence

# # We also increment when an existing sequence was found
# if parameters["increment"]:
# version += 1

# if version != initial_version:
# # Rebuild the file path again with the new version
# _, full_path = await work_and_full_path(version)
# flog.info(full_path)

# publishes = [publish]
# if not publish.is_dir():
# publish = publish.parent
# else:
# publishes = list(publish.iterdir())

# # get the associated dcc to extension ==========================================================================

from __future__ import annotations

import logging
import os
import pathlib
import re
import typing
from typing import Any, Dict
import gazu.files
import fileseq

from typing import Any, Dict, List

import asyncio
from silex_client.action.command_base import CommandBase
from silex_client.action.parameter_buffer import ParameterBuffer
from silex_client.commands.build_work_path import BuildWorkPath
from silex_client.utils import command_builder
from silex_client.core.context import Context
from silex_client.utils.files import expand_path
# from silex_houdini.utils.utils import Utils
from silex_client.utils.parameter_types import ListParameter
from silex_client.utils.log import flog
from silex_client.utils.parameter_types import TaskFileParameterMeta, TextParameterMeta


# Forward references
if typing.TYPE_CHECKING:
from silex_client.action.action_query import ActionQuery

import os

import maya.cmds as cmds

print("je suis dans le silex_clients rename")

class SelectPull(BuildWorkPath):
class RenameStartup(CommandBase):
"""
Save current scene with context as path
"""
print("je suis dans la class")
parameters = {
"name": {
"label": "Only set the path",
"type": str,
"value": None,
"hide": True,
},
}

@CommandBase.conform_command()
async def __call__(
self,
parameters: Dict[str, Any],
action_query: ActionQuery,
logger: logging.Logger,
self,
parameters: Dict[str, Any],
action_query: ActionQuery,
logger: logging.Logger,
):
cmds.file(rename= parameters["name"])

task = await gazu.task.get_task(action_query.context_metadata["task_id"])
async def work_and_full_path(version: int) -> tuple[str, str]:
work_path: str = await gazu.files.build_working_file_path(
task, software=None, revision=version, sep=os.path.sep
)
full_path = f"{work_path}{extension}"
return work_path, full_path

# Build the work path
initial_version = 1
version = initial_version
work_path, full_path = await work_and_full_path(initial_version)

existing_sequences = fileseq.findSequencesOnDisk(os.path.dirname(full_path))

# Change to the good version ===================================================================================
matching_sequence = None
for sequence in existing_sequences:
# Check if the filename is present in any of the file sequences
if pathlib.Path(full_path) in [
pathlib.Path(path) for path in sequence
]:
# Set the version to the latest of that sequence
last_version = sequence.frameSet()[-1] + 1

# If the version is greater, use that
if last_version > version:
version = last_version
matching_sequence = sequence

# We also increment when an existing sequence was found
if parameters["increment"]:
version += 1

if version != initial_version:
# Rebuild the file path again with the new version
_, full_path = await work_and_full_path(version)
flog.info(full_path)

publishes = [publish]
if not publish.is_dir():
publish = publish.parent
else:
publishes = list(publish.iterdir())

# get the associated dcc to extension ==========================================================================
4 changes: 3 additions & 1 deletion silex_client/utils/parameter_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ def TaskFileParameterMeta(
def __init__(self, value):
if not isinstance(value, list):
value = [value]

for index, item in enumerate(value):
value[index] = pathlib.Path(item)

Expand Down Expand Up @@ -421,3 +420,6 @@ def get_default():
}

return CommandParameterMeta("UnionParameter", (object,), attributes)

if __name__ == "__main__":
TaskFileParameterMeta(extensions=["hip","hipnc"])

0 comments on commit 0ae06eb

Please sign in to comment.