dcnum.meta.ppid
Attributes
The dcnum pipeline generation. |
Classes
Base class for protocol classes. |
|
Functions
|
|
|
Convert an object to the correct dtype |
|
Return dictionary of class info with static keyword methods docs |
|
|
|
Convert pipeline method id to method keyword arguments |
|
Return the type encoded by a string, e.g. "bool" -> bool |
|
Find unique prefix for a list of strings |
Module Contents
- dcnum.meta.ppid.DCNUM_PPID_GENERATION = '13'
The dcnum pipeline generation. Increment this string if there are breaking changes that make previous pipelines unreproducible.
- class dcnum.meta.ppid.ClassWithPPIDCapabilities[source]
Bases:
ProtocolBase class for protocol classes.
Protocol classes are defined as:
class Proto(Protocol): def meth(self) -> int: ...
Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing).
For example:
class C: def meth(self) -> int: return 0 def func(x: Proto) -> int: return x.meth() func(C()) # Passes static type check
See PEP 544 for details. Protocol classes decorated with @typing.runtime_checkable act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes can be generic, they are defined as:
class GenProto(Protocol[T]): def meth(self) -> T: ...
- dcnum.meta.ppid.compute_pipeline_hash(*, bg_id, seg_id, feat_id, gate_id, dat_id='unknown', gen_id=DCNUM_PPID_GENERATION)[source]
- dcnum.meta.ppid.convert_to_dtype(value, dtype)[source]
Convert an object to the correct dtype
If dtype is a Union of types, or a list of types, the first non-NoneType type is used for conversion.
- dcnum.meta.ppid.get_class_method_info(class_obj: ClassWithPPIDCapabilities, static_kw_methods: list | None = None, static_kw_defaults: dict | None = None) dict[str, Any][source]
Return dictionary of class info with static keyword methods docs
- Parameters:
class_obj (object) – Class to inspect, must implement the key method.
static_kw_methods (list of callable) – The methods to inspect; all kwargs-only keyword arguments are extracted.
static_kw_defaults (dict) – If a key in this dictionary matches an item in static_kw_methods, then these are the default values returned in the “defaults” dictionary. This is used in cases where a base class does implement some annotations, but the subclass does not actually use them, because e.g. they are taken from a property such as is the case for the mask postprocessing of segmenter classes.
- dcnum.meta.ppid.kwargs_to_ppid(cls: ClassWithPPIDCapabilities, method: str, kwargs: dict, allow_invalid_keys: bool = True)[source]
- dcnum.meta.ppid.ppid_to_kwargs(cls, method, ppid)[source]
Convert pipeline method id to method keyword arguments
Notes
Keep in mind that when a method is changed in a later version, new keyword arguments should always be put AT THE VERY END of the keyword list. Otherwise, might will be ambiguities regarding the abbreviated keys!
- dcnum.meta.ppid.simple_type_eval(type_string: str | type) str | type | list[source]
Return the type encoded by a string, e.g. “bool” -> bool
If type_string is already a type, it is passed through. If there is no rule to convert type_string to a type, type_string is returned as-is. If type_string represents a union of types (using ‘|’), then a list of types is returned.