Skip to content
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

Async dash bio #430

Merged
merged 13 commits into from
Nov 5, 2019
10 changes: 8 additions & 2 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
{
"presets": ["@babel/env", "@babel/react"]
}
"presets": [
"@babel/env",
"@babel/react"
],
"plugins": [
"@babel/plugin-syntax-dynamic-import"
]
}
8 changes: 2 additions & 6 deletions dash_bio/SequenceViewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,12 @@ class SequenceViewer(Component):
- sequenceMaxHeight (string; default '400px'): The maximum height of the sequence.
- badge (boolean; default True): The option of whether or not to display a badge showing the
amino acid count at the top of the component beside the title.
- selection (dict; optional): A highlighted section of the sequence; the color of the highlight
- selection (optional): A highlighted section of the sequence; the color of the highlight
can also be defined. Takes a list of format [min, max, color] where
min is a number that represents the starting index of the selection,
max is a number that represents the stopping index of the selection,
and color is a string that defines the highlight color.
Cannot be used at the same time as coverage. selection has the following type: list of dicts containing keys 'low', 'high', 'color'.
Those keys have the following types:
- low (number; optional)
- high (number; optional)
- color (string; optional)
Cannot be used at the same time as coverage.
- coverage (dict; optional): A coverage of the entire sequence; each section of the sequence
can have its own text color, background color, tooltip (on hover),
and an optional underscore. The props start and end represent the
Expand Down
37 changes: 35 additions & 2 deletions dash_bio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,41 @@

_this_module = _sys.modules[__name__]

async_resources = [
'alignment',
'circos',
'ideogram',
'moleculeviewer2',
'moleculeviewer3',
'needle',
'onco',
'sequence',
'speck'
]

_js_dist = []

_js_dist.extend([{
'relative_package_path': 'async~{}.js'.format(async_resource),
'external_url': (
'https://unpkg.com/dash-bio@{}'
'/dash_bio/async~{}.js'
).format(__version__, async_resource),
'namespace': 'dash_bio',
'async': True
} for async_resource in async_resources])

_js_dist = [
_js_dist.extend([{
'relative_package_path': 'async~{}.js.map'.format(async_resource),
'external_url': (
'https://unpkg.com/dash-bio@{}'
'/dash_bio/async~{}.js.map'
).format(__version__, async_resource),
'namespace': 'dash_bio',
'dynamic': True
} for async_resource in async_resources])

_js_dist.extend([
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not for this PR, but at some point - like perhaps, whenever we get around to fully generating __init__.py - this all seems ripe for abstracting into the dash core, like

_js_dist = _dash.development.list_resources(
    ['bundle.js'],
    ['async~{}.js'.format(resource) for resource in async_resources],
    external_prefix='https://unpkg.com/dash-bio@{}/dash_bio'.format(__version__)
)

May still need some tweaking to handle edge cases like async: 'eager'|'lazy', but we should at least be able to auto-detect sourcemaps (which may not exist in release versions plotly/dash#910) and set them all dynamic: True regardless of the resource setting.

{
'relative_package_path': 'bundle.js',
'external_url': (
Expand All @@ -42,7 +75,7 @@
).format(__version__),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey not new in this PR, but __version__ isn't used in this url?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔎 Interesting, due to how unpkg.com processes a this request, this works but will always return the latest released version of that file, could make for pretty nice bugs! Fixing.

Copy link
Contributor Author

@Marc-Andre-Rivet Marc-Andre-Rivet Nov 4, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Someone using the remotely hosted code for an old version will have a nasty surprise after this update..

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexcjohnson Good catch! Surprised we haven't run into it before.

'namespace': package_name
}
]
])

_css_dist = []

Expand Down
2 changes: 0 additions & 2 deletions dash_bio/_imports_.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from .AlignmentChart import AlignmentChart
from .AlignmentViewer import AlignmentViewer
from .Circos import Circos
from .Ideogram import Ideogram
from .Molecule2dViewer import Molecule2dViewer
Expand All @@ -11,7 +10,6 @@

__all__ = [
"AlignmentChart",
"AlignmentViewer",
"Circos",
"Ideogram",
"Molecule2dViewer",
Expand Down
63 changes: 63 additions & 0 deletions dash_bio/async~alignment.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions dash_bio/async~circos.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dash_bio/async~ideogram.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dash_bio/async~moleculeviewer2.js

Large diffs are not rendered by default.

39 changes: 39 additions & 0 deletions dash_bio/async~moleculeviewer3.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dash_bio/async~needle.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading