-
-
Notifications
You must be signed in to change notification settings - Fork 25
add datasets page to dashboard #1532
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
Open
MattShirley
wants to merge
7
commits into
develop
Choose a base branch
from
1526-add-datasets-to-dashboard
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a99745e
add datasets dashboard
MattShirley e802fd7
add dataset mock
MattShirley 53deabb
update aod stats
MattShirley c9f888f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 6b6d37f
improve test coverage
MattShirley 0ee8ed1
Merge branch '1526-add-datasets-to-dashboard' of https://github.com/s…
MattShirley 90f60d7
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,135 @@ | ||
| {% extends "base.html" %} | ||
| {% block content %} | ||
| <div class="content-section col-12"> | ||
| <div class="row justify-content-between align-items-center"> | ||
| <h4 class="mb-3 col-auto">Dataset</h4> | ||
| <div class="col-auto"> | ||
| {% if not ds.stale %} | ||
| <button id="delete-{{ ds.id }}" | ||
| onclick="deleteDataset({{ ds.id }})" | ||
| type="button" class="btn btn-danger btn-sm"> | ||
| Flush | ||
| </button> | ||
| {% elif ds.lookup_status and ds.lookup_status.value in ('bad_name', 'does_not_exist', 'internal_failure') %} | ||
| <span class="badge badge-danger">{{ ds.lookup_status.value }}</span> | ||
| {% else %} | ||
| <span class="badge badge-secondary">Flushed</span> | ||
| {% endif %} | ||
| </div> | ||
| </div> | ||
|
|
||
| <dl class="row"> | ||
| <dt class="col-sm-3">ID</dt> | ||
| <dd class="col-sm-9">{{ ds.id }}</dd> | ||
|
|
||
| <dt class="col-sm-3">Name</dt> | ||
| <dd class="col-sm-9" style="word-break: break-all"> | ||
| {% if ds.did_finder == "user" %} | ||
| (file list) | ||
| <div class="text-muted small">{{ ds.name }}</div> | ||
| {% else %} | ||
| {{ ds.name }} | ||
| {% endif %} | ||
| </dd> | ||
|
|
||
| <dt class="col-sm-3">DID Finder</dt> | ||
| <dd class="col-sm-9">{{ ds.did_finder }}</dd> | ||
|
|
||
| <dt class="col-sm-3">Lookup Status</dt> | ||
| <dd class="col-sm-9">{{ ds.lookup_status.value if ds.lookup_status else '-' }}</dd> | ||
|
|
||
| <dt class="col-sm-3">Files</dt> | ||
| <dd class="col-sm-9">{{ humanize.intcomma(ds.n_files or 0) }}</dd> | ||
|
|
||
| <dt class="col-sm-3">Total Events</dt> | ||
| <dd class="col-sm-9">{{ humanize.intcomma(ds.events or 0) }}</dd> | ||
|
|
||
| <dt class="col-sm-3">Total Size</dt> | ||
| <dd class="col-sm-9">{{ humanize.naturalsize(ds.size or 0) }}</dd> | ||
|
|
||
| <dt class="col-sm-3">Last Used</dt> | ||
| <dd class="col-sm-9"> | ||
| {{ moment(ds.last_used).format("YYYY-MM-DD HH:mm:ss") if ds.last_used else "-" }} | ||
| <span class="tz"></span> | ||
| </dd> | ||
|
|
||
| <dt class="col-sm-3">Last Updated</dt> | ||
| <dd class="col-sm-9"> | ||
| {{ moment(ds.last_updated).format("YYYY-MM-DD HH:mm:ss") if ds.last_updated else "-" }} | ||
| <span class="tz"></span> | ||
| </dd> | ||
|
|
||
| <dt class="col-sm-3">Transform Requests</dt> | ||
| <dd class="col-sm-9"> | ||
| {% if ds.transform_requests %} | ||
| <ul class="list-unstyled mb-0"> | ||
| {% for req in ds.transform_requests %} | ||
| <li> | ||
| <a href="{{ url_for('transformation_request', id_=req.id) }}"> | ||
| {{ req.title or "Untitled" }} | ||
| </a> | ||
| <span class="text-muted small">({{ req.request_id }})</span> | ||
| </li> | ||
| {% endfor %} | ||
| </ul> | ||
| {% else %} | ||
| - | ||
| {% endif %} | ||
| </dd> | ||
| </dl> | ||
|
|
||
| <h5 class="mt-4">Files ({{ humanize.intcomma(ds.files|length) }})</h5> | ||
| {% if ds.files %} | ||
| <div class="table-responsive"> | ||
| <table class="table table-sm table-bordered table-striped"> | ||
| <thead class="thead-dark"> | ||
| <tr> | ||
| <th scope="col">ID</th> | ||
| <th scope="col">Path(s)</th> | ||
| <th scope="col">Events</th> | ||
| <th scope="col">Size</th> | ||
| <th scope="col">adler32</th> | ||
| </tr> | ||
| </thead> | ||
| <tbody> | ||
| {% for f in ds.files %} | ||
| <tr> | ||
| <th scope="row">{{ f.id }}</th> | ||
| <td style="word-break: break-all">{{ f.paths }}</td> | ||
| <td>{{ humanize.intcomma(f.file_events or 0) }}</td> | ||
| <td>{{ humanize.naturalsize(f.file_size or 0) }}</td> | ||
| <td><code>{{ f.adler32 or '-' }}</code></td> | ||
| </tr> | ||
| {% endfor %} | ||
| </tbody> | ||
| </table> | ||
| </div> | ||
| {% else %} | ||
| <p class="text-muted">No files.</p> | ||
| {% endif %} | ||
| </div> | ||
| {% endblock %} | ||
|
|
||
| {% block scripts %} | ||
| <script> | ||
| function deleteDataset(datasetId) { | ||
| if (!confirm(`Flush dataset ${datasetId}?\n\nThis marks it stale so a future request will refetch the file list.`)) { | ||
| return; | ||
| } | ||
| fetch(`/servicex/datasets/${datasetId}`, { method: 'DELETE' }) | ||
| .then(async (res) => { | ||
| if (res.ok) { | ||
| location.reload(); | ||
| } else { | ||
| const body = await res.json().catch(() => ({})); | ||
| alert(body.message || `Failed to flush dataset ${datasetId}`); | ||
| } | ||
| }) | ||
| .catch((err) => alert(`Failed to flush dataset ${datasetId}: ${err}`)); | ||
| } | ||
|
|
||
| $(document).ready(function () { | ||
| $(".tz").text(moment.tz(moment.tz.guess()).format("z")); | ||
| }); | ||
| </script> | ||
| {% endblock %} |
This file contains hidden or 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,87 @@ | ||
| {% from 'bootstrap5/pagination.html' import render_pagination %} | ||
|
|
||
| {% macro datasets_table(pagination, humanize) %} | ||
| <div class="table-responsive"> | ||
| <table class="table table-sm table-bordered table-striped"> | ||
| <caption>All times in timezone: <span class="tz"></span>.</caption> | ||
| <thead class="thead-dark"> | ||
| <tr> | ||
| <th scope="col">ID</th> | ||
| <th scope="col">Name</th> | ||
| <th scope="col">DID Finder</th> | ||
| <th scope="col">Lookup Status</th> | ||
| <th scope="col">Files</th> | ||
| <th scope="col">Events</th> | ||
| <th scope="col">Size</th> | ||
| <th scope="col">Last Used</th> | ||
| <th scope="col">Last Updated</th> | ||
| <th scope="col">Actions</th> | ||
| </tr> | ||
| </thead> | ||
| <tbody> | ||
| {% for ds in pagination.items %} | ||
| <tr id="dataset-row-{{ ds.id }}"> | ||
| <th scope="row">{{ ds.id }}</th> | ||
| <td style="max-width: 400px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;" | ||
| title="{{ ds.name }}"> | ||
| <a href="{{ url_for('dataset', id_=ds.id) }}"> | ||
| {% if ds.did_finder == "user" %}(file list){% else %}{{ ds.name }}{% endif %} | ||
| </a> | ||
| </td> | ||
| <td>{{ ds.did_finder }}</td> | ||
| <td>{{ ds.lookup_status.value if ds.lookup_status else '-' }}</td> | ||
| <td>{{ humanize.intcomma(ds.n_files or 0) }}</td> | ||
| <td>{{ humanize.intcomma(ds.events or 0) }}</td> | ||
| <td>{{ humanize.naturalsize(ds.size or 0) }}</td> | ||
| <td>{{ moment(ds.last_used).format("YYYY-MM-DD HH:mm") if ds.last_used else "-" }}</td> | ||
| <td>{{ moment(ds.last_updated).format("YYYY-MM-DD HH:mm") if ds.last_updated else "-" }}</td> | ||
| <td> | ||
| {% if not ds.stale %} | ||
| <button id="delete-{{ ds.id }}" | ||
| onclick="deleteDataset({{ ds.id }}, '{{ ds.name|e }}')" | ||
| type="button" class="btn btn-danger btn-sm"> | ||
| Flush | ||
| </button> | ||
| {% elif ds.lookup_status and ds.lookup_status.value in ('bad_name', 'does_not_exist', 'internal_failure') %} | ||
| <span class="badge badge-danger">{{ ds.lookup_status.value }}</span> | ||
| {% else %} | ||
| <span class="badge badge-secondary">Flushed</span> | ||
| {% endif %} | ||
| </td> | ||
| </tr> | ||
| {% endfor %} | ||
| </tbody> | ||
| </table> | ||
| {% if pagination.items %} | ||
| {{ render_pagination(pagination, align='center') }} | ||
| {% else %} | ||
| <div class="text-center text-muted p-4"> | ||
| No datasets found. | ||
| </div> | ||
| {% endif %} | ||
| </div> | ||
| {% endmacro %} | ||
|
|
||
| {% macro datasets_table_scripts() %} | ||
| <script> | ||
| function deleteDataset(datasetId, datasetName) { | ||
| if (!confirm(`Flush dataset "${datasetName}" (id ${datasetId})?\n\nThis marks it stale so a future request will refetch the file list.`)) { | ||
| return; | ||
| } | ||
| fetch(`/servicex/datasets/${datasetId}`, { method: 'DELETE' }) | ||
| .then(async (res) => { | ||
| if (res.ok) { | ||
| location.reload(); | ||
| } else { | ||
| const body = await res.json().catch(() => ({})); | ||
| alert(body.message || `Failed to flush dataset ${datasetId}`); | ||
| } | ||
| }) | ||
| .catch((err) => alert(`Failed to flush dataset ${datasetId}: ${err}`)); | ||
| } | ||
|
|
||
| $(document).ready(function () { | ||
| $(".tz").text(moment.tz(moment.tz.guess()).format("z")); | ||
| }); | ||
| </script> | ||
| {% endmacro %} |
This file contains hidden or 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,37 @@ | ||
| {% extends "base.html" %} | ||
|
|
||
| {% from 'dataset_table.html' import datasets_table, datasets_table_scripts with context %} | ||
| {% from 'sort_dropdown.html' import sort_dropdown %} | ||
|
|
||
| {% block content %} | ||
|
|
||
| <div class="col-12"> | ||
| <div class="content-section"> | ||
| <div class="row justify-content-between align-items-center"> | ||
| <h4 class="mb-3 col-auto">Datasets</h4> | ||
| <div class="col-auto d-flex align-items-center"> | ||
| <form method="get" class="form-inline mr-3"> | ||
| <input type="hidden" name="sort" value="{{ active_sort }}"> | ||
| <input type="hidden" name="order" value="{{ active_order }}"> | ||
| <div class="form-check"> | ||
| <input class="form-check-input" type="checkbox" name="show_deleted" value="true" | ||
| id="show_deleted" {% if show_deleted %}checked{% endif %} | ||
| onchange="this.form.submit()"> | ||
| <label class="form-check-label" for="show_deleted"> | ||
| Show flushed | ||
| </label> | ||
| </div> | ||
| </form> | ||
| {{ sort_dropdown(dropdown_options, active_sort, active_order) }} | ||
| </div> | ||
| </div> | ||
| {{ datasets_table(pagination, humanize) }} | ||
| </div> | ||
| </div> | ||
|
|
||
| {% endblock %} | ||
|
|
||
| {% block scripts %} | ||
| {{ super() }} | ||
| {{ datasets_table_scripts() }} | ||
| {% endblock %} |
This file contains hidden or 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 hidden or 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,12 @@ | ||
| from flask import render_template, abort | ||
|
|
||
| from servicex_app.decorators import oauth_required | ||
| from servicex_app.models import Dataset | ||
|
|
||
|
|
||
| @oauth_required | ||
| def dataset(id_: int): | ||
| ds = Dataset.find_by_id(id_) | ||
| if not ds: | ||
| abort(404) | ||
| return render_template("dataset.html", ds=ds) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so unfortunately
total-eventsdoes not have a consistent meaning across codegens; for uproot-raw it actually is the number of events passing the filter. I'm honestly a bit uncomfortable with doing this kind of patching...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We agree that @MattShirley will back out the backfill and just deploy the dashboard