@@ -1851,6 +1851,12 @@ class Factory(object):
18511851 "condor-requirements" ,
18521852 ]
18531853
1854+ # subset of command line options that need special handling once the factory object has been created.
1855+ _config_init_options = [
1856+ "batch-type" ,
1857+ "manager-name" ,
1858+ ]
1859+
18541860 ##
18551861 # Create a factory for the given batch_type and manager name.
18561862 #
@@ -1880,20 +1886,19 @@ def __init__(self, batch_type="local", manager=None, manager_host_port=None, man
18801886 pathlib .Path .mkdir (pathlib .Path (self ._opts ["scratch-dir" ]), exist_ok = True , parents = True )
18811887
18821888 def _set_manager (self , batch_type , manager , manager_host_port , manager_name ):
1883- if not (manager or manager_host_port or manager_name ):
1884- raise ValueError ("Either manager, manager_host_port, or manager_name or manager should be specified." )
1885-
1886- if manager_name :
1887- self ._opts ["manager-name" ] = manager_name
1888-
18891889 if manager :
1890+ if manager .using_ssl :
1891+ self ._opts ["ssl" ] = True
18901892 if batch_type == "local" :
18911893 manager_host_port = f"localhost:{ manager .port } "
18921894 elif manager .name :
1893- self ._opts ["manager-name" ] = manager_name
1894-
1895- if manager .using_ssl :
1896- self ._opts ["ssl" ] = True
1895+ if manager_name :
1896+ if manager .name != manager_name :
1897+ RuntimeError (
1898+ "The manager and Factory were assigned different names ({manager.name}, {manager_name})"
1899+ )
1900+ else :
1901+ manager_name = manager .name
18971902
18981903 if manager_host_port :
18991904 try :
@@ -1903,6 +1908,10 @@ def _set_manager(self, batch_type, manager, manager_host_port, manager_name):
19031908 return
19041909 except (TypeError , ValueError ):
19051910 raise ValueError ("manager_host_port is not of the form HOST:PORT" )
1911+ elif manager_name :
1912+ self ._opts ["manager-name" ] = manager_name
1913+ else :
1914+ raise ValueError ("Either manager, manager_host_port, or manager_name or manager should be specified." )
19061915
19071916 def _find_exe (self , path , default ):
19081917 if path is None :
@@ -1953,6 +1962,9 @@ def __setattr__(self, name, value):
19531962 else :
19541963 raise AttributeError ("{} is not a supported option" .format (name ))
19551964 else :
1965+ if name_with_hyphens in Factory ._config_init_options :
1966+ raise AttributeError ("{} cannot be changed after the factory initial configuration." .format (name ))
1967+
19561968 if name_with_hyphens in Factory ._command_line_options :
19571969 self ._opts [name_with_hyphens ] = value
19581970 else :
0 commit comments