|
@@ -8,6 +8,7 @@
|
|
|
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
|
|
|
# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
|
|
# specific language governing permissions and limitations under the License.
|
|
|
+
|
|
|
from copy import copy
|
|
|
from typing import Any, Dict, Optional, Union
|
|
|
|
|
@@ -35,6 +36,7 @@ class JobConfig(UniqueSection):
|
|
|
_STANDALONE_MODE = "standalone"
|
|
|
_DEVELOPMENT_MODE = "development"
|
|
|
_DEFAULT_MODE = _DEVELOPMENT_MODE
|
|
|
+ _DEFAULT_MAX_NB_OF_WORKERS = 2
|
|
|
_MODES = [_STANDALONE_MODE, _DEVELOPMENT_MODE]
|
|
|
|
|
|
def __init__(self, mode: Optional[str] = None, **properties):
|
|
@@ -87,7 +89,7 @@ class JobConfig(UniqueSection):
|
|
|
Possible values are: *"standalone"* (the default value) or *"development"*.
|
|
|
max_nb_of_workers (Optional[int, str]): Parameter used only in default *"standalone"* mode.
|
|
|
This indicates the maximum number of jobs able to run in parallel.<br/>
|
|
|
- The default value is 1.<br/>
|
|
|
+ The default value is 2.<br/>
|
|
|
A string can be provided to dynamically set the value using an environment
|
|
|
variable. The string must follow the pattern: `ENV[<env_var>]` where
|
|
|
`<env_var>` is the name of an environment variable.
|
|
@@ -117,14 +119,12 @@ class JobConfig(UniqueSection):
|
|
|
"""True if the config is set to development mode"""
|
|
|
return self.mode == self._DEVELOPMENT_MODE
|
|
|
|
|
|
- @classmethod
|
|
|
- def get_default_config(cls, mode: str) -> Dict[str, Any]:
|
|
|
- if cls.is_standalone: # type: ignore
|
|
|
- return {"max_nb_of_workers": 1}
|
|
|
- if cls.is_development:
|
|
|
+ def get_default_config(self, mode: str) -> Dict[str, Any]:
|
|
|
+ if self.is_standalone:
|
|
|
+ return {"max_nb_of_workers": self._DEFAULT_MAX_NB_OF_WORKERS}
|
|
|
+ if self.is_development:
|
|
|
return {}
|
|
|
raise ModeNotAvailable(mode)
|
|
|
|
|
|
- @classmethod
|
|
|
- def _create_config(cls, mode, **properties):
|
|
|
- return {**cls.get_default_config(mode), **properties}
|
|
|
+ def _create_config(self, mode, **properties):
|
|
|
+ return {**self.get_default_config(mode), **properties}
|