diff --git a/openpype/cli.py b/openpype/cli.py index a7b1c67b75..9034583a7a 100644 --- a/openpype/cli.py +++ b/openpype/cli.py @@ -24,6 +24,8 @@ from .pype_commands import PypeCommands help=("Enable debug")) @click.option("--verbose", expose_value=False, help=("Change OpenPype log level (debug - critical or 0-50)")) +@click.option("--automatic-tests", is_flag=True, expose_value=False, + help=("Run in automatic tests mode")) def main(ctx): """Pype is main command serving as entry point to pipeline system. @@ -127,11 +129,7 @@ def webpublisherwebserver(executable, upload_dir, host=None, port=None): @click.option( "--envgroup", help="Environment group (e.g. \"farm\")", default=None ) -@click.option( - "--automatic_tests", help="Is this automatic test", default=None -) -def extractenvironments(output_json_path, project, asset, task, app, envgroup, - automatic_tests): +def extractenvironments(output_json_path, project, asset, task, app, envgroup): """Extract environment variables for entered context to a json file. Entered output filepath will be created if does not exists. @@ -152,10 +150,7 @@ def extractenvironments(output_json_path, project, asset, task, app, envgroup, multiple=True) @click.option("-g", "--gui", is_flag=True, help="Show Publish UI", default=False) -@click.option( - "--automatic_tests", help="Is this automatic test", default=None -) -def publish(paths, targets, gui, automatic_tests): +def publish(paths, targets, gui): """Start CLI publishing. Publish collects json from paths provided as an argument. diff --git a/openpype/modules/deadline/plugins/publish/submit_publish_job.py b/openpype/modules/deadline/plugins/publish/submit_publish_job.py index 32ad22f6b0..aabc4bf84c 100644 --- a/openpype/modules/deadline/plugins/publish/submit_publish_job.py +++ b/openpype/modules/deadline/plugins/publish/submit_publish_job.py @@ -267,7 +267,7 @@ class ProcessSubmittedJobOnFarm(pyblish.api.InstancePlugin): ] if os.environ.get("IS_TEST"): - args.extend(["--automatic_tests", "1"]) + args.append("--automatic-tests") # Generate the payload for Deadline submission payload = { diff --git a/openpype/modules/deadline/repository/custom/plugins/GlobalJobPreLoad.py b/openpype/modules/deadline/repository/custom/plugins/GlobalJobPreLoad.py index 84b435ccdd..c0c7ee4d54 100644 --- a/openpype/modules/deadline/repository/custom/plugins/GlobalJobPreLoad.py +++ b/openpype/modules/deadline/repository/custom/plugins/GlobalJobPreLoad.py @@ -181,7 +181,7 @@ def inject_openpype_environment(deadlinePlugin): add_args["envgroup"] = "farm" if job.GetJobEnvironmentKeyValue('IS_TEST'): - add_args["automatic_tests"] = "true" + args.append("--automatic-tests") if all(add_args.values()): for key, value in add_args.items(): diff --git a/start.py b/start.py index 5242a50f14..ec0465b0f5 100644 --- a/start.py +++ b/start.py @@ -242,6 +242,10 @@ if "--debug" in sys.argv: sys.argv.remove("--debug") os.environ["OPENPYPE_DEBUG"] = "1" +if "--automatic-tests" in sys.argv: + sys.argv.remove("--automatic-tests") + os.environ["IS_TEST"] = "1" + import igniter # noqa: E402 from igniter import BootstrapRepos # noqa: E402 @@ -486,7 +490,6 @@ def _process_arguments() -> tuple: use_version = None use_staging = False commands = [] - automatic_tests = False # OpenPype version specification through arguments use_version_arg = "--use-version" @@ -571,10 +574,7 @@ def _process_arguments() -> tuple: sys.argv.pop(idx) sys.argv.insert(idx, "tray") - if "--automatic_tests" in sys.argv: - automatic_tests = True - - return use_version, use_staging, commands, automatic_tests + return use_version, use_staging, commands def _determine_mongodb() -> str: @@ -1001,7 +1001,7 @@ def boot(): # Process arguments # ------------------------------------------------------------------------ - use_version, use_staging, commands, automatic_tests = _process_arguments() + use_version, use_staging, commands = _process_arguments() if os.getenv("OPENPYPE_VERSION"): if use_version: @@ -1028,9 +1028,8 @@ def boot(): os.environ["OPENPYPE_DATABASE_NAME"] = \ os.environ.get("OPENPYPE_DATABASE_NAME") or "openpype" - if automatic_tests: + if os.environ.get("IS_TEST") == "1": # change source DBs to predefined ones set for automatic testing - os.environ["IS_TEST"] = "1" os.environ["OPENPYPE_DATABASE_NAME"] += "_tests" avalon_db = os.environ.get("AVALON_DB") or "avalon" os.environ["AVALON_DB"] = avalon_db + "_tests"