-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
1,641 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
"""Generate the code reference pages and navigation. https://mkdocstrings.github.io/recipes/?h=recip#automatic-code-reference-pages.""" | ||
|
||
from pathlib import Path | ||
|
||
import mkdocs_gen_files | ||
|
||
pkg_name = "watz" | ||
|
||
nav = mkdocs_gen_files.Nav() # type: ignore | ||
|
||
for path in sorted(Path(pkg_name).rglob("*.py")): | ||
# Make sure filename doesn't start with an underscore: | ||
if path.name.startswith("_"): | ||
continue | ||
|
||
module_path = path.relative_to(".").with_suffix("") | ||
doc_path = path.relative_to(pkg_name).with_suffix(".md") | ||
full_doc_path = Path("reference", doc_path) | ||
|
||
parts = tuple(module_path.parts) | ||
|
||
if parts[-1] == "__init__": | ||
parts = parts[:-1] | ||
doc_path = doc_path.with_name("index.md") | ||
full_doc_path = full_doc_path.with_name("index.md") | ||
elif parts[-1] == "__main__": | ||
continue | ||
|
||
if parts: | ||
nav[parts] = doc_path.as_posix() | ||
|
||
with mkdocs_gen_files.open(full_doc_path, "w") as fd: | ||
ident = ".".join(parts) | ||
fd.write(f"::: {ident}") | ||
|
||
mkdocs_gen_files.set_edit_path(full_doc_path, path) | ||
|
||
with mkdocs_gen_files.open("reference/SUMMARY.md", "w") as nav_file: | ||
nav_file.writelines(nav.build_literate_nav()) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 9, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"971.264\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"import json\n", | ||
"import pprint\n", | ||
"\n", | ||
"with open(\"/home/zakst/Downloads/req_example.json\", \"r\") as file:\n", | ||
" data = json.load(file)\n", | ||
" # print size in kb of file:\n", | ||
" file_size = len(json.dumps(data))\n", | ||
" print(file_size/1000)\n", | ||
"\n", | ||
"\n", | ||
"\n", | ||
"# pprint.pprint(data[\"Requests\"])" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stderr", | ||
"output_type": "stream", | ||
"text": [ | ||
"/home/zakst/code/watz-py/watz/client.py:36: UserWarning: Failed to connect to Watz API. Attempt 1 of 5.\n", | ||
" return end_ping.call(self._session, ReqPing())\n", | ||
"/home/zakst/code/watz-py/watz/client.py:36: UserWarning: Failed to connect to Watz API. Attempt 2 of 5.\n", | ||
" return end_ping.call(self._session, ReqPing())\n", | ||
"/home/zakst/code/watz-py/watz/client.py:36: UserWarning: Failed to connect to Watz API. Attempt 3 of 5.\n", | ||
" return end_ping.call(self._session, ReqPing())\n", | ||
"/home/zakst/code/watz-py/watz/client.py:36: UserWarning: Failed to connect to Watz API. Attempt 4 of 5.\n", | ||
" return end_ping.call(self._session, ReqPing())\n", | ||
"/home/zakst/code/watz-py/watz/client.py:36: UserWarning: Failed to connect to Watz API. Attempt 5 of 5.\n", | ||
" return end_ping.call(self._session, ReqPing())\n" | ||
] | ||
}, | ||
{ | ||
"ename": "ConnectError", | ||
"evalue": "Failed to connect to Watz API after 5 attempts.", | ||
"output_type": "error", | ||
"traceback": [ | ||
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", | ||
"\u001b[0;31mConnectError\u001b[0m Traceback (most recent call last)", | ||
"\u001b[1;32m/home/zakst/code/watz-py/notebooks/scratch_space.ipynb Cell 1\u001b[0m line \u001b[0;36m4\n\u001b[1;32m <a href='vscode-notebook-cell:/home/zakst/code/watz-py/notebooks/scratch_space.ipynb#W0sZmlsZQ%3D%3D?line=0'>1</a>\u001b[0m \u001b[39mimport\u001b[39;00m \u001b[39mwatz\u001b[39;00m\n\u001b[1;32m <a href='vscode-notebook-cell:/home/zakst/code/watz-py/notebooks/scratch_space.ipynb#W0sZmlsZQ%3D%3D?line=2'>3</a>\u001b[0m client \u001b[39m=\u001b[39m watz\u001b[39m.\u001b[39mClient(base\u001b[39m=\u001b[39m\u001b[39m\"\u001b[39m\u001b[39mhttp://localhost:3000\u001b[39m\u001b[39m\"\u001b[39m, secret\u001b[39m=\u001b[39m\u001b[39m\"\u001b[39m\u001b[39mafb48q5s.GJmVKAk9sSrsSD2qoIdIwxjYjjuY8uMK\u001b[39m\u001b[39m\"\u001b[39m)\n\u001b[0;32m----> <a href='vscode-notebook-cell:/home/zakst/code/watz-py/notebooks/scratch_space.ipynb#W0sZmlsZQ%3D%3D?line=3'>4</a>\u001b[0m client\u001b[39m.\u001b[39;49mping()\n", | ||
"File \u001b[0;32m~/code/watz-py/watz/client.py:36\u001b[0m, in \u001b[0;36mClient.ping\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 30\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39mping\u001b[39m(\u001b[39mself\u001b[39m) \u001b[39m-\u001b[39m\u001b[39m>\u001b[39m RespPing:\n\u001b[1;32m 31\u001b[0m \u001b[39m \u001b[39m\u001b[39m\"\"\"Ping the API.\u001b[39;00m\n\u001b[1;32m 32\u001b[0m \n\u001b[1;32m 33\u001b[0m \u001b[39m Returns:\u001b[39;00m\n\u001b[1;32m 34\u001b[0m \u001b[39m RespPing: The response from the API.\u001b[39;00m\n\u001b[1;32m 35\u001b[0m \u001b[39m \"\"\"\u001b[39;00m\n\u001b[0;32m---> 36\u001b[0m \u001b[39mreturn\u001b[39;00m end_ping\u001b[39m.\u001b[39;49mcall(\u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49m_session, ReqPing())\n", | ||
"File \u001b[0;32m~/code/watz-py/watz/endpoints/_endpoint.py:35\u001b[0m, in \u001b[0;36mEndpoint.call\u001b[0;34m(self, session, req)\u001b[0m\n\u001b[1;32m 34\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39mcall\u001b[39m(\u001b[39mself\u001b[39m, session: httpx\u001b[39m.\u001b[39mClient, req: Req_T) \u001b[39m-\u001b[39m\u001b[39m>\u001b[39m Resp_T:\n\u001b[0;32m---> 35\u001b[0m resp \u001b[39m=\u001b[39m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49m_req(session, req)\n\u001b[1;32m 36\u001b[0m \u001b[39mreturn\u001b[39;00m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_parse(resp)\n", | ||
"File \u001b[0;32m~/code/watz-py/watz/endpoints/_endpoint.py:53\u001b[0m, in \u001b[0;36mEndpoint._req\u001b[0;34m(self, session, req)\u001b[0m\n\u001b[1;32m 48\u001b[0m warnings\u001b[39m.\u001b[39mwarn(\n\u001b[1;32m 49\u001b[0m \u001b[39m\"\u001b[39m\u001b[39mFailed to connect to Watz API. Attempt \u001b[39m\u001b[39m{}\u001b[39;00m\u001b[39m of 5.\u001b[39m\u001b[39m\"\u001b[39m\u001b[39m.\u001b[39mformat(x \u001b[39m+\u001b[39m \u001b[39m1\u001b[39m), stacklevel\u001b[39m=\u001b[39m\u001b[39m3\u001b[39m\n\u001b[1;32m 50\u001b[0m )\n\u001b[1;32m 51\u001b[0m time\u001b[39m.\u001b[39msleep(\u001b[39m0.5\u001b[39m)\n\u001b[0;32m---> 53\u001b[0m \u001b[39mraise\u001b[39;00m httpx\u001b[39m.\u001b[39mConnectError(\u001b[39m\"\u001b[39m\u001b[39mFailed to connect to Watz API after 5 attempts.\u001b[39m\u001b[39m\"\u001b[39m)\n", | ||
"\u001b[0;31mConnectError\u001b[0m: Failed to connect to Watz API after 5 attempts." | ||
] | ||
} | ||
], | ||
"source": [ | ||
"# import watz\n", | ||
"\n", | ||
"client = watz.Client(base=\"http://localhost:3000\", secret=\"afb48q5s.GJmVKAk9sSrsSD2qoIdIwxjYjjuY8uMK\")\n", | ||
"client.ping()\n" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": ".venv", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.12.0" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
Oops, something went wrong.