Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def queue_counts(status):
socket = get_socket()
data = socket.get_queue(status=status, limit=1)
return data["meta"]["n_found"]
def managers_table(status):
socket = get_socket()
managers = socket.get_managers(status=status)
df = pd.DataFrame(managers["data"])
df["uuid"] = [x[:6] for x in df["uuid"]]
cols = ["cluster", "username", "uuid", "submitted", "completed", "failures"]
table = dash_table.DataTable(
id='table',
columns=[{
"name": i.title(),
"id": i
} for i in cols],
data=df[cols].to_dict('records'),
filtering=True,
sorting=True,
def list_managers(status=None, modified_after=None):
socket = get_socket()
managers = socket.get_managers(status=status, modified_after=modified_after)
cols = [
"cluster",
"username",
"tag",
"completed",
"submitted",
"failures",
"returned",
"created_on",
"modified_on",
"programs",
"procedures",
# "name"
]
def service_counts(status):
socket = get_socket()
data = socket.get_services(status=status, limit=1)
return data["meta"]["n_found"]
def task_graph():
socket = get_socket()
cnts = socket.custom_query("task", "counts")
df = pd.DataFrame(cnts["data"])
df.loc[df["tag"].isna(), "tag"] = "None"
order = df.groupby("tag")["count"].sum().sort_values(ascending=False).index
bar_iter = [
("waiting", DEFAULT_PLOTLY_COLORS[0]),
("running", DEFAULT_PLOTLY_COLORS[2]),
("error", DEFAULT_PLOTLY_COLORS[3]),
]
bars = []
for status, color in bar_iter:
bar_data = []
def overview_graph(status):
socket = get_socket()
managers = socket.get_managers(status=status)
df = pd.DataFrame(managers["data"])
data = df.groupby("cluster")["completed"].sum().sort_values(ascending=False)
return {"data": [{"x": data.index, "y": data.values}]}
def manager_graph(status=None, modified_after=None):
socket = get_socket()
managers = socket.get_managers(status=status, modified_after=modified_after)
df = pd.DataFrame(managers["data"])
bars = []
if df.shape[0] > 0:
data = df.groupby("cluster")[["completed", "submitted", "failures"]].sum()
data["error"] = data["failures"]
data["running"] = data["submitted"] - data["completed"]
bar_iter = [
("error", DEFAULT_PLOTLY_COLORS[3]),
("running", DEFAULT_PLOTLY_COLORS[2]),
("completed", DEFAULT_PLOTLY_COLORS[0]),
]