Skip to content

Commit

Permalink
Merge branch 'api-renames' of https://github.com/SubstrateLabs/substr…
Browse files Browse the repository at this point in the history
…ate-python into api-renames
  • Loading branch information
0thernet committed Jun 13, 2024
2 parents 359a804 + 4d86ae0 commit c924537
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
7 changes: 3 additions & 4 deletions examples/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@

# response = substrate.run(story, summary)
response = substrate.run(story)
print(response.api_response.json)
print(response.api_response.status_code)
print(response)

# summary_out = response.get(summary)
# print(summary_out.text)
summary_out = response.get(summary)
print(summary_out.text)

# viz = Substrate.visualize(ry)
# print(viz)
12 changes: 12 additions & 0 deletions substrate/substrate_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@ class SubstrateResponse:
def __init__(self, api_response: APIResponse):
self._api_response = api_response

def __str__(self):
return f"SubstrateResponse(request_id={self.request_id}, api_response={self._api_response.status_code})"

@property
def request_id(self) -> Optional[str]:
"""
The request id.
"""
if self.json:
return self.json.get("substrate_request_id")
return None

def get(self, node: CoreNode[OT]) -> OT:
"""
Get the output of a specific node.
Expand Down

0 comments on commit c924537

Please sign in to comment.