Writing Scripts with the Seal Module
Last updated
Last updated
The Seal Platform allows you to write and execute your own custom Python code within the platform, enabling powerful custom solutions and automations.
If this is your first time using Python, then there are great reference materials online such as:
The Seal module is a Python package for interacting programatically with the Seal platform.
It is automatically available in every Script's Python environment - you don't need to import it manually.
The Seal module consists of a collection of methods on the seal
object:
Returns the entire json blob of data for that entity. The entity id can be copied from the entity's URL in Seal - it's the final section of the url, after the entity title.
Just passing an entity_id
returns the latest version or draft of the entity.
The entity id can be copied from the entity's URL in Seal - it's the final section of the url, after the entity title.
To get a specific version of an entity, include the version as a second argument. You can also pass an entity ref object instead.
Since it returns the whole json blob for the entity, you can get the entity's fields via entity["fields"]
, or a specific field via entity["fields"]["fieldName"]
.
Gets the entity the script card is embedded in.
Gets (non-archived) entities by their title (string). Note that exact titles are matched by default. Since multiple entities can share the same title, this returns an array. You can also search for titles containing the search string with exact=False
.
Returns an array of the entity ids in a view.
Used to make an entity editable (ie create a new draft). Returns the entire json blob of data for the new draft entity.
Converts an instance entity into a template entity. The instance must be editable (a draft) to be converted. Returns the entire json blob of data for the new template entity.
Updates the status tag on an entity. The live entity must be in an editable state.
Updates the upcoming status tag an entity will have when it is next published. The live entity must be in an editable state.
Returns the upcoming version info of an entity. This includes the version and status tag.
Used to add an entity to a pre-existing change set. The change_set_index
can be found in the URL when on a change set page.
Returns information about the change set the given entity now belongs to. This information includes id, index, name, status and description.
Adds a tag to an entity. If no tag matching the input tag is found in the organisation, a new tag will be created.
Adds a tag to the entity the script is embedded in. Can only be run from a script card.
Gets all workflow tasks associated with a workflow entity. Returns a list of dictionaries, each representing a full workflow task object.
Gets all workflow tasks for the entity that a script is embedded in. Can only be run from a script card.
Returns information about the change set the given entity belongs to. This information includes id, index, name, status and description. By default, we find the change set for the latest draft of the entity (if it exists).
To find the change set that a specific version of an entity belongs to, include the version as a second argument. You can also pass an entity ref object instead.
Gets the change set for the entity that a script is embedded in. Can only be run from a script card.
Update a field value in the entity the script is embedded in. Can only be run from a script card.
Update a field value in any entity.
Add a new field to the embedded-in entity.
Add a new field to any entity.
Remove a field from the embedded-in entity. Note that the field's data will also be removed.
Delete field in any entity.
Gets the out of spec fields for the provided entity. By default, the latest version or draft of the entity is used.
To view the out of spec fields from a specific version of an entity, include the version as a second argument. You can also pass an entity ref object instead.
The file is downloaded to the local filesystem of the virtual machine instance. The value returned is the local file path as a string.
Uploads a file into a new entity. The provided type must have 'File' content type. Returns the id of the new entity.
Extract data from a file entity. See Parameters below:
file_entity_id
: ID of the file entity to extract data from
version
: (Optional) Specific version of the file entity
prompt
: (Optional, keyword-only) Custom prompt to guide the data extraction
Returns: json
Example:
Submit one or more instances to an instance submission field, with optional initial field values in a dataframe. If a column is called 'title' or 'Title', it will set the instances' titles of setting the values of a field called 'title' or 'Title').
You can optionally specify a number of empty instances to create.
You can also submit data to a submission table in any entity:
Create an instance from a template. By default, instances are created from the latest published version of the template.
To create an instance from a specific version of a template, include the version as a second argument. You can also pass an entity ref object instead.
Parameters:
template_id
: ID of the template to create an instance from
version
: (Optional, keyword-only) Specific version of the template
field_values
: (Optional, keyword-only) Initial field values for the instance. The specified fields must exist on the template.
Similarly, you can also create test instances from a template:
Generate a chart from an Altair chart. See parameters below:\
chart
: The Altair chart instance
title
:The name for the chart
type_title
: The name of the type to create a chart from. The content type must be Chart.
Run an entity that has content type Script code
. By default, the latest version of the entity is run.
To run a specific version of a script entity, include the version as a second argument. You can also pass an entity ref object instead.
Parameters:
script_id
: ID of the script to run
version
: (Optional, keyword-only) Specific version of the script
Parameters:
entity_id
: ID of the entity with embedded scripts
version
: (Optional, keyword-only) Specific version of the entity
card_ids
: (Optional, keyword-only) List of specific card ids to run on the page
These packages are automatically imported in every Script, so don't need to be manually imported:
altair
(also aliased as alt
)
Chart
(alias of altair.Chart
)
pandas
(also aliased as pd
)
To temporarily install a package when running the script:
For specific field types, refer to this specific .
Submit instances to a in the surrounding entity.
Run all action buttons and script cards embedded in an entity with page content. You can optionally pass in the card_ids
argument to specify which scripts in particular should be run. These IDs can be found in the page content of the entity (see the for more details).
Seal comes with many common Python packages pre-installed. If there are other python packages you regularly require, please contact .