Skip to content

Commit

Permalink
vine factory:always use manager.name as fallback when no host:port is…
Browse files Browse the repository at this point in the history
… available (#4001)

* vine factory:always use manager.name as fallback when no host:port is available

* lint

* do not allow changing batch-type, manager-name after initial configuration
  • Loading branch information
btovar authored Dec 9, 2024
1 parent ff9fff5 commit baaf877
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions taskvine/src/bindings/python3/ndcctools/taskvine/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -1851,6 +1851,12 @@ class Factory(object):
"condor-requirements",
]

# subset of command line options that need special handling once the factory object has been created.
_config_init_options = [
"batch-type",
"manager-name",
]

##
# Create a factory for the given batch_type and manager name.
#
Expand Down Expand Up @@ -1880,20 +1886,19 @@ def __init__(self, batch_type="local", manager=None, manager_host_port=None, man
pathlib.Path.mkdir(pathlib.Path(self._opts["scratch-dir"]), exist_ok=True, parents=True)

def _set_manager(self, batch_type, manager, manager_host_port, manager_name):
if not (manager or manager_host_port or manager_name):
raise ValueError("Either manager, manager_host_port, or manager_name or manager should be specified.")

if manager_name:
self._opts["manager-name"] = manager_name

if manager:
if manager.using_ssl:
self._opts["ssl"] = True
if batch_type == "local":
manager_host_port = f"localhost:{manager.port}"
elif manager.name:
self._opts["manager-name"] = manager_name

if manager.using_ssl:
self._opts["ssl"] = True
if manager_name:
if manager.name != manager_name:
RuntimeError(
"The manager and Factory were assigned different names ({manager.name}, {manager_name})"
)
else:
manager_name = manager.name

if manager_host_port:
try:
Expand All @@ -1903,6 +1908,10 @@ def _set_manager(self, batch_type, manager, manager_host_port, manager_name):
return
except (TypeError, ValueError):
raise ValueError("manager_host_port is not of the form HOST:PORT")
elif manager_name:
self._opts["manager-name"] = manager_name
else:
raise ValueError("Either manager, manager_host_port, or manager_name or manager should be specified.")

def _find_exe(self, path, default):
if path is None:
Expand Down Expand Up @@ -1953,6 +1962,9 @@ def __setattr__(self, name, value):
else:
raise AttributeError("{} is not a supported option".format(name))
else:
if name_with_hyphens in Factory._config_init_options:
raise AttributeError("{} cannot be changed after the factory initial configuration.".format(name))

if name_with_hyphens in Factory._command_line_options:
self._opts[name_with_hyphens] = value
else:
Expand Down

0 comments on commit baaf877

Please sign in to comment.