mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 12:54:40 +01:00
♻️ remove staging logic
This commit is contained in:
parent
ed6cadb22b
commit
84b3bc3db2
4 changed files with 54 additions and 93 deletions
|
|
@ -57,7 +57,6 @@ class OpenPypeVersion(semver.VersionInfo):
|
|||
"""Class for storing information about OpenPype version.
|
||||
|
||||
Attributes:
|
||||
staging (bool): True if it is staging version
|
||||
path (str): path to OpenPype
|
||||
|
||||
"""
|
||||
|
|
@ -161,15 +160,6 @@ class OpenPypeVersion(semver.VersionInfo):
|
|||
version = OpenPypeVersion.parse(string[m.start():m.end()])
|
||||
return version
|
||||
|
||||
@classmethod
|
||||
def parse(cls, version):
|
||||
"""Extends parse to handle ta handle staging variant."""
|
||||
v = super().parse(version)
|
||||
openpype_version = cls(major=v.major, minor=v.minor,
|
||||
patch=v.patch, prerelease=v.prerelease,
|
||||
build=v.build)
|
||||
return openpype_version
|
||||
|
||||
def __hash__(self):
|
||||
return hash(self.path) if self.path else hash(str(self))
|
||||
|
||||
|
|
@ -448,7 +438,6 @@ class OpenPypeVersion(semver.VersionInfo):
|
|||
The version does not contain information about path and source.
|
||||
|
||||
This is utility version to get the latest version from all found.
|
||||
Build version is not listed if staging is enabled.
|
||||
|
||||
Arguments 'local' and 'remote' define if local and remote repository
|
||||
versions are used. All versions are used if both are not set (or set
|
||||
|
|
@ -483,7 +472,7 @@ class OpenPypeVersion(semver.VersionInfo):
|
|||
return all_versions[-1]
|
||||
|
||||
@classmethod
|
||||
def get_expected_studio_version(cls, global_settings=None):
|
||||
def get_expected_studio_version(cls, staging=False, global_settings=None):
|
||||
"""Expected OpenPype version that should be used at the moment.
|
||||
|
||||
If version is not defined in settings the latest found version is
|
||||
|
|
@ -492,12 +481,13 @@ class OpenPypeVersion(semver.VersionInfo):
|
|||
Using precached global settings is needed for usage inside OpenPype.
|
||||
|
||||
Args:
|
||||
staging (bool): Staging version or production version.
|
||||
global_settings (dict): Optional precached global settings.
|
||||
|
||||
Returns:
|
||||
OpenPypeVersion: Version that should be used.
|
||||
"""
|
||||
result = get_expected_studio_version_str(global_settings)
|
||||
result = get_expected_studio_version_str(staging, global_settings)
|
||||
if not result:
|
||||
return None
|
||||
return OpenPypeVersion(version=result)
|
||||
|
|
@ -567,7 +557,7 @@ class BootstrapRepos:
|
|||
"""Get path for specific version in list of OpenPype versions.
|
||||
|
||||
Args:
|
||||
version (str): Version string to look for (1.2.4+staging)
|
||||
version (str): Version string to look for (1.2.4-nightly.1+test)
|
||||
version_list (list of OpenPypeVersion): list of version to search.
|
||||
|
||||
Returns:
|
||||
|
|
|
|||
|
|
@ -16,14 +16,13 @@ from .pype_commands import PypeCommands
|
|||
@click.option("--use-staging", is_flag=True,
|
||||
expose_value=False, help="use staging variants")
|
||||
@click.option("--list-versions", is_flag=True, expose_value=False,
|
||||
help=("list all detected versions. Use With `--use-staging "
|
||||
"to list staging versions."))
|
||||
help="list all detected versions.")
|
||||
@click.option("--validate-version", expose_value=False,
|
||||
help="validate given version integrity")
|
||||
@click.option("--debug", is_flag=True, expose_value=False,
|
||||
help=("Enable debug"))
|
||||
help="Enable debug")
|
||||
@click.option("--verbose", expose_value=False,
|
||||
help=("Change OpenPype log level (debug - critical or 0-50)"))
|
||||
help="Change OpenPype log level (debug - critical or 0-50)")
|
||||
def main(ctx):
|
||||
"""Pype is main command serving as entry point to pipeline system.
|
||||
|
||||
|
|
@ -416,20 +415,18 @@ def unpack_project(zipfile, root):
|
|||
|
||||
@main.command()
|
||||
def interactive():
|
||||
"""Interative (Python like) console.
|
||||
"""Interactive (Python like) console.
|
||||
|
||||
Helpfull command not only for development to directly work with python
|
||||
Helpful command not only for development to directly work with python
|
||||
interpreter.
|
||||
|
||||
Warning:
|
||||
Executable 'openpype_gui' on windows won't work.
|
||||
Executable 'openpype_gui' on Windows won't work.
|
||||
"""
|
||||
|
||||
from openpype.version import __version__
|
||||
|
||||
banner = "OpenPype {}\nPython {} on {}".format(
|
||||
__version__, sys.version, sys.platform
|
||||
)
|
||||
banner = f"OpenPype {__version__}\nPython {sys.version} on {sys.platform}"
|
||||
code.interact(banner)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ repository or locally available.
|
|||
|
||||
import os
|
||||
import sys
|
||||
import warnings
|
||||
|
||||
import openpype.version
|
||||
|
||||
|
|
@ -60,9 +61,16 @@ def is_running_from_build():
|
|||
def is_running_staging():
|
||||
"""Currently used OpenPype is staging version.
|
||||
|
||||
Deprecated:
|
||||
Since 3.15
|
||||
|
||||
Returns:
|
||||
bool: True if openpype version containt 'staging'.
|
||||
"""
|
||||
warnings.warn(
|
||||
"Staging version logic set by version string is deprecated.",
|
||||
DeprecationWarning
|
||||
)
|
||||
if "staging" in get_openpype_version():
|
||||
return True
|
||||
return False
|
||||
|
|
|
|||
104
start.py
104
start.py
|
|
@ -516,8 +516,6 @@ def _process_arguments() -> tuple:
|
|||
if m and m.group('version'):
|
||||
use_version = m.group('version')
|
||||
_print(f">>> Requested version [ {use_version} ]")
|
||||
if "+staging" in use_version:
|
||||
use_staging = True
|
||||
break
|
||||
|
||||
if use_version is None:
|
||||
|
|
@ -682,8 +680,7 @@ def _find_frozen_openpype(use_version: str = None,
|
|||
Path: Path to version to be used.
|
||||
|
||||
Raises:
|
||||
RuntimeError: If no OpenPype version are found or no staging version
|
||||
(if requested).
|
||||
RuntimeError: If no OpenPype version are found.
|
||||
|
||||
"""
|
||||
# Collect OpenPype versions
|
||||
|
|
@ -698,13 +695,10 @@ def _find_frozen_openpype(use_version: str = None,
|
|||
if use_version.lower() == "latest":
|
||||
# Version says to use latest version
|
||||
_print(">>> Finding latest version defined by use version")
|
||||
openpype_version = bootstrap.find_latest_openpype_version(
|
||||
use_staging)
|
||||
openpype_version = bootstrap.find_latest_openpype_version()
|
||||
else:
|
||||
_print(f">>> Finding specified version \"{use_version}\"")
|
||||
openpype_version = bootstrap.find_openpype_version(
|
||||
use_version, use_staging
|
||||
)
|
||||
openpype_version = bootstrap.find_openpype_version(use_version)
|
||||
|
||||
if openpype_version is None:
|
||||
raise OpenPypeVersionNotFound(
|
||||
|
|
@ -714,8 +708,7 @@ def _find_frozen_openpype(use_version: str = None,
|
|||
elif studio_version is not None:
|
||||
# Studio has defined a version to use
|
||||
_print(f">>> Finding studio version \"{studio_version}\"")
|
||||
openpype_version = bootstrap.find_openpype_version(
|
||||
studio_version, use_staging)
|
||||
openpype_version = bootstrap.find_openpype_version(studio_version)
|
||||
if openpype_version is None:
|
||||
raise OpenPypeVersionNotFound((
|
||||
"Requested OpenPype version "
|
||||
|
|
@ -728,20 +721,15 @@ def _find_frozen_openpype(use_version: str = None,
|
|||
_print((
|
||||
">>> Finding latest version "
|
||||
f"with [ {installed_version} ]"))
|
||||
openpype_version = bootstrap.find_latest_openpype_version(
|
||||
use_staging)
|
||||
openpype_version = bootstrap.find_latest_openpype_version()
|
||||
|
||||
if openpype_version is None:
|
||||
if use_staging:
|
||||
reason = "Didn't find any staging versions."
|
||||
else:
|
||||
reason = "Didn't find any versions."
|
||||
raise OpenPypeVersionNotFound(reason)
|
||||
raise OpenPypeVersionNotFound("Didn't find any versions.")
|
||||
|
||||
# get local frozen version and add it to detected version so if it is
|
||||
# newer it will be used instead.
|
||||
if installed_version == openpype_version:
|
||||
version_path = _bootstrap_from_code(use_version, use_staging)
|
||||
version_path = _bootstrap_from_code(use_version)
|
||||
openpype_version = OpenPypeVersion(
|
||||
version=BootstrapRepos.get_version(version_path),
|
||||
path=version_path)
|
||||
|
|
@ -805,8 +793,8 @@ def _find_frozen_openpype(use_version: str = None,
|
|||
return openpype_version.path
|
||||
|
||||
|
||||
def _bootstrap_from_code(use_version, use_staging):
|
||||
"""Bootstrap live code (or the one coming with frozen OpenPype.
|
||||
def _bootstrap_from_code(use_version):
|
||||
"""Bootstrap live code (or the one coming with frozen OpenPype).
|
||||
|
||||
Args:
|
||||
use_version: (str): specific version to use.
|
||||
|
|
@ -829,33 +817,25 @@ def _bootstrap_from_code(use_version, use_staging):
|
|||
local_version = bootstrap.get_version(Path(_openpype_root))
|
||||
switch_str = f" - will switch to {use_version}" if use_version and use_version != local_version else "" # noqa
|
||||
_print(f" - booting version: {local_version}{switch_str}")
|
||||
assert local_version
|
||||
if not local_version:
|
||||
raise OpenPypeVersionNotFound(
|
||||
f"Cannot find version at {_openpype_root}")
|
||||
else:
|
||||
# get current version of OpenPype
|
||||
local_version = OpenPypeVersion.get_installed_version_str()
|
||||
|
||||
# All cases when should be used different version than build
|
||||
if (use_version and use_version != local_version) or use_staging:
|
||||
if use_version and use_version != local_version:
|
||||
if use_version:
|
||||
# Explicit version should be used
|
||||
version_to_use = bootstrap.find_openpype_version(
|
||||
use_version, use_staging
|
||||
)
|
||||
version_to_use = bootstrap.find_openpype_version(use_version)
|
||||
if version_to_use is None:
|
||||
raise OpenPypeVersionIncompatible(
|
||||
f"Requested version \"{use_version}\" was not found.")
|
||||
else:
|
||||
# Staging version should be used
|
||||
version_to_use = bootstrap.find_latest_openpype_version(
|
||||
use_staging
|
||||
)
|
||||
version_to_use = bootstrap.find_latest_openpype_version()
|
||||
if version_to_use is None:
|
||||
if use_staging:
|
||||
reason = "Didn't find any staging versions."
|
||||
else:
|
||||
# This reason is backup for possible bug in code
|
||||
reason = "Didn't find any versions."
|
||||
raise OpenPypeVersionNotFound(reason)
|
||||
raise OpenPypeVersionNotFound("Didn't find any versions.")
|
||||
|
||||
# Start extraction of version if needed
|
||||
if version_to_use.path.is_file():
|
||||
|
|
@ -913,10 +893,7 @@ def _bootstrap_from_code(use_version, use_staging):
|
|||
|
||||
def _boot_validate_versions(use_version, local_version):
|
||||
_print(f">>> Validating version [ {use_version} ]")
|
||||
openpype_versions = bootstrap.find_openpype(include_zips=True,
|
||||
staging=True)
|
||||
openpype_versions += bootstrap.find_openpype(include_zips=True,
|
||||
staging=False)
|
||||
openpype_versions = bootstrap.find_openpype(include_zips=True)
|
||||
v: OpenPypeVersion
|
||||
found = [v for v in openpype_versions if str(v) == use_version]
|
||||
if not found:
|
||||
|
|
@ -932,14 +909,7 @@ def _boot_validate_versions(use_version, local_version):
|
|||
_print(f'{">>> " if valid else "!!! "}{message}')
|
||||
|
||||
|
||||
def _boot_print_versions(use_staging, local_version, openpype_root):
|
||||
if not use_staging:
|
||||
_print("--- This will list only non-staging versions detected.")
|
||||
_print(" To see staging versions, use --use-staging argument.")
|
||||
else:
|
||||
_print("--- This will list only staging versions detected.")
|
||||
_print(" To see other version, omit --use-staging argument.")
|
||||
|
||||
def _boot_print_versions(openpype_root):
|
||||
if getattr(sys, 'frozen', False):
|
||||
local_version = bootstrap.get_version(Path(openpype_root))
|
||||
else:
|
||||
|
|
@ -947,16 +917,12 @@ def _boot_print_versions(use_staging, local_version, openpype_root):
|
|||
|
||||
compatible_with = OpenPypeVersion(version=local_version)
|
||||
if "--all" in sys.argv:
|
||||
compatible_with = None
|
||||
_print("--- Showing all version (even those not compatible).")
|
||||
else:
|
||||
_print(("--- Showing only compatible versions "
|
||||
f"with [ {compatible_with.major}.{compatible_with.minor} ]"))
|
||||
|
||||
openpype_versions = bootstrap.find_openpype(
|
||||
include_zips=True,
|
||||
staging=use_staging,
|
||||
)
|
||||
openpype_versions = bootstrap.find_openpype(include_zips=True)
|
||||
openpype_versions = [
|
||||
version for version in openpype_versions
|
||||
if version.is_compatible(
|
||||
|
|
@ -966,12 +932,11 @@ def _boot_print_versions(use_staging, local_version, openpype_root):
|
|||
list_versions(openpype_versions, local_version)
|
||||
|
||||
|
||||
def _boot_handle_missing_version(local_version, use_staging, message):
|
||||
def _boot_handle_missing_version(local_version, message):
|
||||
_print(message)
|
||||
if os.environ.get("OPENPYPE_HEADLESS_MODE") == "1":
|
||||
openpype_versions = bootstrap.find_openpype(
|
||||
include_zips=True, staging=use_staging
|
||||
)
|
||||
include_zips=True)
|
||||
list_versions(openpype_versions, local_version)
|
||||
else:
|
||||
igniter.show_message_dialog("Version not found", message)
|
||||
|
|
@ -1005,7 +970,6 @@ def boot():
|
|||
"is overridden by command line argument."))
|
||||
else:
|
||||
_print(">>> version set by environment variable")
|
||||
use_staging = "staging" in os.getenv("OPENPYPE_VERSION")
|
||||
use_version = os.getenv("OPENPYPE_VERSION")
|
||||
|
||||
# ------------------------------------------------------------------------
|
||||
|
|
@ -1059,7 +1023,7 @@ def boot():
|
|||
os.environ["OPENPYPE_PATH"] = openpype_path
|
||||
|
||||
if "print_versions" in commands:
|
||||
_boot_print_versions(use_staging, local_version, OPENPYPE_ROOT)
|
||||
_boot_print_versions(OPENPYPE_ROOT)
|
||||
sys.exit(1)
|
||||
|
||||
# ------------------------------------------------------------------------
|
||||
|
|
@ -1072,7 +1036,7 @@ def boot():
|
|||
try:
|
||||
version_path = _find_frozen_openpype(use_version, use_staging)
|
||||
except OpenPypeVersionNotFound as exc:
|
||||
_boot_handle_missing_version(local_version, use_staging, str(exc))
|
||||
_boot_handle_missing_version(local_version, str(exc))
|
||||
sys.exit(1)
|
||||
|
||||
except RuntimeError as e:
|
||||
|
|
@ -1088,10 +1052,10 @@ def boot():
|
|||
_print("--- version is valid")
|
||||
else:
|
||||
try:
|
||||
version_path = _bootstrap_from_code(use_version, use_staging)
|
||||
version_path = _bootstrap_from_code(use_version)
|
||||
|
||||
except OpenPypeVersionNotFound as exc:
|
||||
_boot_handle_missing_version(local_version, use_staging, str(exc))
|
||||
_boot_handle_missing_version(local_version, str(exc))
|
||||
sys.exit(1)
|
||||
|
||||
# set this to point either to `python` from venv in case of live code
|
||||
|
|
@ -1172,10 +1136,10 @@ def get_info(use_staging=None) -> list:
|
|||
inf.append(("OpenPype variant", "staging"))
|
||||
else:
|
||||
inf.append(("OpenPype variant", "production"))
|
||||
inf.append(
|
||||
("Running OpenPype from", os.environ.get('OPENPYPE_REPOS_ROOT'))
|
||||
inf.extend([
|
||||
("Running OpenPype from", os.environ.get('OPENPYPE_REPOS_ROOT')),
|
||||
("Using mongodb", components["host"])]
|
||||
)
|
||||
inf.append(("Using mongodb", components["host"]))
|
||||
|
||||
if os.environ.get("FTRACK_SERVER"):
|
||||
inf.append(("Using FTrack at",
|
||||
|
|
@ -1194,11 +1158,13 @@ def get_info(use_staging=None) -> list:
|
|||
|
||||
mongo_components = get_default_components()
|
||||
if mongo_components["host"]:
|
||||
inf.append(("Logging to MongoDB", mongo_components["host"]))
|
||||
inf.append((" - port", mongo_components["port"] or "<N/A>"))
|
||||
inf.append((" - database", Logger.log_database_name))
|
||||
inf.append((" - collection", Logger.log_collection_name))
|
||||
inf.append((" - user", mongo_components["username"] or "<N/A>"))
|
||||
inf.extend([
|
||||
("Logging to MongoDB", mongo_components["host"]),
|
||||
(" - port", mongo_components["port"] or "<N/A>"),
|
||||
(" - database", Logger.log_database_name),
|
||||
(" - collection", Logger.log_collection_name),
|
||||
(" - user", mongo_components["username"] or "<N/A>")
|
||||
])
|
||||
if mongo_components["auth_db"]:
|
||||
inf.append((" - auth source", mongo_components["auth_db"]))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue