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

[#69] Version.take_name has been renamed to Version.variant_name. #94

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 16 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@
Stalker Changes
===============

1.0.0
=====

* `Version.take_name` has been renamed to `Version.variant_name` to follow the industry
standard.
* `Task.depends` renmaed to `Task.depends_on`.
* `TaskDependency.task_depends_to` renamed to `TaskDependency.task_depends_on`.
* Stalker now supports Python versions from 3.8 to 3.13.
* Added GitHub actions for CI/CD practices.
* Updated validation messages to make them more consistently displaying the current
type and the value of the validated attribute.
* Added Makefile workflow to help creating a virtualenv, building, installing, releasing
etc. actions much more easier.
* Modernised Stalker as a Python project. It is now fully PEP 517 compliant.
* Renamed OSX to macOS anywhere it is mentioned.

0.2.27
======

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""Rename Version.take_name to Version.variant_name

Revision ID: ec1eb2151bb9
Revises: 019378697b5b
Create Date: 2024-11-01 16:37:18.048904
"""

from alembic import op

import sqlalchemy as sa



# revision identifiers, used by Alembic.
revision = 'ec1eb2151bb9'
down_revision = '019378697b5b'


def upgrade():
"""Upgrade the tables."""
op.alter_column(
"Versions", "take_name", new_column_name="variant_name"
)


def downgrade():
"""Downgrade the tables."""
op.alter_column(
"Versions", "variant_name", new_column_name="take_name"
)
2 changes: 1 addition & 1 deletion docs/source/_static/images/stalker_design.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1677,7 +1677,7 @@
<shape arcwidth="20.0" archeight="20.0" xsi:type="roundRect"/>
</child>
<child ID="1365"
label="take_name | STRING, DEFAULT=&quot;Main&quot;"
label="variant_name | STRING, DEFAULT=&quot;Main&quot;"
created="1275345214943" x="34.0" y="43.25" width="228.0"
height="23.0" strokeWidth="1.0" autoSized="true" xsi:type="node">
<fillColor>#F2AE45</fillColor>
Expand Down
8 changes: 4 additions & 4 deletions docs/source/configure.rst
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,12 @@ Variables which can be set in ``config.py`` are as follows:

key = "stalker_default_key"

.. confval:: version_take_name
.. confval:: version_variant_name

The default take name for :class:`~stalker.models.version.Version`
The default variant name for :class:`~stalker.models.version.Version`
instances. Default value is::

version_take_name = "Main"
version_variant_name = "Main"

.. confval:: status_bg_color

Expand Down Expand Up @@ -555,7 +555,7 @@ Variables which can be set in ``config.py`` are as follows:
:class:`~stalker.models.version.Version` instances. This value is not used
yet. Default value is::

filename_template = '{{task.entity_type}}_{{task.id}}_{{version.take_name}}_v{{"%03d"|format(version.version_number)}}'
filename_template = '{{task.entity_type}}_{{task.id}}_{{version.variant_name}}_v{{"%03d"|format(version.version_number)}}'

.. confval:: sequence_format

Expand Down
6 changes: 3 additions & 3 deletions examples/flat_project_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
name="Flat Task Template",
target_entity_type="Task",
path="{{project.code}}", # everything will be under the same folder
filename="{{task.nice_name}}_{{version.take_name}}"
filename="{{task.nice_name}}_{{version.variant_name}}"
'_v{{"%03d"|format(version.version_number)}}{{extension}}'
# you can customize this as you wish, you can even use a uuid4
# as the file name
Expand Down Expand Up @@ -109,7 +109,7 @@
target_entity_type="Task",
path="{{project.code}}/{%- for parent_task in parent_tasks -%}"
"{{parent_task.nice_name}}/{%- endfor -%}", # all in different folder
filename="{{task.nice_name}}_{{version.take_name}}"
filename="{{task.nice_name}}_{{version.variant_name}}"
'_v{{"%03d"|format(version.version_number)}}{{extension}}',
)

Expand Down Expand Up @@ -163,7 +163,7 @@
db.DBSession.add(shot1) # this should be enough to add the rest

# now create new maya files for them
comp_v1 = Version(task=comp, take_name="Test")
comp_v1 = Version(task=comp, variant_name="Test")
comp_v1.update_paths()
comp_v1.extension = ".ma"

Expand Down
4 changes: 2 additions & 2 deletions src/stalker/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ class Config(ConfigBase):
admin_group_name="admins",
# the default keyword which is going to be used in password scrambling
key="stalker_default_key",
version_take_name="Main",
version_variant_name="Main",
actions=["Create", "Read", "Update", "Delete", "List"], # CRUDL
# Tickets
ticket_label="Ticket",
Expand Down Expand Up @@ -434,7 +434,7 @@ class Config(ConfigBase):
}""",
tj_command="tj3" if sys.platform == "win32" else "/usr/local/bin/tj3",
path_template="{{project.code}}/{%- for parent_task in parent_tasks -%}{{parent_task.nice_name}}/{%- endfor -%}", # noqa: B950
filename_template='{{task.entity_type}}_{{task.id}}_{{version.take_name}}_v{{"%03d"|format(version.version_number)}}', # noqa: B950
filename_template='{{task.entity_type}}_{{task.id}}_{{version.variant_name}}_v{{"%03d"|format(version.version_number)}}', # noqa: B950
# --------------------------------------------
# the following settings came from oyProjectManager
sequence_format="%h%p%t %R",
Expand Down
76 changes: 39 additions & 37 deletions src/stalker/models/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ class Version(Link, DAGMixin):
$REPO{{project.repository.id}}/{{project.code}}/{%- for parent_task in parent_tasks -%}{{parent_task.nice_name}}/{%- endfor -%}

Args:
take_name (str): A short string holding the current take name. Takes in Stalker
are used solely for grouping individual versions together. Versions with the
same ``take_name`` (of the same Task) are numbered together. It can be any
variant_name (str): A short string holding the current variant name. Variants in
Stalker are used for creating variants versions. Versions with the same
``variant_name`` (of the same Task) are numbered together. It can be any
alphanumeric value (a-zA-Z0-9_). The default is the string "Main". When
skipped it will use the default value. It can not start with a number. It
can not have white spaces.
Expand Down Expand Up @@ -105,11 +105,11 @@ class Version(Link, DAGMixin):
back_populates="versions",
)

take_name = Column(
variant_name = Column(
String(256),
default=defaults.version_take_name,
doc="""Takes in Versions are used solely for grouping individual
versions together.""",
default=defaults.version_variant_name,
doc="""Variants in Versions are used for representing different variants of the
same version.""",
)

version_number = Column(
Expand Down Expand Up @@ -150,7 +150,7 @@ class Version(Link, DAGMixin):
def __init__(
self,
task=None,
take_name=defaults.version_take_name,
variant_name=defaults.version_variant_name,
inputs=None,
outputs=None,
parent=None,
Expand All @@ -164,7 +164,7 @@ def __init__(

DAGMixin.__init__(self, parent=parent)

self.take_name = take_name
self.variant_name = variant_name
self.task = task
self.version_number = None
if inputs is None:
Expand Down Expand Up @@ -196,59 +196,61 @@ def __repr__(self) -> str:
)

@classmethod
def _format_take_name(cls, take_name: str) -> str:
"""Format the given take_name value.
def _format_variant_name(cls, variant_name: str) -> str:
"""Format the given variant_name value.

Args:
take_name (str): The take name value to be formatted.
variant_name (str): The variant name value to be formatted.

Returns:
str: The formatted take name value.
str: The formatted variant name value.
"""
# remove unnecessary characters
take_name = re.sub(r"([^a-zA-Z0-9\s_\-@]+)", r"", take_name).strip()
variant_name = re.sub(r"([^a-zA-Z0-9\s_\-@]+)", r"", variant_name).strip()

# replace empty spaces with underscores
take_name = re.sub(r"[\s]+", "_", take_name)
variant_name = re.sub(r"[\s]+", "_", variant_name)

# replace multiple underscores with only one
# take_name = re.sub(r'([_]+)', r'_', take_name)
# variant_name = re.sub(r'([_]+)', r'_', variant_name)

# remove any non allowed characters from the start
take_name = re.sub(r"^[^a-zA-Z0-9]+", r"", take_name)
variant_name = re.sub(r"^[^a-zA-Z0-9]+", r"", variant_name)

return take_name
return variant_name

@validates("take_name")
def _validate_take_name(self, key: str, take_name: str) -> str:
"""Validate the given take_name value.
@validates("variant_name")
def _validate_variant_name(self, key: str, variant_name: str) -> str:
"""Validate the given variant_name value.

Args:
key (str): The name of the validated column.
take_name (str): The take name value to be validated.
variant_name (str): The variant name value to be validated.

Raises:
TypeError: If the take name value is not a string.
ValueError: If the take name value is an empty string.
TypeError: If the variant name value is not a string.
ValueError: If the variant name value is an empty string.

Returns:
str: The validated take name value.
str: The validated variant name value.
"""
if not isinstance(take_name, string_types):
if not isinstance(variant_name, string_types):
raise TypeError(
"{}.take_name should be a string, not {}: '{}'".format(
self.__class__.__name__, take_name.__class__.__name__, take_name
"{}.variant_name should be a string, not {}: '{}'".format(
self.__class__.__name__,
variant_name.__class__.__name__,
variant_name,
)
)

take_name = self._format_take_name(take_name)
variant_name = self._format_variant_name(variant_name)

if take_name == "":
if variant_name == "":
raise ValueError(
f"{self.__class__.__name__}.take_name can not be an empty string"
f"{self.__class__.__name__}.variant_name can not be an empty string"
)

return take_name
return variant_name

@property
def latest_version(self) -> "Version":
Expand All @@ -262,7 +264,7 @@ def latest_version(self) -> "Version":
with DBSession.no_autoflush:
last_version = (
Version.query.filter(Version.task == self.task)
.filter(Version.take_name == self.take_name)
.filter(Version.variant_name == self.variant_name)
.order_by(Version.version_number.desc())
.first()
)
Expand Down Expand Up @@ -522,7 +524,7 @@ def latest_published_version(self) -> "Version":
"""
return (
Version.query.filter_by(task=self.task)
.filter_by(take_name=self.take_name)
.filter_by(variant_name=self.variant_name)
.filter_by(is_published=True)
.order_by(Version.version_number.desc())
.first()
Expand Down Expand Up @@ -563,14 +565,14 @@ def __eq__(self, other):

Returns:
bool: True if the other object is equal to this one as an Entity, is a
Version instance, has the same task, same take_name and same
Version instance, has the same task, same variant_name and same
version_number.
"""
return (
super(Version, self).__eq__(other)
and isinstance(other, Version)
and self.task == other.task
and self.take_name == other.take_name
and self.variant_name == other.variant_name
and self.version_number == other.version_number
)

Expand Down Expand Up @@ -624,7 +626,7 @@ def nice_name(self) -> str:
naming_parents = self.naming_parents
return self._format_nice_name(
"{}_{}".format(
"_".join(map(lambda x: x.nice_name, naming_parents)), self.take_name
"_".join(map(lambda x: x.nice_name, naming_parents)), self.variant_name
)
)

Expand Down
Loading
Loading