Dataset Activity¶
Dataset activity includes any operation that imports, transforms, exports or copies dataset data.
You can view a datasets activity via the API or in the SolveBio UI by visiting the Activity tab of a dataset.
Example: Check for any activity¶
This example is a fast way to check for any activity on a dataset.
1 2 3 4 5 6 7 | from solvebio import Dataset activity = Dataset.retrieve(<DATASET ID>).activity() if activity: print("Dataset has active tasks") else: # run some analysis print("Dataset is idle") |
1 2 3 4 5 6 7 8 | status <- paste('running', 'queued', 'pending', sep=',') tasks <- Task.all(target_object_id=<DATASET ID>, status=status, limit=1)$total if (tasks) { # Active tasks } else { # Dataset is idle } |
Example: Wait for idle dataset¶
Some use cases may require waiting until a dataset is idle. A dataset is idle when there are no longer any task operations that are queued, pending or running.
This can be done synchronously using the follow
parameter. This parameter continually loops through all dataset activity until the dataset is idle.
The function sleeps in between each check for activity. The default is 3 seconds and can be modified using the sleep_seconds
parameter.
The function also limits the activity check to 1 tasks. This can be modified using the limit
parameter.
1 2 3 4 5 6 7 8 | from solvebio import Dataset Dataset.retrieve(<DATASET ID>).activity(follow=True) # Sleep for 20 seconds in between Dataset.retrieve(<DATASET ID>).activity(follow=True, sleep_seconds=20.0) # Retrieve information for at most 30 active tasks Dataset.retrieve(<DATASET ID>).activity(follow=True, limit=30) |
1 2 3 4 | Dataset.activity(<DATASET ID>, follow=TRUE) # Retrieve information for at most 30 active tasks Dataset.activity(<DATASET ID>, follow=TRUE, limit=30) |