Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

silent error with the work file resolving fixed when searching for fi… #35

Merged
merged 45 commits into from
Dec 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
e480d91
silent error with the work file resolving fixed when searching for fi…
masqu3rad3 Dec 19, 2023
ebd9258
github actions maya test
masqu3rad3 Dec 19, 2023
f44fb6d
ends
masqu3rad3 Dec 19, 2023
f21d9b2
ends
masqu3rad3 Dec 19, 2023
9d276dc
ends
masqu3rad3 Dec 19, 2023
0073c06
ends
masqu3rad3 Dec 19, 2023
cea00e9
ends
masqu3rad3 Dec 19, 2023
7584598
ends
masqu3rad3 Dec 19, 2023
1909d0f
ends
masqu3rad3 Dec 19, 2023
be07182
ends
masqu3rad3 Dec 19, 2023
d05d8c8
ends
masqu3rad3 Dec 19, 2023
9984bee
ends
masqu3rad3 Dec 19, 2023
d180057
ends
masqu3rad3 Dec 19, 2023
91b8bca
ends
masqu3rad3 Dec 19, 2023
2a05932
ends
masqu3rad3 Dec 19, 2023
b967aa1
ends
masqu3rad3 Dec 19, 2023
e7e02cc
ends
masqu3rad3 Dec 19, 2023
5089a7d
ends
masqu3rad3 Dec 19, 2023
9a48f83
ends
masqu3rad3 Dec 19, 2023
68c93db
ends
masqu3rad3 Dec 19, 2023
478e940
ends
masqu3rad3 Dec 19, 2023
085f654
ends
masqu3rad3 Dec 20, 2023
671ada2
ends
masqu3rad3 Dec 20, 2023
b2c7253
ends
masqu3rad3 Dec 20, 2023
d710222
ends
masqu3rad3 Dec 20, 2023
e9c5794
ends
masqu3rad3 Dec 20, 2023
40a8eb8
ends
masqu3rad3 Dec 20, 2023
12882ed
ends
masqu3rad3 Dec 20, 2023
28e10bb
ends
masqu3rad3 Dec 20, 2023
fa6aac9
ends
masqu3rad3 Dec 20, 2023
75e7d75
ends
masqu3rad3 Dec 20, 2023
2605399
ends
masqu3rad3 Dec 20, 2023
6345baa
Merge branch 'TIK-58-Publish-Dialog' into TIK-72-Settings-Dialog
masqu3rad3 Dec 20, 2023
08bc677
initial 3ds max integration
masqu3rad3 Dec 20, 2023
c72b833
ends
masqu3rad3 Dec 20, 2023
7ead6c2
settings dialog wip
masqu3rad3 Dec 22, 2023
d7fa8a0
settings dialog wip
masqu3rad3 Dec 23, 2023
fb39cbc
settings dialog wip
masqu3rad3 Dec 24, 2023
275d590
settings dialog wip / Bug fixed which prevents resetting the root pro…
masqu3rad3 Dec 24, 2023
8a90325
ends
masqu3rad3 Dec 24, 2023
79c096b
settings dialog (metadata definitions) wip
masqu3rad3 Dec 24, 2023
c685afc
fixing the preview errors due to the Path implementation
masqu3rad3 Dec 25, 2023
efeaf2f
settings dialog and overall make-ups continuing
masqu3rad3 Dec 25, 2023
0c0bd0a
adding the settings dialog to the main ui
masqu3rad3 Dec 25, 2023
7fd19db
initial settings ui
masqu3rad3 Dec 26, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions .github/workflows/ci-test-maya.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,11 @@ jobs:
mayapy get-pip.py --user
mayapy -m pip install --user \
coverage==5.5 \
flaky==3.7.0 \
docutils==0.17.1 \
sphinx==1.8.5 \
sphinxcontrib-napoleon==0.7 \
pytest==6.2.4
-r requirements-dev.txt \
- name: Environment
run: |
export XDG_RUNTIME_DIR=/var/tmp/runtime-root
export MAYA_DISABLE_ADP=1
- name: Test with pytest
run: |
mayapy -m pytest ./tests/maya
mayapy ./tests/maya/invoke.py
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "tik_manager4"
version = "4.0.0"
license = {file = "LICENSE"}
authors =[{name="Arda Kutlu", email="ardakutlu@gmail.com"},]
description="A program to manage pipelines"
description="Multi Platform and Multi DCC Python based Pipeline Toolkit."
readme = "README.md"
requires-python = "> 3.9"
classifiers = [
Expand Down
10 changes: 5 additions & 5 deletions tests/maya/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from pathlib import Path
import pytest

IN_GITHUB_ACTIONS = os.getenv("GITHUB_ACTIONS") == "true"
# IN_GITHUB_ACTIONS = os.getenv("GITHUB_ACTIONS") == "true"

@pytest.fixture(scope='session', autouse=True)
def initialize():
Expand Down Expand Up @@ -46,7 +46,7 @@ def tik(tmp_path):
shutil.copytree(str(tmp_path / "user_backup"), str(user_path))


@pytest.fixture(autouse=True)
def skip_github():
if IN_GITHUB_ACTIONS:
pytest.skip('Skipping Maya tests in GitHub Actions.')
# @pytest.fixture(autouse=True)
# def skip_github():
# if IN_GITHUB_ACTIONS:
# pytest.skip('Skipping Maya tests in GitHub Actions.')
6 changes: 6 additions & 0 deletions tests/maya/invoke.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import re
import sys
from pytest import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main(["./tests/maya"]))
65 changes: 39 additions & 26 deletions tests/maya/test_maya_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import pytest
from pathlib import Path
from tik_manager4.core import utils

# from maya import cmds
# try to import the cmds module from maya. If it fails, skip the tests.
try:
from maya import cmds
Expand All @@ -28,39 +28,53 @@ def project(self, tik):
tik.create_project(str(project_path), structure_template="empty")
return tik.project

def _create_subproject(self, project):
"""Create a subproject."""
sub_project = project.create_sub_project("test_subproject", parent_path="")
return sub_project

def _create_task(self, project):
"""Create a task."""
sub_project = self._create_subproject(project)
task = project.create_task("test_task", categories=["Model", "Rig", "LookDev"],
parent_uid=sub_project.id)
return task

def _create_work(self, project, category="Model"):
"""Create a work."""
test_task = self._create_task(project)
cmds.file(new=True, force=True)
# create a cube and save it as a work with binary format
test_cube = cmds.polyCube(name="test_cube")
work_obj = test_task.categories[category].create_work("test_cube", file_format=".ma", notes="This is the test cube.")
return work_obj, test_task

def test_create_a_sub_project(self, project):
"""Test to create a subproject."""
sub_project = project.create_sub_project("test_subproject", parent_path="")
sub_project = self._create_subproject(project)
assert sub_project != -1
assert sub_project.path == "test_subproject"

def test_delete_a_sub_project(self, project):
"""Test to delete a subproject."""
self.test_create_a_sub_project(project)
self._create_subproject(project)
# try to delete a non existing sub-project
assert project.delete_sub_project(path="non_existing_subproject") == -1
# delete an existing one
assert project.delete_sub_project(path="test_subproject") == 1

def test_create_a_task(self, project):
"""Test to create a task"""
self.test_create_a_sub_project(project)
task = project.create_task("test_task", categories=["Model", "Rig", "LookDev"],
parent_path="test_subproject")
assert task.name == "test_task"
assert task.creator == "Admin"
assert list(task.categories.keys()) == ["Model", "Rig", "LookDev"]
assert task.path == "test_subproject"
return task
test_task = self._create_task(project)
assert test_task.name == "test_task"
assert test_task.creator == "Admin"
assert list(test_task.categories.keys()) == ["Model", "Rig", "LookDev"]
assert test_task.path == "test_subproject"

# @pytest.mark.parametrize("category", ["Model", "Rig", "LookDev"])
def test_create_a_work(self, project, category="Model"):
"""Tests creating a work"""
test_task = self.test_create_a_task(project)
cmds.file(new=True, force=True)
# create a cube and save it as a work with binary format
test_cube = cmds.polyCube(name="test_cube")
work_obj = test_task.categories[category].create_work("test_cube", file_format=".mb", notes="This is the test cube.")
work_obj, test_task = self._create_work(project, category=category)

assert work_obj.name == f"test_task_{category}_test_cube"
assert work_obj.creator == "Admin"
Expand All @@ -80,20 +94,19 @@ def test_create_a_work(self, project, category="Model"):
cmds.setAttr("test_cube.scale", 4, 4, 4)
work_obj = test_task.categories[category].create_work("test_cube", notes="Scaled the cube.")
assert len(work_obj.versions) == 3
return work_obj

def test_getting_current_work(self, project):
"""Test for getting work object from the scene."""

_compare_work_obj = self.test_create_a_work(project)
_compare_work_obj = self._create_work(project, category="Model")[0]

# reset the scene
cmds.file(new=True, force=True)
# try getting the work object from a scene without a work.
assert project.get_current_work() == (None, None)

# open the scene and get the work object
_compare_work_obj.load_version(2)
_compare_work_obj.load_version(1)
test_work, version = project.get_current_work()
assert test_work.name == _compare_work_obj.name
assert test_work.id == _compare_work_obj.id
Expand All @@ -102,12 +115,12 @@ def test_getting_current_work(self, project):
def test_publishing_from_work(self, project, category):
"""Test to publish a work."""
# create works for each category
work_obj = self.test_create_a_work(project, category=category)
work_obj = self._create_work(project, category=category)[0]
# attempt to resolve a work with an empty scene
cmds.file(new=True, force=True)
assert project.publisher.resolve() == False

work_obj.load_version(2)
work_obj.load_version(1)

# publish the same work 3 times
for count in range(1, 4):
Expand Down Expand Up @@ -135,7 +148,7 @@ def test_publishing_from_work(self, project, category):
assert project.publisher._published_object.get_property("category") == category
assert project.publisher._published_object.get_property("dcc") == "Maya"
assert project.publisher._published_object.get_property("version_number") == count
assert project.publisher._published_object.get_property("work_version") == 2
assert project.publisher._published_object.get_property("work_version") == 1
assert project.publisher._published_object.get_property("task_name") == "test_task"
assert project.publisher._published_object.get_property("path") == f"test_subproject/test_task/{category}/Maya/publish"

Expand All @@ -155,7 +168,8 @@ def test_publishing_from_work(self, project, category):
# EXTRACT
project.publisher.extract()
for ext_name, ext_object in project.publisher._resolved_extractors.items():
assert ext_object.state == "extracted"
assert ext_object.state == "success"
# assert ext_object.state == "idle"

# PUBLISH
project.publisher.publish()
Expand All @@ -165,12 +179,11 @@ def test_publishing_from_work(self, project, category):
element_path = Path(project.publisher._published_object.get_abs_project_path(), element["path"])
assert Path(element_path).exists()

return work_obj

def test_scanning_publishes(self, project):
"""Test to scan the publishes."""
# create a work
work_obj = self.test_publishing_from_work(project, category="Model")
work_obj = self._create_work(project, category="Model")[0]

# for file_path, publish_obj in work_obj.publish.versions.items():
for publish_obj in work_obj.publish.versions:
Expand All @@ -195,7 +208,7 @@ def test_scanning_publishes(self, project):
def test_promoting_publish(self, project):
"""Test to promote a publish."""
# create a work
work_obj = self.test_publishing_from_work(project, category="Model")
work_obj = self._create_work(project, category="Model")[0]
# promote the first publish
# for file_path, publish_obj in work_obj.publish.versions.items():
for publish_obj in work_obj.publish.versions:
Expand Down
3 changes: 2 additions & 1 deletion tik_manager4/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,9 @@ def initialize(self, data):
data = data or {}
self._originalValue = {}
self._currentValue = {}
self._originalValue.update(data)
# self._originalValue.update(data)
self._currentValue.update(data)
self._originalValue = deepcopy(self._currentValue)

def update(self, data, dont_add_new_keys=True):
"""Updates the settings data"""
Expand Down
30 changes: 22 additions & 8 deletions tik_manager4/dcc/extract_core.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
"""Template module for publishing"""
# import os
from pathlib import Path
import importlib
from tik_manager4.core import filelog
from tik_manager4.core.settings import Settings


LOG = filelog.Filelog(logname=__name__, filename="tik_manager4")


class ExtractCore():
name: str = ""
class ExtractCore:
"""Core class for extracting elements from the scene."""

nice_name: str = ""
color: tuple = (255, 255, 255) # RGB
color: tuple = (255, 255, 255) # RGB
default_settings: dict = {}

def __init__(self):
# self._name: str = ""
# get the module name as name
# self._name = None
self._extension: str = ""
self._extract_folder: str = ""
self._category: str = ""
Expand All @@ -27,6 +30,15 @@ def __init__(self):
_settings.set_data(value)
self.settings[key] = _settings

def __init_subclass__(cls, **kwargs):
# Get the base name of the file without the extension using pathlib
module = importlib.import_module(cls.__module__)
module_file_path = Path(module.__file__).resolve()
module_name = module_file_path.stem
# Set the 'name' variable in the subclass
cls.name = module_name
super().__init_subclass__(**kwargs)

@property
def extract_name(self):
return self._extract_name
Expand Down Expand Up @@ -72,7 +84,7 @@ def extract(self):
try:
func()
self._status = "success"
except Exception as exc: # pylint: disable=broad-except
except Exception as exc: # pylint: disable=broad-except
LOG.error(exc)
LOG.error(f"Error while extracting {self.name} to {self.extract_folder}")
self._status = "failed"
Expand All @@ -83,5 +95,7 @@ def _extract_default(self):

def resolve_output(self):
"""Resolve the output path"""
output_path = Path(self.extract_folder) / f"{self._extract_name}{self.extension}"
return str(output_path)
output_path = (
Path(self.extract_folder) / f"{self._extract_name}{self.extension}"
)
return str(output_path)
4 changes: 2 additions & 2 deletions tik_manager4/dcc/houdini/main.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import hou

from tik_manager4.dcc.main_core import DccTemplate
from tik_manager4.dcc.main_core import MainCore

NAME = "Houdini"


class Dcc(DccTemplate):
class Dcc(MainCore):
hou.displayMessage("Houdini DCC loaded")
pass
# TODO mix-match from Tik Manager 3
28 changes: 21 additions & 7 deletions tik_manager4/dcc/ingest_core.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,36 @@
"""Core file for inserting elements into the scenes."""

import importlib
from pathlib import Path
from tik_manager4.core import filelog

LOG = filelog.Filelog(logname=__name__, filename="tik_manager4")


class IngestCore():
name: str = ""
class IngestCore:
"""Core class for ingesting elements into the scene."""

nice_name: str = ""
valid_extensions: list = []

def __init__(self):
self.name = str(Path(__file__).stem)
self._category: str = ""
self._status: str = "idle"
self._file_path: str = ""
self._namespace: str = ""
self.category_functions: dict = {}
self.category_reference_functions: dict = {}

def __init_subclass__(cls, **kwargs):
# Get the base name of the file without the extension using pathlib
module = importlib.import_module(cls.__module__)
module_file_path = Path(module.__file__).resolve()
module_name = module_file_path.stem
# Set the 'name' variable in the subclass
cls.name = module_name
super().__init_subclass__(**kwargs)

@property
def category(self):
"""Return the category for the rules."""
Expand Down Expand Up @@ -54,23 +66,25 @@ def file_path(self, file_path):
raise ValueError(f"File extension not valid: {_file_path.suffix}")
self._file_path = file_path

def bring_in(self): # a.k.a import
def bring_in(self): # a.k.a import
"""Bring in the element to the scene."""
func = self.category_functions.get(self.category, self._bring_in_default)
try:
func()
self._status = "success"
except Exception as exc: # pylint: disable=broad-except
except Exception as exc: # pylint: disable=broad-except
LOG.error(exc)
self._status = "failed"

def reference(self):
"""Reference the element to the scene where available."""
func = self.category_reference_functions.get(self.category, self._reference_default)
func = self.category_reference_functions.get(
self.category, self._reference_default
)
try:
func()
self._status = "success"
except Exception as exc: # pylint: disable=broad-except
except Exception as exc: # pylint: disable=broad-except
LOG.error(exc)
self._status = "failed"

Expand All @@ -80,4 +94,4 @@ def _bring_in_default(self):

def _reference_default(self):
"""Reference method for any non-specified category"""
LOG.warning(f"Reference not implemented for {self.name}")
LOG.warning(f"Reference not implemented for {self.name}")
Loading
Loading