Skip to content

radical.asyncflow.task

Task

Task(**kwargs)

Bases: TaskDescription

Task description container extending radical.pilot TaskDescription. A specialized task description class that inherits from radical.pilot's TaskDescription to define and manage task configurations. Args: **kwargs: Configuration parameters for the task. All arguments are passed directly to the parent TaskDescription class. Attributes: Inherits all attributes from radical.pilot.TaskDescription. Example: >>> task = Task(executable='/bin/date', ... cpu_processes=1, ... gpu_processes=0) Note: This class uses dictionary-based initialization through the parent class's from_dict parameter to maintain compatibility with radical.pilot's configuration system.

Source code in doc_env/lib/python3.13/site-packages/radical/asyncflow/task.py
23
24
25
26
def __init__(self, **kwargs):
    # we pass only the kwargs as dict to the rp.TaskDescription
    # as it only allows from_dict
    super().__init__(from_dict=kwargs)

update

update(other)

Overload dict.update(): the call is used to ensure that sub-dicts are instantiated as their respective TypedDict-inheriting class types, if so specified by the respective schema.

So, if the schema contains::

{ ... 'foo' : BarTypedDict 'foos': [BarTypedDict] ... }

where BarTypedDict is a valid type in the scope of the schema definition, which inherits from ru.TypedDict, then update() will ensure that the value for key foo is indeed of type ru.TypedDict. An error will be raised if (a) BarTypedDict does not have a single parameter constructor like ru.TypedDict, or (b) the data value for foo cannot be used as from_dict parameter to the BarTypedDict constructor.

Source code in doc_env/lib/python3.13/site-packages/radical/utils/typeddict.py
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
def update(self, other):
    '''
    Overload `dict.update()`: the call is used to ensure that sub-dicts are
    instantiated as their respective TypedDict-inheriting class types,
    if so specified by the respective schema.

    So, if the schema contains::

      {
        ...
        'foo' : BarTypedDict
        'foos': [BarTypedDict]
        ...
      }

    where `BarTypedDict` is a valid type in the scope of the schema
    definition, which inherits from `ru.TypedDict`, then `update()` will
    ensure that the value for key `foo` is indeed of type `ru.TypedDict`.
    An error will be raised if (a) `BarTypedDict` does not have a single
    parameter constructor like `ru.TypedDict`, or (b) the `data` value for
    `foo` cannot be used as `from_dict` parameter to the `BarTypedDict`
    constructor.
    '''
    if not other:
        return

    for k, v in other.items():
        if isinstance(v, dict):
            t = self._schema.get(k) or \
                (type(self) if self._self_default else TypedDict)
            if isinstance(t, type) and issubclass(t, TypedDict):
                # cast to expected TypedDict type
                if not self.get(k):
                    self[k] = t()
                self[k].update(v)
                continue
        self[k] = v

__deepcopy__

__deepcopy__(memo)

return a new instance of the same type, not an original TypedDict, otherwise if an instance of TypedDict-based has an attribute of other TypedDict-based type then verify method will raise an exception

Source code in doc_env/lib/python3.13/site-packages/radical/utils/typeddict.py
214
215
216
217
218
219
220
def __deepcopy__(self, memo):
    '''
    return a new instance of the same type, not an original TypedDict,
    otherwise if an instance of TypedDict-based has an attribute of other
    TypedDict-based type then `verify` method will raise an exception
    '''
    return type(self)(from_dict=copy.deepcopy(self._data))