-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from ORNL/dev
Main < Dev
- Loading branch information
Showing
23 changed files
with
7,508 additions
and
43 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 @@ | ||
requests |
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 |
---|---|---|
@@ -1,4 +1,8 @@ | ||
tensorboard==2.10.1 | ||
tensorflow-macos==2.10.0 | ||
pandas==1.5.1 | ||
tbparse==0.0.7 | ||
pytest==6.2.4 | ||
flake8==5.0.4 | ||
black==23.1.0 | ||
numpy==1.23.4 | ||
tensorboard==2.11.0 | ||
tensorflow-macos==2.11.0 | ||
bokeh==2.4.2 | ||
jupyterlab |
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 |
---|---|---|
|
@@ -4,3 +4,5 @@ black==23.1.0 | |
numpy==1.23.4 | ||
tensorboard==2.11.0 | ||
tensorflow==2.11.0 | ||
bokeh==2.4.2 | ||
jupyterlab==3.6.1 |
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
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,67 @@ | ||
from threading import Thread | ||
from time import sleep | ||
|
||
from flowcept.commons.doc_db.document_inserter import DocumentInserter | ||
|
||
import json | ||
from typing import List, Dict | ||
import requests | ||
|
||
from flowcept.configs import WEBSERVER_PORT, WEBSERVER_HOST | ||
from flowcept.flowcept_webserver.app import BASE_ROUTE | ||
from flowcept.flowcept_webserver.resources.query_rsrc import TaskQuery | ||
|
||
|
||
class FlowceptConsumerAPI(object): | ||
def __init__(self): | ||
self._consumer_thread: Thread = None | ||
|
||
def start(self): | ||
self._consumer_thread = Thread(target=DocumentInserter().main) | ||
self._consumer_thread.start() | ||
print("Flowcept Consumer starting...") | ||
sleep(2) | ||
print("Ok, we're consuming messages!") | ||
|
||
# def close(self): | ||
# self._consumer_thread.join() | ||
|
||
|
||
class TaskQueryAPI(object): | ||
def __init__( | ||
self, | ||
host: str = WEBSERVER_HOST, | ||
port: int = WEBSERVER_PORT, | ||
auth=None, | ||
): | ||
self._host = host | ||
self._port = port | ||
self._url = ( | ||
f"http://{self._host}:{self._port}{BASE_ROUTE}{TaskQuery.ROUTE}" | ||
) | ||
|
||
def query( | ||
self, | ||
filter: dict, | ||
projection: dict = None, | ||
limit: int = 0, | ||
sort: dict = None, | ||
remove_json_unserializables=True, | ||
) -> List[Dict]: | ||
request_data = {"filter": json.dumps(filter)} | ||
if projection: | ||
request_data["projection"] = json.dumps(projection) | ||
if limit: | ||
request_data["limit"] = limit | ||
if sort: | ||
request_data["sort"] = json.dumps(sort) | ||
if remove_json_unserializables: | ||
request_data[ | ||
"remove_json_unserializables" | ||
] = remove_json_unserializables | ||
|
||
r = requests.post(self._url, json=request_data) | ||
if 200 <= r.status_code < 300: | ||
return r.json() | ||
else: | ||
raise Exception(r.text) |
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 @@ | ||
|
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
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,32 @@ | ||
import json | ||
from flask_restful import Resource, reqparse | ||
|
||
from flowcept.commons.doc_db.document_db_dao import DocumentDBDao | ||
|
||
|
||
class TaskQuery(Resource): | ||
ROUTE = "/task_query" | ||
|
||
def post(self): | ||
parser = reqparse.RequestParser() | ||
req_args = ["filter", "projection", "sort", "limit"] | ||
for arg in req_args: | ||
parser.add_argument(arg, type=str, required=False, help="") | ||
args = parser.parse_args() | ||
|
||
doc_args = {} | ||
for arg in args: | ||
if args[arg] is None: | ||
continue | ||
try: | ||
doc_args[arg] = json.loads(args[arg]) | ||
except Exception as e: | ||
return (f"Could not parse {arg} argument: {e}"), 400 | ||
|
||
dao = DocumentDBDao() | ||
docs = dao.find(**doc_args) | ||
|
||
if docs is not None and len(docs): | ||
return docs, 201 | ||
else: | ||
return (f"Could not find matching docs"), 404 |
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
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
Oops, something went wrong.