Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
fix: add about page to report, including embedded packages and licens…
…es (#1511) * fix: add about page to reports, listing embedded software and licenses * add heroicons
- Loading branch information
1 parent
dc65e29
commit 142a452
Showing
12 changed files
with
200 additions
and
24 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
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,17 @@ | ||
from pathlib import Path | ||
from snakemake.common import is_local_file | ||
from snakemake.exceptions import WorkflowError | ||
|
||
|
||
def get_resource_as_string(path_or_uri): | ||
import requests | ||
|
||
if is_local_file(path_or_uri): | ||
return open(Path(__file__).parent.parent / "template" / path_or_uri).read() | ||
else: | ||
r = requests.get(path_or_uri) | ||
if r.status_code == requests.codes.ok: | ||
return r.text | ||
raise WorkflowError( | ||
"Failed to download resource needed for " "report: {}".format(path_or_uri) | ||
) |
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,82 @@ | ||
import json | ||
from snakemake.exceptions import WorkflowError | ||
from snakemake.report.data.common import get_resource_as_string | ||
import snakemake | ||
|
||
|
||
def get_packages(): | ||
try: | ||
import pygments | ||
except ImportError: | ||
raise WorkflowError( | ||
"Python package pygments must be installed to create reports." | ||
) | ||
|
||
return Packages( | ||
{ | ||
"snakemake": Package( | ||
version=snakemake.__version__.split("+")[0], | ||
license_url="https://raw.githubusercontent.com/snakemake/snakemake/main/LICENSE.md", | ||
), | ||
"pygments": Package( | ||
version=pygments.__version__, | ||
license_url="https://raw.githubusercontent.com/pygments/pygments/master/LICENSE", | ||
), | ||
"tailwindcss": Package( | ||
version="3.0", | ||
license_url="https://raw.githubusercontent.com/tailwindlabs/tailwindcss/master/LICENSE", | ||
url="https://cdn.tailwindcss.com/3.0.23?plugins=forms@0.4.0,typography@0.5.2", | ||
), | ||
"react": Package( | ||
version="17", | ||
license_url="https://raw.githubusercontent.com/facebook/react/main/LICENSE", | ||
main="https://unpkg.com/react@17/umd/react.development.js", | ||
dom="https://unpkg.com/react-dom@17/umd/react-dom.development.js", | ||
), | ||
"vega": Package( | ||
version="5.21", | ||
url="https://cdnjs.cloudflare.com/ajax/libs/vega/5.21.0/vega.js", | ||
license_url="https://raw.githubusercontent.com/vega/vega/main/LICENSE", | ||
), | ||
"vega-lite": Package( | ||
version="5.2", | ||
url="https://cdnjs.cloudflare.com/ajax/libs/vega-lite/5.2.0/vega-lite.js", | ||
license_url="https://raw.githubusercontent.com/vega/vega-lite/next/LICENSE", | ||
), | ||
"vega-embed": Package( | ||
version="6.20", | ||
url="https://cdnjs.cloudflare.com/ajax/libs/vega-embed/6.20.8/vega-embed.js", | ||
license_url="https://raw.githubusercontent.com/vega/vega-embed/next/LICENSE", | ||
), | ||
"heroicons": Package( | ||
version="1.0.6", | ||
license_url="https://raw.githubusercontent.com/tailwindlabs/heroicons/master/LICENSE", | ||
), | ||
} | ||
) | ||
|
||
|
||
class Packages: | ||
def __init__(self, packages): | ||
self.packages = packages | ||
|
||
def __getitem__(self, package): | ||
return self.packages[package] | ||
|
||
def get_json(self): | ||
return json.dumps( | ||
{name: package.get_record() for name, package in self.packages.items()} | ||
) | ||
|
||
|
||
class Package: | ||
def __init__(self, version=None, license_url=None, url=None, **urls): | ||
self.version = version | ||
self.license = get_resource_as_string(license_url) | ||
if url is not None: | ||
self.url = url | ||
else: | ||
self.urls = urls | ||
|
||
def get_record(self): | ||
return {"version": self.version, "license": self.license} |
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
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,23 @@ | ||
'use strict'; | ||
|
||
class ReportInfo extends AbstractMenu { | ||
render() { | ||
return e( | ||
"ul", | ||
{}, | ||
e( | ||
ListHeading, | ||
{ text: "Embedded packages" }, | ||
), | ||
this.getPackages() | ||
); | ||
} | ||
|
||
getPackages() { | ||
let _this = this; | ||
return Object.entries(packages).map(function ([name, record]) { | ||
return _this.getMenuItem(`${name} ${record.version}`, "cube", () => _this.props.app.showLicense(name)) | ||
} | ||
); | ||
} | ||
} |
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