Skip to content

Commit

Permalink
Update GriptapeCloudStructureRunDriver to look for completed statuses
Browse files Browse the repository at this point in the history
  • Loading branch information
vachillo committed Sep 17, 2024
1 parent c3f5d49 commit ea9039b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ def _get_structure_run_result(self, structure_run_id: str) -> BaseArtifact | Inf
status = result["status"]

wait_attempts = 0
while status in ("QUEUED", "RUNNING") and wait_attempts < self.structure_run_max_wait_time_attempts:
while (
status not in ("SUCCEEDED", "FAILED", "ERROR", "CANCELLED")
and wait_attempts < self.structure_run_max_wait_time_attempts
):
# wait
time.sleep(self.structure_run_wait_time_interval)
wait_attempts += 1
Expand Down
1 change: 1 addition & 0 deletions tests/integration/test_code_blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"docs/griptape-framework/drivers/src/observability_drivers_2.py",
"docs/griptape-framework/structures/src/observability_1.py",
"docs/griptape-framework/structures/src/observability_2.py",
"docs/griptape-framework/data/src/loaders_9.py",
]


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,18 @@ def driver(self, mocker, mock_requests_post):
from griptape.drivers import GriptapeCloudStructureRunDriver

mock_response = mocker.Mock()
mock_response.json.return_value = {
"description": "fizz buzz",
"output": TextArtifact("foo bar").to_dict(),
"status": "SUCCEEDED",
}
mock_response.json.side_effect = [
{"description": "fizz buzz", "status": "RUNNING"},
{"description": "fizz buzz", "output": TextArtifact("foo bar").to_dict(), "status": "SUCCEEDED"},
]
mocker.patch("requests.get", return_value=mock_response)

return GriptapeCloudStructureRunDriver(
base_url="https://cloud-foo.griptape.ai", api_key="foo bar", structure_id="1", env={"key": "value"}
base_url="https://cloud-foo.griptape.ai",
api_key="foo bar",
structure_id="1",
env={"key": "value"},
structure_run_wait_time_interval=0,
)

def test_run(self, driver, mock_requests_post):
Expand Down

0 comments on commit ea9039b

Please sign in to comment.