+If your input only provides the UUID for a container request rather than a container, you can get that container request, then follow the @container_uuid@ field if it is set. (It might not be if the container request has not been dispatched yet.)
+
+{% codeblock as python %}
+import arvados.util
+parent_container_request = arv_client.container_requests().get(
+ uuid='zzzzz-xvhdp-12345abcde67890',
+).execute()
+parent_container_uuid = parent_container_request['container_uuid']
+if parent_container_uuid is None:
+ # No container has run for this request yet, so there cannot be child requests.
+ child_container_requests = ()
+else:
+ child_container_requests = arvados.util.keyset_list_all(
+ # Do *not* call the method here, just pass it.
+ arv_client.container_requests().list,
+ filters=[
+ ['requesting_container_uuid', '=', parent_container_uuid],
+ # You may add other filters for your listing.
+ # For example, you could filter by 'name' to find specific kinds
+ # of steps of a CWL workflow.
+ ...,
+ ],
+ )
+for child_container_request in child_container_requests:
+ ... # Work with each child container request
+{% endcodeblock %}
+
+With each child container request, you could repeat any of the recipes listed earlier in this section: examine their status, inputs, outputs, logs, and so on.
+
+h2(#working-with-container-request-queue). Working with the container request queue
+
+h3(#list-completed-container-requests). List completed container requests
+
+Completed container requests have their @state@ field set to @"Final"@. You can list container requests with this filter to find completed requests.
+
+{% codeblock as python %}
+import arvados.util
+import datetime
+time_filter = datetime.datetime.utcnow()
+time_filter -= datetime.timedelta(days=7)
+
+for container_request in arvados.util.keyset_list_all(
+ # Do *not* call the method here, just pass it.
+ arv_client.container_requests().list,
+ filters=[
+ # This is the filter you need to find completed container requests.
+ ['state', '=', 'Final'],
+ # There could be many completed container requests, so you should
+ # provide additional filters. This example limits the listing to
+ # container requests from the past week.
+ ['created_at', '>=', f'{time_filter.isoformat()}Z'],
+ ...,
+ ],
+):
+ # Work with each container_request as desired.
+ # This example provides a basic status table with the container request
+ # UUID, time the request was created, and time the container finished
+ # (both in UTC).
+ print(
+ container_request['uuid'],
+ container_request['created_at'],
+ container_request['modified_at'],
+ )
+{% endcodeblock %}
+
+h3(#cancel-a-container-request). Cancel a container request
+
+To cancel a container request, update it to set its @priority@ field to 0. See the "containers API reference":{{ site.baseurl }}/api/methods/containers.html for details.
+
+{% codeblock as python %}
+cancelled_container_request = arv_client.container_requests().update(
+ uuid='zzzzz-xvhdp-12345abcde67890',
+ body={
+ 'container_request': {
+ 'priority': 0,
+ },
+ },
+).execute()
+{% endcodeblock %}
+
+p(#cancel-all-container-requests). If you want to cancel many container requests, you can list container requests with the @state@ field set to @"Committed"@, a @priority@ greater than zero, and any other filters you like. Then update each container request in turn.
+
+{% codeblock as python %}
+import arvados.util
+for container_request in arvados.util.keyset_list_all(
+ # Do *not* call the method here, just pass it.
+ arv_client.container_requests().list,
+ filters=[
+ # These are the filters you need to find cancellable container requests.
+ ['state', '=', 'Committed'],
+ ['priority', '>', 0],
+ # You can add other filters as desired.
+ # For example, you might filter on `requesting_container_uuid` to
+ # cancel only steps of one specific workflow.
+ ...,
+ ],
+):
+ cancelled_container_request = arv_client.container_requests().update(
+ uuid=container_request['uuid'],
+ body={
+ 'container_request': {
+ 'priority': 0,
+ },
+ },
+ ).execute()