Skip to content
Snippets Groups Projects
Commit a8becd00 authored by Sybren A. Stüvel's avatar Sybren A. Stüvel
Browse files

Add --test CLI arg and override supported task types

parent 4608cf7d
Branches
Tags
No related merge requests found
...@@ -27,6 +27,10 @@ def main(): ...@@ -27,6 +27,10 @@ def main():
help="Enables debug logging for Flamenco Worker's own log entries. " help="Enables debug logging for Flamenco Worker's own log entries. "
"Edit the logging config in flamenco-worker.cfg " "Edit the logging config in flamenco-worker.cfg "
"for more powerful options.") "for more powerful options.")
parser.add_argument('-t', '--test', action='store_true',
help="Starts up in testing mode, in which only a handful of "
"test-specific task types are accepted. This overrides the task_types "
"in the configuration file.")
args = parser.parse_args() args = parser.parse_args()
if args.version: if args.version:
...@@ -36,12 +40,16 @@ def main(): ...@@ -36,12 +40,16 @@ def main():
# Load configuration # Load configuration
from . import config from . import config
confparser = config.load_config(args.config, args.verbose) confparser = config.load_config(args.config, args.verbose, args.test)
config.configure_logging(confparser, enable_debug=args.debug) config.configure_logging(confparser, enable_debug=args.debug)
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
log.debug('Starting, pid=%d', os.getpid()) log.debug('Starting, pid=%d', os.getpid())
if args.test:
log.warning('Test mode enabled, overriding task_types=%r',
confparser.value('task_types'))
if args.reregister: if args.reregister:
log.warning('Erasing worker_id and worker_secret so we can attempt re-registration.') log.warning('Erasing worker_id and worker_secret so we can attempt re-registration.')
confparser.erase('worker_id') confparser.erase('worker_id')
......
...@@ -28,6 +28,9 @@ DEFAULT_CONFIG = { ...@@ -28,6 +28,9 @@ DEFAULT_CONFIG = {
]) ])
} }
# Will be assigned to the config key 'task_types' when started with --test CLI arg.
TESTING_TASK_TYPES = 'test-blender-render'
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
...@@ -74,7 +77,8 @@ def merge_with_home_config(new_conf: dict): ...@@ -74,7 +77,8 @@ def merge_with_home_config(new_conf: dict):
def load_config(config_file: pathlib.Path = None, def load_config(config_file: pathlib.Path = None,
show_effective_config: bool = False) -> ConfigParser: show_effective_config: bool = False,
enable_test_mode=False) -> ConfigParser:
"""Loads one or more configuration files.""" """Loads one or more configuration files."""
# Logging and the default interpolation of configparser both use the # Logging and the default interpolation of configparser both use the
...@@ -102,6 +106,9 @@ def load_config(config_file: pathlib.Path = None, ...@@ -102,6 +106,9 @@ def load_config(config_file: pathlib.Path = None,
log.info('Succesfully loaded: %s', loaded) log.info('Succesfully loaded: %s', loaded)
if enable_test_mode:
confparser.setvalue('task_types', TESTING_TASK_TYPES)
if show_effective_config: if show_effective_config:
import sys import sys
log.info('Effective configuration:') log.info('Effective configuration:')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment