Version:

salvus.opt.tasks

salvus.opt.tasks salvus opt tasks
Collection of task objects to handle asynchronous inversions.

Functions

read_task_from_json()

Utility to deserialize a task. This requires to detect the correct class name from the JSON dictionary to instantiate the task.
SIGNATURE
def read_task_from_json(d: dict) -> Task: ...
ARGUMENTS
Required
d
Type:dict
Description:
JSON dictionary of the task.
RETURNS
Return type: Task
Task object.

validate_keys()

Utility function to validate a set of keys.
SIGNATURE
def validate_keys(
    required: set, obtained: set, key: str, partial_update: bool = False
) -> None: ...
ARGUMENTS
Required
required
Type:set
Description:
Set of required items.
Required
obtained
Type:set
Description:
Set of obtained items.
Required
key
Type:str
Description:
Description of the set (just for printing nicer errors).
Optional
partial_update
Type:bool
Default value:False
Description:
Allow partial update that does not necessarily contain all required keys.

Classes

Task

Base class to create tasks during an inversion.
SIGNATURE
class Task(salvus.flow.utils.serialization_helpers.SerializationMixin):
    def __init__(self): ...

Properties

  • name(str)-Task name.

Class Methods

Task.from_json()
Construct object from a JSON-serializable dictionary.
SIGNATURE
def from_json(d: dict) -> typing.Self: ...
ARGUMENTS
Required
d
Type:dict
Description:
JSON dictionary of the task.

Methods

Task.to_json()
Serialize the object to dictionary that can be written to JSON.
SIGNATURE
def to_json(
    self,
    external_file_hash: str | None = None,
    timer: Timer | None = None,
    log_to_logger: bool = False,
    comm: int | None = None,
) -> dict: ...
ARGUMENTS
Optional
external_file_hash
Type:str | None
Default value:None
Description:
Hash of any external files associated with this object. Can be passed here in which case it will be stored in a centralized location in the JSON file.
Optional
timer
Type:Timer | None
Default value:None
Description:
Execution timer.
Optional
log_to_logger
Type:bool
Default value:False
Description:
Log timings to the logger.
Optional
comm
Type:int | None
Default value:None
Description:
MPI communicator, if any.
Task.update_status()
Update task status.
SIGNATURE
def update_status(self, status: _valid_status) -> None: ...
ARGUMENTS
Required
status
Type:_valid_status
Description:
New status.
Task.validate()
Validate status of the tasks.
SIGNATURE
def validate(self, success: bool = False) -> None: ...
ARGUMENTS
Optional
success
Type:bool
Default value:False
Description:
Raise if task has not been completed (status="done").

TaskCustom

Custom task. All required information needs to be passed as dictionary that can be serialized to JSON.
SIGNATURE
class TaskCustom(salvus.opt.tasks.Task):
    def __init__(
        self, info: dict[str, int | str | float | SerializationMixin]
    ): ...
ARGUMENTS
Required
info
Type:dict[str, int | str | float | SerializationMixin]
Description:
Custom task specification.

Properties

  • name(str)-Task name.

Class Methods

TaskCustom.from_json()
Construct object from a JSON-serializable dictionary.
SIGNATURE
def from_json(d: dict) -> TaskCustom: ...
ARGUMENTS
Required
d
Type:dict
Description:
JSON dictionary of the task.

Methods

TaskCustom.to_json()
Serialize the object to dictionary that can be written to JSON.
SIGNATURE
def to_json(
    self,
    external_file_hash: str | None = None,
    timer: Timer | None = None,
    log_to_logger: bool = False,
    comm: int | None = None,
) -> dict: ...
ARGUMENTS
Optional
external_file_hash
Type:str | None
Default value:None
Description:
Hash of any external files associated with this object. Can be passed here in which case it will be stored in a centralized location in the JSON file.
Optional
timer
Type:Timer | None
Default value:None
Description:
Execution timer.
Optional
log_to_logger
Type:bool
Default value:False
Description:
Log timings to the logger.
Optional
comm
Type:int | None
Default value:None
Description:
MPI communicator, if any.
TaskCustom.update_results()
Update the results of the tasks.
SIGNATURE
def update_results(
    self, result: dict[str, int | str | float | SerializationMixin]
) -> None: ...
ARGUMENTS
Required
result
Type:dict[str, int | str | float | SerializationMixin]
Description:
Task results.
TaskCustom.update_status()
Update task status.
SIGNATURE
def update_status(self, status: _valid_status) -> None: ...
ARGUMENTS
Required
status
Type:_valid_status
Description:
New status.
TaskCustom.validate()
Validate status of the tasks.
SIGNATURE
def validate(self, success: bool = False) -> None: ...
ARGUMENTS
Optional
success
Type:bool
Default value:False
Description:
Raise if task has not been completed (status="done").

TaskEventSelection

Task to select a subgroup of events as control group.
SIGNATURE
class TaskEventSelection(salvus.opt.tasks.Task):
    def __init__(
        self, events: list[str], required_events: list[str] | None = None
    ): ...
ARGUMENTS
Required
events
Type:list[str]
Description:
List of events to choose from.
Optional
required_events
Type:list[str] | None
Default value:None
Description:
List of required events.

Properties

  • name(str)-Task name.

Class Methods

TaskEventSelection.from_json()
Construct object from a JSON-serializable dictionary.
SIGNATURE
def from_json(d: dict) -> TaskEventSelection: ...
ARGUMENTS
Required
d
Type:dict
Description:
JSON dictionary of the task.

Methods

TaskEventSelection.to_json()
Serialize the object to dictionary that can be written to JSON.
SIGNATURE
def to_json(
    self,
    external_file_hash: str | None = None,
    timer: Timer | None = None,
    log_to_logger: bool = False,
    comm: int | None = None,
) -> dict: ...
ARGUMENTS
Optional
external_file_hash
Type:str | None
Default value:None
Description:
Hash of any external files associated with this object. Can be passed here in which case it will be stored in a centralized location in the JSON file.
Optional
timer
Type:Timer | None
Default value:None
Description:
Execution timer.
Optional
log_to_logger
Type:bool
Default value:False
Description:
Log timings to the logger.
Optional
comm
Type:int | None
Default value:None
Description:
MPI communicator, if any.
TaskEventSelection.update_results()
Update the results of the tasks.
SIGNATURE
def update_results(self, selection: list[bool]) -> None: ...
ARGUMENTS
Required
selection
Type:list[bool]
Description:
Boolean list selecting / deselecting events.
TaskEventSelection.update_status()
Update task status.
SIGNATURE
def update_status(self, status: _valid_status) -> None: ...
ARGUMENTS
Required
status
Type:_valid_status
Description:
New status.
TaskEventSelection.validate()
Validate status of the tasks.
SIGNATURE
def validate(self, success: bool = False) -> None: ...
ARGUMENTS
Optional
success
Type:bool
Default value:False
Description:
Raise if task has not been completed (status="done").

TaskFinalizeIteration

Custom task to finalize iteration.
SIGNATURE
class TaskFinalizeIteration(salvus.opt.tasks.Task):
    def __init__(
        self,
        info: dict[str, int | str | float | SerializationMixin] | None = None,
    ): ...
ARGUMENTS
Optional
info
Type:dict[str, int | str | float | SerializationMixin] | None
Default value:None
Description:
Custom task specification.

Properties

  • name(str)-Task name.

Class Methods

TaskFinalizeIteration.from_json()
Construct object from a JSON-serializable dictionary.
SIGNATURE
def from_json(d: dict) -> TaskFinalizeIteration: ...
ARGUMENTS
Required
d
Type:dict
Description:
JSON dictionary of the task.

Methods

TaskFinalizeIteration.to_json()
Serialize the object to dictionary that can be written to JSON.
SIGNATURE
def to_json(
    self,
    external_file_hash: str | None = None,
    timer: Timer | None = None,
    log_to_logger: bool = False,
    comm: int | None = None,
) -> dict: ...
ARGUMENTS
Optional
external_file_hash
Type:str | None
Default value:None
Description:
Hash of any external files associated with this object. Can be passed here in which case it will be stored in a centralized location in the JSON file.
Optional
timer
Type:Timer | None
Default value:None
Description:
Execution timer.
Optional
log_to_logger
Type:bool
Default value:False
Description:
Log timings to the logger.
Optional
comm
Type:int | None
Default value:None
Description:
MPI communicator, if any.
TaskFinalizeIteration.update_results()
Update the status of the tasks.
SIGNATURE
def update_results(self) -> None: ...
TaskFinalizeIteration.update_status()
Update task status.
SIGNATURE
def update_status(self, status: _valid_status) -> None: ...
ARGUMENTS
Required
status
Type:_valid_status
Description:
New status.
TaskFinalizeIteration.validate()
Validate status of the tasks.
SIGNATURE
def validate(self, success: bool = False) -> None: ...
ARGUMENTS
Optional
success
Type:bool
Default value:False
Description:
Raise if task has not been completed (status="done").

TaskGradients

Task to compute gradients for a given model and list of events.
SIGNATURE
class TaskGradients(salvus.opt.tasks.Task):
    def __init__(self, model: str, events: list[str]): ...
ARGUMENTS
Required
model
Type:str
Description:
Model
Required
events
Type:list[str]
Description:
List of events.

Properties

  • name(str)-Task name.

Class Methods

TaskGradients.from_json()
Construct object from a JSON-serializable dictionary.
SIGNATURE
def from_json(d: dict) -> TaskGradients: ...
ARGUMENTS
Required
d
Type:dict
Description:
JSON dictionary of the task.

Methods

TaskGradients.to_json()
Serialize the object to dictionary that can be written to JSON.
SIGNATURE
def to_json(
    self,
    external_file_hash: str | None = None,
    timer: Timer | None = None,
    log_to_logger: bool = False,
    comm: int | None = None,
) -> dict: ...
ARGUMENTS
Optional
external_file_hash
Type:str | None
Default value:None
Description:
Hash of any external files associated with this object. Can be passed here in which case it will be stored in a centralized location in the JSON file.
Optional
timer
Type:Timer | None
Default value:None
Description:
Execution timer.
Optional
log_to_logger
Type:bool
Default value:False
Description:
Log timings to the logger.
Optional
comm
Type:int | None
Default value:None
Description:
MPI communicator, if any.
TaskGradients.update_results()
Update the results of the tasks.
SIGNATURE
def update_results(
    self, gradients: dict[str, typing.Any], partial_update: bool = False
) -> None: ...
ARGUMENTS
Required
gradients
Type:dict[str, typing.Any]
Description:
Dictionary with event-specific gradients.
Optional
partial_update
Type:bool
Default value:False
Description:
Allow partial updates for a subset of data.
TaskGradients.update_status()
Update task status.
SIGNATURE
def update_status(self, status: _valid_status) -> None: ...
ARGUMENTS
Required
status
Type:_valid_status
Description:
New status.
TaskGradients.validate()
Validate status of the tasks.
SIGNATURE
def validate(self, success: bool = False) -> None: ...
ARGUMENTS
Optional
success
Type:bool
Default value:False
Description:
Raise if task has not been completed (status="done").

TaskMisfits

Task to compute misfits for a given model and list of events.
SIGNATURE
class TaskMisfits(salvus.opt.tasks.Task):
    def __init__(self, model: str, events: list[str]): ...
ARGUMENTS
Required
model
Type:str
Description:
Model
Required
events
Type:list[str]
Description:
List of events.

Properties

  • name(str)-Task name.

Class Methods

TaskMisfits.from_json()
Construct object from a JSON-serializable dictionary.
SIGNATURE
def from_json(d: dict) -> TaskMisfits: ...
ARGUMENTS
Required
d
Type:dict
Description:
JSON dictionary of the task.

Methods

TaskMisfits.to_json()
Serialize the object to dictionary that can be written to JSON.
SIGNATURE
def to_json(
    self,
    external_file_hash: str | None = None,
    timer: Timer | None = None,
    log_to_logger: bool = False,
    comm: int | None = None,
) -> dict: ...
ARGUMENTS
Optional
external_file_hash
Type:str | None
Default value:None
Description:
Hash of any external files associated with this object. Can be passed here in which case it will be stored in a centralized location in the JSON file.
Optional
timer
Type:Timer | None
Default value:None
Description:
Execution timer.
Optional
log_to_logger
Type:bool
Default value:False
Description:
Log timings to the logger.
Optional
comm
Type:int | None
Default value:None
Description:
MPI communicator, if any.
TaskMisfits.update_results()
Update the results of the tasks.
SIGNATURE
def update_results(
    self, misfits: dict[str, float], partial_update: bool = False
) -> None: ...
ARGUMENTS
Required
misfits
Type:dict[str, float]
Description:
Dictionary with event-specific misfits.
Optional
partial_update
Type:bool
Default value:False
Description:
Allow partial updates for a subset of data.
TaskMisfits.update_status()
Update task status.
SIGNATURE
def update_status(self, status: _valid_status) -> None: ...
ARGUMENTS
Required
status
Type:_valid_status
Description:
New status.
TaskMisfits.validate()
Validate status of the tasks.
SIGNATURE
def validate(self, success: bool = False) -> None: ...
ARGUMENTS
Optional
success
Type:bool
Default value:False
Description:
Raise if task has not been completed (status="done").

TaskMisfitsAndGradients

Task to compute misfits and gradients for a given model and list of events.
SIGNATURE
class TaskMisfitsAndGradients(salvus.opt.tasks.Task):
    def __init__(self, model: str, events: list[str]): ...
ARGUMENTS
Required
model
Type:str
Description:
Model
Required
events
Type:list[str]
Description:
List of events.

Properties

  • name(str)-Task name.

Class Methods

TaskMisfitsAndGradients.from_json()
Construct object from a JSON-serializable dictionary.
SIGNATURE
def from_json(d: dict) -> TaskMisfitsAndGradients: ...
ARGUMENTS
Required
d
Type:dict
Description:
JSON dictionary of the task.

Methods

TaskMisfitsAndGradients.to_json()
Serialize the object to dictionary that can be written to JSON.
SIGNATURE
def to_json(
    self,
    external_file_hash: str | None = None,
    timer: Timer | None = None,
    log_to_logger: bool = False,
    comm: int | None = None,
) -> dict: ...
ARGUMENTS
Optional
external_file_hash
Type:str | None
Default value:None
Description:
Hash of any external files associated with this object. Can be passed here in which case it will be stored in a centralized location in the JSON file.
Optional
timer
Type:Timer | None
Default value:None
Description:
Execution timer.
Optional
log_to_logger
Type:bool
Default value:False
Description:
Log timings to the logger.
Optional
comm
Type:int | None
Default value:None
Description:
MPI communicator, if any.
TaskMisfitsAndGradients.update_results()
Update the results of the tasks.
SIGNATURE
def update_results(
    self, misfits: dict[str, float], gradients: dict[str, typing.Any]
) -> None: ...
ARGUMENTS
Required
misfits
Type:dict[str, float]
Description:
Dictionary with event-specific misfits.
Required
gradients
Type:dict[str, typing.Any]
Description:
Dictionary with event-specific gradients.
TaskMisfitsAndGradients.update_status()
Update task status.
SIGNATURE
def update_status(self, status: _valid_status) -> None: ...
ARGUMENTS
Required
status
Type:_valid_status
Description:
New status.
TaskMisfitsAndGradients.validate()
Validate status of the tasks.
SIGNATURE
def validate(self, success: bool = False) -> None: ...
ARGUMENTS
Optional
success
Type:bool
Default value:False
Description:
Raise if task has not been completed (status="done").

TaskMisfitsAndSummedGradient

Task to compute misfits and gradients for a given model and list of events and return the summed gradient.
SIGNATURE
class TaskMisfitsAndSummedGradient(salvus.opt.tasks.Task, typing.Generic):
    def __init__(self, model: str, events: list[str]): ...
ARGUMENTS
Required
model
Type:str
Description:
Model
Required
events
Type:list[str]
Description:
List of events.

Properties

  • name(str)-Task name.

Class Methods

TaskMisfitsAndSummedGradient.from_json()
Construct object from a JSON-serializable dictionary.
SIGNATURE
def from_json(d: dict) -> TaskMisfitsAndSummedGradient: ...
ARGUMENTS
Required
d
Type:dict
Description:
JSON dictionary of the task.

Methods

TaskMisfitsAndSummedGradient.to_json()
Serialize the object to dictionary that can be written to JSON.
SIGNATURE
def to_json(
    self,
    external_file_hash: str | None = None,
    timer: Timer | None = None,
    log_to_logger: bool = False,
    comm: int | None = None,
) -> dict: ...
ARGUMENTS
Optional
external_file_hash
Type:str | None
Default value:None
Description:
Hash of any external files associated with this object. Can be passed here in which case it will be stored in a centralized location in the JSON file.
Optional
timer
Type:Timer | None
Default value:None
Description:
Execution timer.
Optional
log_to_logger
Type:bool
Default value:False
Description:
Log timings to the logger.
Optional
comm
Type:int | None
Default value:None
Description:
MPI communicator, if any.
TaskMisfitsAndSummedGradient.update_results()
Update the results of the tasks.
SIGNATURE
def update_results(
    self,
    misfits: dict[str, float],
    gradient: dict[str, typing.Any] | ModelType,
) -> None: ...
ARGUMENTS
Required
misfits
Type:dict[str, float]
Description:
Dictionary with event-specific misfits.
Required
gradient
Type:dict[str, typing.Any] | ModelType
Description:
Summed gradient.
TaskMisfitsAndSummedGradient.update_status()
Update task status.
SIGNATURE
def update_status(self, status: _valid_status) -> None: ...
ARGUMENTS
Required
status
Type:_valid_status
Description:
New status.
TaskMisfitsAndSummedGradient.validate()
Validate status of the tasks.
SIGNATURE
def validate(self, success: bool = False) -> None: ...
ARGUMENTS
Optional
success
Type:bool
Default value:False
Description:
Raise if task has not been completed (status="done").

TaskPreconditioner

Task to apply a preconditioner to a given model.
SIGNATURE
class TaskPreconditioner(salvus.opt.tasks.Task, typing.Generic):
    def __init__(self, model: str | ModelType): ...
ARGUMENTS
Required
model
Type:str | ModelType
Description:
Model to apply the preconditioner to.

Properties

  • name(str)-Task name.

Class Methods

TaskPreconditioner.from_json()
Construct object from a JSON-serializable dictionary.
SIGNATURE
def from_json(d: dict) -> TaskPreconditioner: ...
ARGUMENTS
Required
d
Type:dict
Description:
JSON dictionary of the task.

Methods

TaskPreconditioner.to_json()
Serialize the object to dictionary that can be written to JSON.
SIGNATURE
def to_json(
    self,
    external_file_hash: str | None = None,
    timer: Timer | None = None,
    log_to_logger: bool = False,
    comm: int | None = None,
) -> dict: ...
ARGUMENTS
Optional
external_file_hash
Type:str | None
Default value:None
Description:
Hash of any external files associated with this object. Can be passed here in which case it will be stored in a centralized location in the JSON file.
Optional
timer
Type:Timer | None
Default value:None
Description:
Execution timer.
Optional
log_to_logger
Type:bool
Default value:False
Description:
Log timings to the logger.
Optional
comm
Type:int | None
Default value:None
Description:
MPI communicator, if any.
TaskPreconditioner.update_results()
Update the results of the tasks.
SIGNATURE
def update_results(
    self,
    preconditioned_model: str | ModelType | None = None,
    info: dict[str, str] | None = None,
) -> None: ...
ARGUMENTS
Optional
preconditioned_model
Type:str | ModelType | None
Default value:None
Description:
Preconditioned model.
Optional
info
Type:dict[str, str] | None
Default value:None
Description:
Auxiliary information, e.g., the job name of a running simulation.
TaskPreconditioner.update_status()
Update task status.
SIGNATURE
def update_status(self, status: _valid_status) -> None: ...
ARGUMENTS
Required
status
Type:_valid_status
Description:
New status.
TaskPreconditioner.validate()
Validate status of the tasks.
SIGNATURE
def validate(self, success: bool = False) -> None: ...
ARGUMENTS
Optional
success
Type:bool
Default value:False
Description:
Raise if task has not been completed (status="done").
PAGE CONTENTS