Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for running as an API server. #35

Merged
merged 19 commits into from
Dec 24, 2021

Conversation

KoleBarnes
Copy link
Contributor

  • Plus general refactoring and clean-up.

Signed-off-by: KoleBarnes kbarnes261@gmail.com

Cleaned up imports.

Signed-off-by: KoleBarnes <kbarnes261@gmail.com>
- Only use `winpty` when running interactively on Windows.
- This fixes the `stdout is not a tty` issue seen on Windows when piping the output of the script to a file.
  - For example; `./run.sh --net smn --status > status.json`

Removed all trailing white-space from network names.
Added network name and consistent timestamp to node summary.

- Add the network name to the node summary so monitoring results can be filtered and grouped by network.
- Ensure there is a consistent (UTC) timestamp on the results that can be used as the time series for the collected data.  This ensures events can be compared across nodes regardless of any clock skew on the nodes themselves.

Updated run script.

- Add support for specifying the number of samples to collect via an environment variable (default 1); `SAMPLES`.
  - Samples are taken one minute apart as the Nodes refresh their own data every minute.
- Add support for logging results directly to a timestamped file via an environment variable; `LOG`.

Full Example:
`SAMPLES=20 LOG=/c/tick-sandbox/telegraf/indy-node-monitor/BuilderNet/BuilderNet-AllNodes.json ./run.sh --net sbn --seed <seed>`
- Runs the `fetch_status` process 20 times (once every minute) producing a set of files in `/c/tick-sandbox/telegraf/indy-node-monitor/BuilderNet/` with a timestamped filename that looks like this; `BuilderNet-AllNodes_2021-05-23_06-48-20.json`.

Signed-off-by: KoleBarnes <kbarnes261@gmail.com>
Signed-off-by: KoleBarnes <kbarnes261@gmail.com>
KoleBarnes and others added 9 commits December 20, 2021 08:37
- Added function init_network_args_test. This function returns a tuple with the network info.
- Added more logging to pool connection.
- Added asyncio to requirements.txt
- Minor clean-up.
- Removed Commented code.

Signed-off-by: KoleBarnes <kbarnes261@gmail.com>
fetch_status.py
 - Added parser arg to start Fast API
 - Moved default for genesis_path to fetch_status_library.py in init_network_args so it can be used by the command line and REST API

fetch_status_library.py
 - Added return to fetch_status
 - Added default for genesis_path

run.sh
 - Opened port

Added requirements
Cleaned up imports.
Fixed fetch_status_library.py verbose not being enabled when using REST API.

Signed-off-by: KoleBarnes <kbarnes261@gmail.com>
Created did helper function.
Created separate instances for plug-ins in REST API. One to set default args and one for a separate user instance.
Added and fixed logging.
Fixed results being printed to console when running REST API.

Signed-off-by: KoleBarnes <kbarnes261@gmail.com>
 - Fetch status renamed to main.
 - Fetch status library renamed to fetch status.
 - Fetching of pool connection and fetch status are now classes.
 - Created util file for helper functions.
 - Fixed and added logging.
 - Removed some imports and requirements.

Signed-off-by: KoleBarnes <kbarnes261@gmail.com>
…ti request errors when running REST API.

Added Singleton meta class to Pool class to have a global pool cache.
Added refactoring Notes.

Signed-off-by: KoleBarnes <kbarnes261@gmail.com>
Fixed import in pool.py

Signed-off-by: KoleBarnes <kbarnes261@gmail.com>
Singleton meta class now has its own file.
Changed string manipulation in fetch pool connection for something better.
Added genesis path and url to fetch status class.
Added comments.

Signed-off-by: KoleBarnes <kbarnes261@gmail.com>
- Pull the known network related code out into it's own class; Networks
- Refactor network and pool resolution to use network ids.
- Update dependent code.  Testing is not complete

Signed-off-by: Wade Barnes <wade@neoterictech.ca>
Renamed Networks.get_names to Networks.get_ids, and Networks.get_all to Networks.get_details.
Renamed status_test to node_info and cleaned up global variables in rest_api.py.
Fixed comments and logs.

Signed-off-by: KoleBarnes <kbarnes261@gmail.com>
@KoleBarnes KoleBarnes force-pushed the feature/fastapi branch 2 times, most recently from 6d50c62 to fb2e68a Compare December 20, 2021 16:43
- Created an exception for when a requested node is not found on the requested network.
- Refactored Pool.resolve to deal with genesis url's using the new Networks class.
- Cleaned up pool cacheing.
- Clean-up variable names and logging messages.
- Add redirect to API, from `/` to `/docs`.

Signed-off-by: Wade Barnes <wade@neoterictech.ca>
Signed-off-by: KoleBarnes <kbarnes261@gmail.com>
- Removed import argparse ArgumentError.

Signed-off-by: KoleBarnes <kbarnes261@gmail.com>
 - uvicorn for debug.
 - gunicorn for production.

Signed-off-by: KoleBarnes <kbarnes261@gmail.com>
Added code to check if a seed is being used while running the REST API. If so it will exit.
Changed App name and description.

Signed-off-by: KoleBarnes <kbarnes261@gmail.com>
Add API documentation.

Signed-off-by: KoleBarnes <kbarnes261@gmail.com>
Signed-off-by: KoleBarnes <kbarnes261@gmail.com>
…e Networks.

Signed-off-by: KoleBarnes <kbarnes261@gmail.com>
@WadeBarnes WadeBarnes merged commit 324e530 into hyperledger:main Dec 24, 2021
@KoleBarnes KoleBarnes deleted the feature/fastapi branch January 27, 2022 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants