Skip to content

Commit

Permalink
Update dashboard (#195)
Browse files Browse the repository at this point in the history
* update bokeh

* use empty csv

* update downloads usage

* show exception when no records found

* added ipsl
  • Loading branch information
cehbrecht committed Nov 5, 2021
1 parent 8604804 commit 59a78a2
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 11 deletions.
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ dependencies:
- dask<2021.7.0
- aiohttp
# dashboard
- bokeh
- bokeh=2.4.1
# tests
- pytest
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ pandas<1.3.0
dask<2021.7.0
aiohttp
# dashboard
bokeh
bokeh>=2.4.1
humanize
10 changes: 5 additions & 5 deletions rook/dashboard/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous">
<!-- Bokeh CSS -->
<link href="http://cdn.pydata.org/bokeh/release/bokeh-2.3.2.min.css" rel="stylesheet">
<link href="http://cdn.pydata.org/bokeh/release/bokeh-widgets-2.3.2.min.css" rel="stylesheet">
<link href="http://cdn.pydata.org/bokeh/release/bokeh-2.4.1.min.css" rel="stylesheet">
<link href="http://cdn.pydata.org/bokeh/release/bokeh-widgets-2.4.1.min.css" rel="stylesheet">

<title>Rook - Dashboard</title>
</head>
Expand All @@ -20,9 +20,9 @@
{% endblock %}

<!-- Bokeh -->
<script src="https://cdn.bokeh.org/bokeh/release/bokeh-2.3.2.min.js"></script>
<script src="https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.3.2.min.js"></script>
<script src="https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.3.2.min.js"></script>
<script src="https://cdn.bokeh.org/bokeh/release/bokeh-2.4.1.min.js"></script>
<script src="https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.4.1.min.js"></script>
<script src="https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.4.1.min.js"></script>

<!-- Bootstrap Bundle with Popper -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/js/bootstrap.bundle.min.js" integrity="sha384-gtEjrD/SeCtmISkJkNUaaKMoLD0//ElJ19smozuHV6z3Iehds+3Ulb9Bn9Plx0x4" crossorigin="anonymous"></script>
Expand Down
2 changes: 1 addition & 1 deletion rook/processes/wps_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def __init__(self):
min_occurs=1,
max_occurs=1,
default="local",
allowed_values=["local", "ceda", "dkrz", "all"],
allowed_values=["local", "ceda", "ipsl", "dkrz", "all"],
),
LiteralInput(
"time",
Expand Down
20 changes: 17 additions & 3 deletions rook/processes/wps_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@

LOGGER = logging.getLogger()

EMPTY_CSV = """\
remote_host_ip,ip_number,datetime,timezone,request_type,request,protocol,status_code,size,referer,user_agent
127.0.0.1,1000000000,2021-01-01 12:00:00,+0200,GET,dummy.nc,HTTP/1.1,200,1000000,-,python
""" # noqa


class Usage(Process):
def __init__(self):
Expand Down Expand Up @@ -64,17 +69,26 @@ def _handler(self, request, response):
else:
time = None
time_start = time_end = None
# usage
try:
usage = WPSUsage()
response.outputs["wpsusage"].file = usage.collect(
time_start=time_start, time_end=time_end, outdir=self.workdir
)
response.update_status("WPSUsage completed.", 50)
except Exception as e:
raise ProcessError(f"{e}")
# downloads
try:
usage = Downloads()
response.outputs["downloads"].file = usage.collect(
downloads_csv = usage.collect(
time_start=time_start, time_end=time_end, outdir=self.workdir
)
response.outputs["downloads"].file = downloads_csv
except Exception:
LOGGER.exception("downloads collection failed")
response.outputs["downloads"].data = EMPTY_CSV
finally:
response.update_status("Downloads usage completed.", 90)
except Exception as e:
raise ProcessError(f"{e}")

return response
1 change: 1 addition & 0 deletions rook/usage/combine.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

URLS = {
"local": config.get_config_value("server", "url"),
"ipsl": "http://copernicus-wps.ipsl.upmc.fr/wps",
"dkrz": "http://rook3.cloud.dkrz.de/wps",
"ceda": "http://rook-wps1.ceda.ac.uk/wps",
}
Expand Down
2 changes: 2 additions & 0 deletions rook/usage/downloads.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ def parse(self, log_files, time_start=None, time_end=None, outdir=None):
if not record["request"].startswith(self.output_path):
continue
records.append(record)
if not records:
raise NotFoundError("could not find any records")
df = pd.DataFrame(records)
df = df.loc[
df["request"].str.contains(rf"{self.output_path}/.*/.*\.nc", regex=True)
Expand Down

0 comments on commit 59a78a2

Please sign in to comment.