Action#

Graviti SDK use class Action to represent an action. The action name is used as the unique identifier of an action. And the data usage workflow is defined in the action payload which follows the yaml syntax.

Action is a dataset level resource, it is necessary to get a dataset first:

from graviti import Workspace

ws = Workspace(f"{YOUR_ACCESSKEY}")

dataset = ws.datasets.get(f"{DATASET_NAME}")

Create an Action#

SDK provides method create() to create an action:

with open(f"{PAYLOAD_YAML_FILE_PATH}") as fp:
    payload = fp.read()

dataset.actions.create(f"{ACTION_NAME}", payload)

List Actions#

SDK provides method list() to list actions:

dataset.actions.list()

Get an Action#

SDK provides method get() to get an action:

dataset.actions.get(f"{ACTION_NAME}")

Update an Action#

SDK provides method Action.edit() to update an action:

Rename the action:

action = dataset.actions.get(f"{ACTION_NAME}")
action.edit(name=f"{NEW_ACTION_NAME}")

Update the action payload:

with open(f"{PAYLOAD_YAML_FILE_PATH}") as fp:
    new_payload = fp.read()

action.edit(payload=f"{NEW_ACTION_NAME}")

Note

Everytime the payload is updated, the Action.edition will be incremented by one.

Disable or Enable an Action#

SDK provides methods Action.disable() and Action.enable() to disable and enable an action:

Once an action is disabled, it cannot be triggered automately and manually.

>>> action = dataset.actions.get(f"{ACTION_NAME}")
>>> action.state
'ENABLED'

>>> action.disable()
>>> action.state
'DISABLED'

>>> action.enable()
>>> action.state
'ENABLED'

Delete an Action#

SDK provides method delete() to delete an action:

dataset.actions.delete(f"{ACTION_NAME}")

Run an Action#

“Run an Action” is equivalent to “Create an Action Run”, check Create an Action Run to run an action.