anod.action

Package Contents

Classes

Action

Action object.

Root

Root action.

GetSource

GetSource Action.

Download

General root class for all download actions.

DownloadSource

DownloadSource Action.

InstallSource

InstallSource Action.

CreateSource

CreateSource Action.

CreateSources

CreateSources Action.

Checkout

Checkout Action.

AnodAction

AnodAction Action.

Build

Anod build primitive.

Test

Anod test primitive.

Install

Anod install primitive.

DownloadBinary

DownloadBinary Action.

Upload

General root class for all upload actions.

UploadComponent

UploadComponent Action.

UploadBinaryComponent

Upload binary component.

UploadSourceComponent

Upload source only component.

UploadSource

Upload a source package.

Decision

Decision Action.

CreateSourceOrDownload

Decision between creating or downloading a source package.

BuildOrDownload

Decision between building or downloading a component.

Attributes

Choice

anod.action.Choice
class anod.action.Action(uid: str, data: Any)

Action object.

Action objects are used as node in DAG produced by anod scheduler. Only child classes are used directly.

property run_method: str
__slots__ = ('uid', 'data')
class anod.action.Root

Bases: Action

Root action.

This action does not correspond to any real activity. It’s only used as the root of the DAG and can be “executed” only once all the scheduled Actions are completed.

__slots__ = ('uid', 'data')
__str__() str

Return str(self).

class anod.action.GetSource(builder: e3.anod.package.SourceBuilder)

Bases: Action

GetSource Action.

This action means that we need to retrieve a given source package. In the anod DAG context it can either have one child node: DownloadSource (read access to a store) or provide the choice between DownloadSource or CreateSource using a Decision node.

__slots__ = ('uid', 'builder')
__str__() str

Return str(self).

class anod.action.Download(uid: str, data: Any)

Bases: Action

General root class for all download actions.

class anod.action.DownloadSource(builder: e3.anod.package.SourceBuilder)

Bases: Download

DownloadSource Action.

This action means the we need to download from the store a given source. DownloadSource is always a leaf of the DAG.

__slots__ = ('uid', 'builder')
__str__() str

Return str(self).

class anod.action.InstallSource(uid: str, spec: e3.anod.spec.Anod, source: e3.anod.package.Source)

Bases: Action

InstallSource Action.

This means that a source should be installed. Child action is always a GetSource Action.

__slots__ = ('uid', 'spec', 'source')
__str__() str

Return str(self).

class anod.action.CreateSource(anod_instance: e3.anod.spec.Anod, source_name: str)

Bases: Action

CreateSource Action.

This means that we need to assemble the source package from a repositories checkouts. CreateSource has at least one Checkout child node.

__slots__ = ('uid', 'anod_instance', 'source_name')
__str__() str

Return str(self).

class anod.action.CreateSources(anod_instance: e3.anod.spec.Anod)

Bases: Action

CreateSources Action.

This action does not correspond to any real activity. It’s only used to group all CreateSource action corresponding to the same anod spec.

__slots__ = ('uid', 'anod_instance')
__str__() str

Return str(self).

class anod.action.Checkout(repo_name: str, repo_data: dict[str, Any])

Bases: Action

Checkout Action.

This means that we need to perform the checkout/update of a given repository.

__slots__ = ('uid', 'repo_name', 'repo_data')
__str__() str

Return str(self).

class anod.action.AnodAction(anod_instance: e3.anod.spec.Anod)

Bases: Action

AnodAction Action.

Correspond to an Anod primitive call. Only subclasses should be used.

__slots__ = ('uid', 'anod_instance')
__str__() str

Return str(self).

class anod.action.Build(anod_instance: e3.anod.spec.Anod)

Bases: AnodAction

Anod build primitive.

class anod.action.Test(anod_instance: e3.anod.spec.Anod)

Bases: AnodAction

Anod test primitive.

class anod.action.Install(anod_instance: e3.anod.spec.Anod)

Bases: AnodAction

Anod install primitive.

class anod.action.DownloadBinary(data: e3.anod.spec.Anod)

Bases: Download

DownloadBinary Action.

Download a binary package from the store.

__slots__ = ('uid', 'data')
__str__() str

Return str(self).

class anod.action.Upload(uid: str, data: Any)

Bases: Action

General root class for all upload actions.

class anod.action.UploadComponent(data: e3.anod.spec.Anod)

Bases: Upload

UploadComponent Action.

Upload a component to the store.

__slots__ = ('uid', 'data', 'anod_instance')
str_prefix = ''
__str__() str

Return str(self).

class anod.action.UploadBinaryComponent(data: e3.anod.spec.Anod)

Bases: UploadComponent

Upload binary component.

str_prefix = 'binary package'
class anod.action.UploadSourceComponent(data: e3.anod.spec.Anod)

Bases: UploadComponent

Upload source only component.

str_prefix = 'source metadata'
class anod.action.UploadSource(anod_instance: e3.anod.spec.Anod, source_name: str)

Bases: Upload

Upload a source package.

__slots__ = ('uid', 'anod_instance', 'source_name')
__str__() str

Return string representation.

class anod.action.Decision(root: Action, left: Action, right: Action, choice: Choice | None = None)

Bases: Action

Decision Action.

Decision nodes correspond to Action nodes where the end result can be obtained using multiple methods. For instance, sources can be obtained either by downloading them from the store, but also by getting them from repositories. Each child of Decision nodes represents one way to obtain the desired end result (a “choice”).

The current implementation only supports 2 choices, called “left” and “right”.

The DAG we first create when reading the plan includes these Decision nodes. Then, as part of scheduling the plan, we create a new DAG where all Decision nodes are removed, and only one child of each Decision is chosen by the scheduler, then taking the place of its Decision node in the DAG. Therefore, once scheduling of the DAG is complete, there should no longer be any Decision node left.

It important to know that this class does not actually decide which choice to make. It just records some information about the plan, and the associated specs. It then uses that information to determine if a choice has actually been made, be it implicitly or explicitly.

Variables:
  • initiator (str) – The UID of the parent node of the decision.

  • left_action (Action.) – The first possible choice for our decision.

  • right_action (Action.) – The second possible choice for our decision.

  • choice (Decision.LEFT | Decision.RIGHT | Decision.BOTH) – If not None, the choice made by the plan itself. It can be Decision.LEFT, meaning that the plan contains an entry to perform the self.left_action; If set to Decision.RIGHT, it means the plan contains an entry to perform the self.right_action; and if set to BOTH, it means the plan contains entries to perform both self.left_action and self.right_action (which may or may not be an issue).

  • expected_choice – If not None, the choice implicitly made by the way the specs involved in the decision are written. In practice, this attribute records the constraints we have in terms of the choices in the plan which are valid.

  • triggers (list[(str, LEFT | RIGHT, str | None)]) – A list of actions that, if present in a DAG being created while scheduling the plan (from which this Decision originates), causes a specific choice to be expected for this decision. Each element of this list consists of a tuple with the uid of the Action triggering the choice, the expected choice, and a plan_line (if the action comes from the plan, otherwise None).

  • decision_maker – If not None, the plan_line where an entry in the plan is performing an action corresponding to one of our choices.

Ivar:

str

property left: str

return self.left_action.uid (this is a convenience property).

property right: str

return self.right_action.uid (this is a convenience property).

LEFT: Final = 0
RIGHT: Final = 1
BOTH: Final = 2
add_trigger(trigger: Action, decision: Choice, plan_line: str) None

Add a trigger to self.triggers.

See the description of the “triggers” attribute for more information as to what these triggers are used for.

Parameters:
  • trigger – The action which, when scheduled, causes the given decision (which is actually more aptly described as a choice) to be recorded as the expected choice for our Decision.

  • decision – The expected choice when the trigger Action is scheduled.

  • plan_line – plan line associated with this action

apply_triggers(dag: e3.collection.dag.DAG) None

Apply triggers to the given dag.

Parameters:

dag – a dag of scheduled actions

get_decision() str | None

Return uid of the choice made by the plan, or None.

This function returns the choice made by the plan, if any. This means that if the plan doesn’t include an action that implements any of the choices, we return None. Similarly, if the plan has actions implementing more than one of the choices, the plan hasn’t made any decision because the decision is ambiguous.

And finally, if the plan made a choice, but that choice contradicts this decision’s expected_choice, then the decision is incorrect, and we also return None in that case.

Returns:

None if the decision cannot be made; otherwise, return uid of the choice that was made.

get_expected_decision() str | None

Get expected decision.

Returns:

uid of the expected action or None if no specific decision is expected.

set_decision(which: Choice, decision_maker: str | None) None

Record a choice made by an action in a plan.

This method should be caused when an entry in our plan performs an action corresponding to one of the choices for our decision. This method records which of the choices that action performs.

Parameters:
  • which – Decision.LEFT or Decision.RIGHT

  • decision_maker – Record who the decision maker is. This is typically the plan line of the action performing the choice being recorded.

abstract classmethod description(decision: Choice) str

Return a description of the decision (actually a choice).

Parameters:

decision – The decision (actually a choice).

Returns:

A description of the given parameter (named “decision”, but actually a choice).

suggest_plan_fix(choice: Choice) str | None

Suggest a plan line that would fix the conflict.

Parameters:

choice – Decision.LEFT or Decision.RIGHT

Returns:

a line to add to the plan or None if no fix can be proposed

class anod.action.CreateSourceOrDownload(root: Action, left: CreateSource, right: DownloadSource)

Bases: Decision

Decision between creating or downloading a source package.

CREATE: Final
DOWNLOAD: Final
classmethod description(decision: Choice) str

Return a description of the decision (actually a choice).

Parameters:

decision – The decision (actually a choice).

Returns:

A description of the given parameter (named “decision”, but actually a choice).

class anod.action.BuildOrDownload(root: Install, left: Build, right: DownloadBinary)

Bases: Decision

Decision between building or downloading a component.

BUILD: Final
INSTALL: Final
classmethod description(decision: Choice) str

Return a description of the decision (actually a choice).

Parameters:

decision – The decision (actually a choice).

Returns:

A description of the given parameter (named “decision”, but actually a choice).

suggest_plan_fix(choice: Choice) str

Suggest a plan line that would fix the conflict.

Parameters:

choice – Decision.LEFT or Decision.RIGHT

Returns:

a line to add to the plan or None if no fix can be proposed