Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Feature #664 3.0 lib refactor #706

Merged
merged 56 commits into from
Nov 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
bc8d66f
extracted few things from lib.py
antirotor Oct 28, 2020
a2a1004
create lib module
antirotor Oct 28, 2020
5ae50f5
Merge branch 'feature/664-3-0-lib-refactor' into feature/lib-refactor…
antirotor Oct 28, 2020
eb9a67a
few fixes
antirotor Oct 28, 2020
c13e48c
lib changed to lib/old_lib to have a starting point
mkolar Oct 28, 2020
bceb93f
Merge branch 'feature/664-3-0-lib-refactor' into feature/lib-refactor…
mkolar Oct 28, 2020
d299c21
remove functions from old-lib import
mkolar Oct 28, 2020
d11ef77
fix relative imports for 2.x compatibility
mkolar Oct 28, 2020
98012be
add deprecated.py
mkolar Nov 3, 2020
acb134c
Merge pull request #669 from pypeclub/feature/lib-refactor-antirotor
mkolar Nov 3, 2020
15c03de
moved `get_avalon_database` and `set_io_database` to deprecated
iLLiCiTiT Nov 3, 2020
0096705
removed unused `CustomNone`
iLLiCiTiT Nov 3, 2020
dbfbe99
removed single line function `get_project`
iLLiCiTiT Nov 3, 2020
83578a9
removed unused import
iLLiCiTiT Nov 3, 2020
d46f6fb
moved independent imports as first in lib's __init__
iLLiCiTiT Nov 3, 2020
2ce0e7a
removed `get_project` import from pype.api
iLLiCiTiT Nov 3, 2020
9887dc4
moved applications import from lib_old
iLLiCiTiT Nov 3, 2020
c9b0ab8
added few comments
iLLiCiTiT Nov 3, 2020
b407291
removed empoty lines
iLLiCiTiT Nov 3, 2020
83c4696
moved `map_subsets_by_family` under `BuildWorkfile` class
iLLiCiTiT Nov 3, 2020
389d475
Import tests for #669
kalisp Nov 4, 2020
6bbd895
Merge remote-tracking branch 'origin/feature/lib_from_illicit_part_1'…
kalisp Nov 4, 2020
ba7abcb
Merge pull request #681 from pypeclub/feature/lib_from_illicit_part_1
kalisp Nov 4, 2020
8f01ab2
Merge branch 'feature/664-3-0-lib-refactor' of https://github.com/pyp…
kalisp Nov 4, 2020
3ac01c5
Import tests for #681
kalisp Nov 4, 2020
8d74d69
move grouper to extractor
mkolar Nov 10, 2020
ba66d03
move pairwise to plugin
mkolar Nov 10, 2020
e86215b
move pairwise to maya.lib
mkolar Nov 10, 2020
1ad1cea
remove modified_environ function
mkolar Nov 10, 2020
dca965b
remove _get_host
mkolar Nov 10, 2020
63b32be
move version and path related functions to new lib
mkolar Nov 10, 2020
5b891e0
typo in dosctring
mkolar Nov 10, 2020
6fb10db
add missing import
mkolar Nov 10, 2020
28ad05f
remvoe deleted function from API
mkolar Nov 10, 2020
da8f010
updated lib_old with newer changes
iLLiCiTiT Nov 10, 2020
324636a
fix method `map_subsets_by_family` call
iLLiCiTiT Nov 10, 2020
4be779b
BuildWorkfile class has it's own logger
iLLiCiTiT Nov 10, 2020
3edf202
moved all avalon context functions to one file
iLLiCiTiT Nov 10, 2020
c116e80
moved `get_subsets` to collect audio in celaction collector which is …
iLLiCiTiT Nov 10, 2020
36cd349
switch_item moved to fusion.lib as it's only place where is used
iLLiCiTiT Nov 10, 2020
833d6ff
moved BuildWorkfile to avalon context
iLLiCiTiT Nov 10, 2020
ab62127
ffprobe_streams moved to ffmpeg_utils
iLLiCiTiT Nov 10, 2020
e153fbe
cleaned up imports
iLLiCiTiT Nov 10, 2020
dafa84e
removed `get_subsets` from pype.api
iLLiCiTiT Nov 10, 2020
79cf878
removed imports from old lib
iLLiCiTiT Nov 10, 2020
f591d76
hound fixes
iLLiCiTiT Nov 10, 2020
e933955
#664 - added tests for #697
kalisp Nov 11, 2020
7f97e41
`get_subsets` is more efficient now
iLLiCiTiT Nov 11, 2020
b238c81
#664 - added tests for #700, resolved conflicts
kalisp Nov 11, 2020
0353a83
Merge remote-tracking branch 'origin/feature/lib_from_illicit_part_2'…
kalisp Nov 11, 2020
5d07af2
#664 - moved last 2 functions
kalisp Nov 11, 2020
433105e
#664 - removed obsolete Aport action
kalisp Nov 12, 2020
c1cbf31
Updated docstrings
kalisp Nov 12, 2020
fd8eb50
Updated docstrings
kalisp Nov 12, 2020
98e0d65
Updated docstrings
kalisp Nov 12, 2020
d5abe02
Conflict resolve
kalisp Nov 12, 2020
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
20 changes: 0 additions & 20 deletions docs/source/pype.aport.rst

This file was deleted.

1 change: 0 additions & 1 deletion docs/source/pype.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ Subpackages

.. toctree::

pype.aport
pype.avalon_apps
pype.clockify
pype.ftrack
Expand Down
8 changes: 0 additions & 8 deletions pype/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,9 @@
from .lib import (
version_up,
get_asset,
get_project,
get_hierarchy,
get_subsets,
get_version_from_path,
get_last_version_from_path,
modified_environ,
add_tool_to_environment,
source_hash,
get_latest_version
)
Expand Down Expand Up @@ -88,14 +84,10 @@

# get contextual data
"version_up",
"get_project",
"get_hierarchy",
"get_asset",
"get_subsets",
"get_version_from_path",
"get_last_version_from_path",
"modified_environ",
"add_tool_to_environment",
"source_hash",

"subprocess",
Expand Down
83 changes: 82 additions & 1 deletion pype/hosts/fusion/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from avalon.vendor.Qt import QtGui
import avalon.fusion

from avalon import io

self = sys.modules[__name__]
self._project = None
Expand Down Expand Up @@ -59,3 +59,84 @@ def get_additional_data(container):
return {"color": QtGui.QColor.fromRgbF(tile_color["R"],
tile_color["G"],
tile_color["B"])}


def switch_item(container,
asset_name=None,
subset_name=None,
representation_name=None):
"""Switch container asset, subset or representation of a container by name.

It'll always switch to the latest version - of course a different
approach could be implemented.

Args:
container (dict): data of the item to switch with
asset_name (str): name of the asset
subset_name (str): name of the subset
representation_name (str): name of the representation

Returns:
dict

"""

if all(not x for x in [asset_name, subset_name, representation_name]):
raise ValueError("Must have at least one change provided to switch.")

# Collect any of current asset, subset and representation if not provided
# so we can use the original name from those.
if any(not x for x in [asset_name, subset_name, representation_name]):
_id = io.ObjectId(container["representation"])
representation = io.find_one({"type": "representation", "_id": _id})
version, subset, asset, project = io.parenthood(representation)

if asset_name is None:
asset_name = asset["name"]

if subset_name is None:
subset_name = subset["name"]

if representation_name is None:
representation_name = representation["name"]

# Find the new one
asset = io.find_one({
"name": asset_name,
"type": "asset"
})
assert asset, ("Could not find asset in the database with the name "
"'%s'" % asset_name)

subset = io.find_one({
"name": subset_name,
"type": "subset",
"parent": asset["_id"]
})
assert subset, ("Could not find subset in the database with the name "
"'%s'" % subset_name)

version = io.find_one(
{
"type": "version",
"parent": subset["_id"]
},
sort=[('name', -1)]
)

assert version, "Could not find a version for {}.{}".format(
asset_name, subset_name
)

representation = io.find_one({
"name": representation_name,
"type": "representation",
"parent": version["_id"]}
)

assert representation, ("Could not find representation in the database "
"with the name '%s'" % representation_name)

avalon.api.switch(container, representation)

return representation
2 changes: 1 addition & 1 deletion pype/hosts/fusion/scripts/fusion_switch_shot.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def switch(asset_name, filepath=None, new=True):
representations = []
for container in containers:
try:
representation = pype.switch_item(
representation = fusion_lib.switch_item(
container,
asset_name=asset_name)
representations.append(representation)
Expand Down
4 changes: 3 additions & 1 deletion pype/hosts/hiero/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import hiero
import pyblish.api
import avalon.api as avalon
import avalon.io
from avalon.vendor.Qt import (QtWidgets, QtGui)
import pype.api as pype
from pype.api import Logger, Anatomy
Expand Down Expand Up @@ -58,7 +59,8 @@ def sync_avalon_data_to_workfile():
project.setProjectRoot(active_project_root)

# get project data from avalon db
project_data = pype.get_project()["data"]
project_doc = avalon.io.find_one({"type": "project"})
project_data = project_doc["data"]

log.debug("project_data: {}".format(project_data))

Expand Down
15 changes: 11 additions & 4 deletions pype/hosts/maya/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import bson
import json
import logging
import itertools
import contextlib
from collections import OrderedDict, defaultdict
from math import ceil
Expand Down Expand Up @@ -122,6 +123,12 @@ def float_round(num, places=0, direction=ceil):
return direction(num * (10**places)) / float(10**places)


def pairwise(iterable):
"""s -> (s0,s1), (s2,s3), (s4, s5), ..."""
a = iter(iterable)
return itertools.izip(a, a)


def unique(name):
assert isinstance(name, string_types), "`name` must be string"

Expand Down Expand Up @@ -419,12 +426,12 @@ def empty_sets(sets, force=False):
plugs=True,
connections=True) or []
original_connections.extend(connections)
for dest, src in lib.pairwise(connections):
for dest, src in pairwise(connections):
cmds.disconnectAttr(src, dest)
yield
finally:

for dest, src in lib.pairwise(original_connections):
for dest, src in pairwise(original_connections):
cmds.connectAttr(src, dest)

# Restore original members
Expand Down Expand Up @@ -1857,8 +1864,8 @@ def set_context_settings():
"""

# Todo (Wijnand): apply renderer and resolution of project

project_data = lib.get_project()["data"]
project_doc = io.find_one({"type": "project"})
project_data = project_doc["data"]
asset_data = lib.get_asset()["data"]

# Set project fps
Expand Down
2 changes: 1 addition & 1 deletion pype/hosts/nuke/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def format_anatomy(data):
if not version:
file = script_name()
data["version"] = pype.get_version_from_path(file)
project_document = pype.get_project()
project_document = io.find_one({"type": "project"})
data.update({
"subset": data["avalon"]["subset"],
"asset": data["avalon"]["asset"],
Expand Down
Loading