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

Refactor Deadline Submission JobInfo #49

Open
wants to merge 143 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
143 commits
Select commit Hold shift + click to select a range
d1a883b
New Settings for CollectJobInfoItem
kalisp Oct 16, 2024
f72e87f
Matched implemented artist overrides definitions
kalisp Oct 17, 2024
2b29403
Added collected jobInfo object
kalisp Oct 17, 2024
cb0d24d
Use DeadlineJobInfo as collector object
kalisp Oct 18, 2024
37c0a0d
Removed six dependency
kalisp Oct 18, 2024
3358838
Implemented new generic method applicable for all DCC
kalisp Oct 18, 2024
60da8b9
Removed unneeded imports
kalisp Oct 18, 2024
ae3c739
Do not pass empty string to DeadlineJobInfo
kalisp Oct 18, 2024
1c8990a
Removed unneded imports
kalisp Oct 18, 2024
57860ce
Reimplemented get_job_info, moved to generic impl
kalisp Oct 18, 2024
10f566f
Removed storign deadline info to instance
kalisp Oct 18, 2024
bbb12b7
Updates to DeadlineJobInfo to match previous implementation
kalisp Oct 18, 2024
c26c997
Added Frames field for explicit rendering
kalisp Oct 18, 2024
e1eba7f
Run CollectJobInfo only locally
kalisp Oct 18, 2024
8062462
Implemented explicit frames filtering on simple files
kalisp Oct 18, 2024
ec908e0
Reworked removal of deadline in submit job
kalisp Oct 18, 2024
64b22ff
Removed empty line
kalisp Oct 18, 2024
0d3125d
Added empty line at the end
kalisp Oct 18, 2024
c206b24
Formatting
kalisp Oct 18, 2024
803c25c
Removed forgotten dev code
kalisp Oct 18, 2024
201c5b8
Refactor batchname
kalisp Oct 18, 2024
57ac094
Merge develop
kalisp Oct 30, 2024
6a280b0
Added last empty line
kalisp Oct 30, 2024
6d3fe14
Changed collection of project_settings
kalisp Oct 30, 2024
f09cde7
Removed hiding attributes on disabled instances
kalisp Oct 30, 2024
47f0f8b
Replaced querying with cached methods
kalisp Oct 30, 2024
3ae7c94
Fixed handling of list defaults
kalisp Oct 30, 2024
41e2f03
Refactor defs initialization
kalisp Oct 30, 2024
8227376
Fix instance variable
kalisp Oct 30, 2024
24dbf6d
Formatting
kalisp Oct 30, 2024
87d5f4b
Refactored base definition to array
kalisp Oct 30, 2024
2fbc45b
Fix default values for not existing task entity
kalisp Oct 30, 2024
c6416ad
Removed unnecessary condition
kalisp Oct 30, 2024
e593e5d
Separated AYON fields from Deadline own
kalisp Oct 31, 2024
dfa544b
Updates to limit_groups, machine lists
kalisp Oct 31, 2024
ac77178
Updated machine_limit handling
kalisp Oct 31, 2024
068ae90
Updated expected_files handling
kalisp Oct 31, 2024
0e3760a
Implemented additional JobInfo, PluginInfo fields
kalisp Oct 31, 2024
26a63d0
Refactor
kalisp Nov 1, 2024
1352ad0
Removed unneeded variable
kalisp Nov 1, 2024
1e9a349
Refactored querying of profiles
kalisp Nov 1, 2024
a692796
Refactor
kalisp Nov 1, 2024
67de670
Refactored task values
kalisp Nov 1, 2024
834290a
Merge remote-tracking branch 'origin/feature/AY-6789_Render-instance-…
kalisp Nov 1, 2024
dbd9304
Removed magic conversion from Settings to fields
kalisp Nov 1, 2024
5fa1034
Implemented UsePublished
kalisp Nov 1, 2024
6330f07
Removed unneeded default_priority
kalisp Nov 1, 2024
7221315
Removed unneeded asset_dependencies
kalisp Nov 1, 2024
436f51f
Replaced missed use_published
kalisp Nov 1, 2024
02e0c85
Updates for Maya to show attr defs
kalisp Nov 1, 2024
0a22384
Formatting to separate profile from actual presets
kalisp Nov 1, 2024
1e71e44
Moved resolution of scene_path earlier
kalisp Nov 1, 2024
69e9414
Removed unneeded plugin_info class variable
kalisp Nov 1, 2024
18b1764
Removed unused import
kalisp Nov 1, 2024
d01479a
Refactored Blender submission
kalisp Nov 1, 2024
2db8418
Refactored querying of plugin
kalisp Nov 1, 2024
3bf017f
Implemented in Harmony
kalisp Nov 1, 2024
91b9101
Implemented in Max
kalisp Nov 1, 2024
567ed8c
Added comments and pools
kalisp Nov 1, 2024
150bcd7
Refactored JobInfo for Unreal
kalisp Nov 1, 2024
31b71b9
Refactored JobInfo for Houdini
kalisp Nov 1, 2024
ce2f93a
Reordered defaults
kalisp Nov 4, 2024
e39c116
Ruff fixes
kalisp Nov 4, 2024
96afdfd
Fix missing import
kalisp Nov 4, 2024
7c89b2c
Fix empty additional info
kalisp Nov 4, 2024
e0f1a29
Refactor Fusion submitter to be based on the AbstractSubmitDeadline p…
BigRoy Nov 4, 2024
af1e4f2
Improve `Delay Job` attribute definition (less long label, add placeh…
BigRoy Nov 4, 2024
f6c3974
Add some type hints to the code
BigRoy Nov 4, 2024
d8c44d9
Moved pools from separate plugin to collect_jobinfo
kalisp Nov 4, 2024
edff1c5
Merge branch 'feature/AY-6789_Render-instance-support-of-Frame-List' …
kalisp Nov 4, 2024
18f5146
Merge pull request #56 from BigRoy/feature/AY-6789_Render-instance-su…
kalisp Nov 4, 2024
b5f178b
Added group to Publisher UI
kalisp Nov 4, 2024
84783e8
Merge remote-tracking branch 'origin/feature/AY-6789_Render-instance-…
kalisp Nov 4, 2024
124d715
Fix limit group placeholder
kalisp Nov 4, 2024
42658bc
Fix empty plugin info
kalisp Nov 4, 2024
d202aaf
Implemented enum fields and querying for them
kalisp Nov 4, 2024
13c80ec
Fix removing job_info
kalisp Nov 4, 2024
2cb890a
Formatting added last empty line
kalisp Nov 5, 2024
f3db2b5
Fix removal of job_info
kalisp Nov 5, 2024
7cf4c72
Fix use keyword argument
kalisp Nov 5, 2024
193ea1c
Fix usage of keyword argument
kalisp Nov 5, 2024
8526e5a
Fix sending of machine_list
kalisp Nov 5, 2024
3b03400
Fix removal job_info
kalisp Nov 5, 2024
bd3010f
Fix do not trigger on not farm instances
kalisp Nov 5, 2024
9fcc50a
Fix showing attributes for not farm instances
kalisp Nov 6, 2024
3b81896
Fix typo
kalisp Nov 6, 2024
3d6778c
Removed unnecessary class variables
kalisp Nov 6, 2024
73b3400
Transformed Nuke to AbstractSubmitDeadline
kalisp Nov 6, 2024
19639fb
Transformed CelAction to AbstractSubmitDeadline
kalisp Nov 6, 2024
389fef8
Replaced attr with dataclass
kalisp Nov 6, 2024
051d8e2
Refactored names of getters
kalisp Nov 7, 2024
1461ffd
Removed unneeded comment
kalisp Nov 7, 2024
2f58203
Refactor names to more precise
kalisp Nov 7, 2024
7cdc12e
Reformatted docstrings
kalisp Nov 7, 2024
1e39873
Added docstrings
kalisp Nov 7, 2024
318fac0
Changed methods to classmethod
kalisp Nov 7, 2024
d6378a3
Changed methods to staticmethod
kalisp Nov 7, 2024
3cbecec
Fix typo
kalisp Nov 7, 2024
675a335
Refactored getter names
kalisp Nov 7, 2024
0a42400
Refactored use of cls
kalisp Nov 7, 2024
403d577
Refactored access to deadline info
kalisp Nov 7, 2024
ba7293d
Refactored utility methods for DL api to lib file
kalisp Nov 7, 2024
86ddfb8
Fix typo
kalisp Nov 7, 2024
6686f41
Removed obsolete fields for CelAction
kalisp Nov 7, 2024
118ace2
Removed env_search_replace_values and env_allowed_keys
kalisp Nov 7, 2024
b8f3373
Removed hardoced chunk, uses from Profile
kalisp Nov 7, 2024
3df6c16
Docstrings
kalisp Nov 7, 2024
3ebe477
Added validator for priority
kalisp Nov 7, 2024
37dcd72
Removed use_gpu from JobInfo
kalisp Nov 8, 2024
d2c0857
Fix pool
kalisp Nov 8, 2024
8b7e43a
Fix pool
kalisp Nov 8, 2024
39f359d
Merge
kalisp Nov 8, 2024
877542f
Reordered imports
kalisp Nov 11, 2024
286601f
Refactored logic
kalisp Nov 11, 2024
6816382
Pass in project_settings
kalisp Nov 11, 2024
397cf34
Use class variable
kalisp Nov 11, 2024
781bab5
Refactored list fields
kalisp Nov 11, 2024
5596190
Changed recalculating only on context change
kalisp Nov 11, 2024
1068256
Fix removing job_info
kalisp Nov 11, 2024
4b9d487
Fix pool collection
kalisp Nov 11, 2024
ce69056
Merge remote-tracking branch 'origin/feature/AY-6789_Render-instance-…
kalisp Nov 11, 2024
46a90af
Merge branch 'develop' of https://github.com/ynput/ayon-deadline into…
kalisp Nov 11, 2024
c424311
Cleaned up plugin Settings
kalisp Nov 13, 2024
112220e
Provided basic profile for CollectJobInfo
kalisp Nov 13, 2024
cd81da2
Added missed default artist overrides
kalisp Nov 13, 2024
9732866
Fix wrong access to job_delay default value
kalisp Nov 13, 2024
42148a9
Use list comprehension for pool enum
kalisp Nov 13, 2024
c9d1c4a
Use list comprehension for machines enum
kalisp Nov 13, 2024
d58ff4d
Use list comprehension
kalisp Nov 13, 2024
005a5fb
Fix condition
kalisp Nov 13, 2024
deb8aa8
Fix copy to deepcopy
kalisp Nov 13, 2024
ba26549
Fix formatting
kalisp Nov 13, 2024
faa1cba
Use list comprehension for groups
kalisp Nov 13, 2024
ea9b2d6
Use list comprehension for limit groups
kalisp Nov 13, 2024
a307520
Use list comprehension for machine_limit defaults
kalisp Nov 13, 2024
7e0ad18
Fix wrong assignment
kalisp Nov 13, 2024
df7a85e
Fix deepcopy from import
kalisp Nov 13, 2024
5c4ebd0
Added deadline to instance families
kalisp Nov 13, 2024
c05ddc2
Make frames optional
kalisp Nov 14, 2024
d3cbe0b
Fix updates of job_info between jobs
kalisp Nov 15, 2024
269b943
add missing import
MustafaJafar Nov 15, 2024
fa9327c
remove unused import
MustafaJafar Nov 15, 2024
3aa671c
Fix propagation updated job_info
kalisp Nov 15, 2024
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
470 changes: 97 additions & 373 deletions client/ayon_deadline/abstract_submit_deadline.py

Large diffs are not rendered by default.

151 changes: 107 additions & 44 deletions client/ayon_deadline/addon.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
import os
import sys

import requests
import six
from typing import Optional, List

from ayon_core.lib import Logger
from ayon_core.addon import AYONAddon, IPluginPaths

from .lib import (
get_deadline_workers,
get_deadline_groups,
get_deadline_limit_groups,
get_deadline_pools
)
from .version import __version__


DEADLINE_ADDON_ROOT = os.path.dirname(os.path.abspath(__file__))


class DeadlineWebserviceError(Exception):
"""
Exception to throw when connection to Deadline server fails.
"""


class DeadlineAddon(AYONAddon, IPluginPaths):
name = "deadline"
version = __version__
Expand All @@ -38,6 +35,11 @@ def initialize(self, studio_settings):

self.deadline_servers_info = deadline_servers_info

self._pools_by_server_name = {}
Copy link
Member

@iLLiCiTiT iLLiCiTiT Nov 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably invalidate the cache after some time? There is helper NestedCacheItem class for that

    def _initialization(self):
        ...
        self._limit_groups_by_server_name = NestedCacheItem(lifetime=5*60)
        ...

    def limit_groups_by_server_name(self, server_name: str) -> List[str]:
        limit_groups_cache = self._limit_groups_by_server_name[server_name]
        if not limit_groups_cache.is_valid:
            dl_server_info = self.deadline_servers_info.get(server_name)

            auth = (dl_server_info["default_username"],
                    dl_server_info["default_password"])
            limit_groups = self.get_deadline_limit_groups(
                dl_server_info["value"],
                auth
            )
            limit_groups_cache.update_data(limit_groups)

        return limit_groups_cache.get_data()

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't bother really. The query of this data is really quite slow most of the time - yet at the same time someone RARELY changes this on Deadline settings during production - and restarting the host integration I'd say is totally fine for those edge cases instead of slowness say every publish every five minutes?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We know about artists who have opened Nuke for a week. We should probably invalidate, cached values after some time.

self._limit_groups_by_server_name = {}
self._groups_by_server_name = {}
self._machines_by_server_name = {}

def get_plugin_paths(self):
"""Deadline plugin paths."""
# Note: We are not returning `publish` key because we have overridden
Expand All @@ -46,47 +48,108 @@ def get_plugin_paths(self):
# abstract on the parent class
return {}

def get_publish_plugin_paths(self, host_name=None):
def get_publish_plugin_paths(
self,
host_name: Optional[str] = None
) -> List[str]:
publish_dir = os.path.join(DEADLINE_ADDON_ROOT, "plugins", "publish")
paths = [os.path.join(publish_dir, "global")]
if host_name:
paths.append(os.path.join(publish_dir, host_name))
return paths

@staticmethod
def get_deadline_pools(webservice, auth=None, log=None):
"""Get pools from Deadline.
def get_pools_by_server_name(self, server_name: str) -> List[str]:
"""Returns dictionary of pools per DL server

Args:
server_name (str): Deadline Server name from Project Settings.

Returns:
Dict[str, List[str]]: {"default": ["pool1", "pool2"]}

"""
pools = self._pools_by_server_name.get(server_name)
if pools is None:
dl_server_info = self.deadline_servers_info[server_name]

auth = (dl_server_info["default_username"],
dl_server_info["default_password"])
pools = get_deadline_pools(
dl_server_info["value"],
auth
)
self._pools_by_server_name[server_name] = pools

return pools

def get_groups_by_server_name(self, server_name: str) -> List[str]:
"""Returns dictionary of groups per DL server

Args:
server_name (str): Deadline Server name from Project Settings.

Returns:
Dict[str, List[str]]: {"default": ["group1", "group2"]}

"""
groups = self._groups_by_server_name.get(server_name)
if groups is None:
dl_server_info = self.deadline_servers_info[server_name]

auth = (dl_server_info["default_username"],
dl_server_info["default_password"])
groups = get_deadline_groups(
dl_server_info["value"],
auth
)
self._groups_by_server_name[server_name] = groups

return groups

def get_limit_groups_by_server_name(self, server_name: str) -> List[str]:
"""Returns dictionary of limit groups per DL server

Args:
server_name (str): Deadline Server name from Project Settings.

Returns:
Dict[str, List[str]]: {"default": ["limit1", "limit2"]}

"""
limit_groups = self._limit_groups_by_server_name.get(server_name)
if limit_groups is None:
dl_server_info = self.deadline_servers_info[server_name]

auth = (dl_server_info["default_username"],
dl_server_info["default_password"])
limit_groups = get_deadline_limit_groups(
dl_server_info["value"],
auth
)
self._limit_groups_by_server_name[server_name] = limit_groups

return limit_groups

def get_machines_by_server_name(self, server_name: str) -> List[str]:
"""Returns dictionary of machines/workers per DL server

Args:
webservice (str): Server url.
auth (Optional[Tuple[str, str]]): Tuple containing username,
password
log (Optional[Logger]): Logger to log errors to, if provided.
server_name (str): Deadline Server name from Project Settings.

Returns:
List[str]: Pools.
Throws:
RuntimeError: If deadline webservice is unreachable.
Dict[str, List[str]]: {"default": ["renderNode1", "PC1"]}

"""
from .abstract_submit_deadline import requests_get

if not log:
log = Logger.get_logger(__name__)

argument = "{}/api/pools?NamesOnly=true".format(webservice)
try:
kwargs = {}
if auth:
kwargs["auth"] = auth
response = requests_get(argument, **kwargs)
except requests.exceptions.ConnectionError as exc:
msg = 'Cannot connect to DL web service {}'.format(webservice)
log.error(msg)
six.reraise(
DeadlineWebserviceError,
DeadlineWebserviceError('{} - {}'.format(msg, exc)),
sys.exc_info()[2])
if not response.ok:
log.warning("No pools retrieved")
return []

return response.json()
machines = self._machines_by_server_name.get(server_name)
if machines is None:
dl_server_info = self.deadline_servers_info[server_name]

auth = (dl_server_info["default_username"],
dl_server_info["default_password"])
machines = get_deadline_workers(
dl_server_info["value"],
auth
)
self._machines_by_server_name[server_name] = machines

return machines
Loading