def make_executor_params( *, max_executors=0, capacity=0, name_prefix='', daemon=None, default_priority=None, parse_priority=None, ): # default_priority, when provided, is usually a domain object; so # caller should also provide a parse function. ASSERT.not_xor(default_priority is None, parse_priority is None) return parameters.Namespace( 'make executor', max_executors=parameters.Parameter(max_executors, type=int), capacity=parameters.Parameter(capacity, type=int), name_prefix=parameters.Parameter(name_prefix, type=str), daemon=parameters.Parameter(daemon, type=(bool, type(None))), default_priority=( parameters.ConstParameter(None) if default_priority is None else \ parameters.Parameter( default_priority, convert=parse_priority, format=str ) ), )
def __post_init__(self): ASSERT.only_one((self.id, self.name or self.version, self.tag)) ASSERT.not_xor(self.name, self.version) if self.id: validate_image_id(self.id) elif self.name: validate_image_name(self.name) validate_image_version(self.version) else: validate_image_tag(self.tag)
def _find_image_dir_path(image_id, name, version, tag): """Return path to image directory or None if not found.""" ASSERT.only_one((image_id, name or version, tag)) ASSERT.not_xor(name, version) if name: # We check duplicated image name and version when images are # imported, and so we do not check it again here. for image_dir_path in _iter_image_dir_paths(): metadata = read_metadata(image_dir_path) if metadata.name == name and metadata.version == version: return image_dir_path return None if image_id: image_dir_path = get_image_dir_path(image_id) else: tag_path = _get_tag_path(tag) if not g1.files.lexists(tag_path): return None image_dir_path = _get_image_dir_path_from_tag(tag_path) return image_dir_path if image_dir_path.is_dir() else None
def __post_init__(self): validate_xar_label(self.label) validate_xar_version(self.version) ASSERT.not_xor(self.exec_relpath is None, self.image is None) if self.exec_relpath is not None: ASSERT.not_predicate(Path(self.exec_relpath), Path.is_absolute)