-
Notifications
You must be signed in to change notification settings - Fork 291
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
Introduce flyte Decks into flytekit #859
Merged
Changes from 35 commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
4959b41
Introduce flyte Decks into flytekit
pingsutw 4f2d48d
Updated deck interface
pingsutw 6e669d3
Merge branch 'master' of github.com:flyteorg/flytekit into deck
pingsutw 50a49e9
Updated deck interface
pingsutw 10890f0
Updated dependency
pingsutw e8d98ba
Updated comment
pingsutw 1eace7a
Fixed tests
pingsutw 6c6712c
Fixed tests
pingsutw 3890b78
Deck plugin
pingsutw f2fe059
Refactor deck interface
pingsutw 2a82127
Merged master
pingsutw 85d063f
Updated tests
pingsutw 77b2b94
Updated tests
pingsutw 6bf8ac1
Updated tests
pingsutw 8a88f4c
Updated tests
pingsutw 11319b9
Updated tests
pingsutw f5361d0
Updated tests
pingsutw dfbe437
Fixed tests
pingsutw 2ac7936
Merged master
pingsutw 1277718
Lint fixed
pingsutw 31fd500
Addressed comment
pingsutw 72144dc
Fixed tests
pingsutw 98d5045
Fixed plugin tests
pingsutw 736c935
Fixed spark plugin tests
pingsutw 5b7c407
Merge branch 'master' of github.com:flyteorg/flytekit into deck
pingsutw 9d5fb3e
Tests fixed
pingsutw 9fc0f4b
Add deck plugin to ci
pingsutw 163aa39
Fixed tests
pingsutw 6150ddb
More tests
pingsutw cdc4bcf
Fix spark tests
pingsutw 3373b2d
Fix lint
pingsutw cb545e9
address comments
pingsutw 8a8f7c2
address comments
pingsutw 8e94c2e
Fixed tests error
pingsutw 987e058
Fixed tests error
pingsutw 948f00c
add example and update type hint
pingsutw 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 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
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,2 @@ | ||
from .deck import Deck | ||
from .renderer import TopFrameRenderer |
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,79 @@ | ||
import os | ||
from typing import Dict, Optional | ||
|
||
from jinja2 import Environment, FileSystemLoader | ||
|
||
from flytekit.core.context_manager import ExecutionParameters, FlyteContext, FlyteContextManager | ||
|
||
|
||
class Deck: | ||
""" | ||
Deck enable users to get customizable and default visibility into their tasks. | ||
|
||
Deck contains a list of renderers (FrameRenderer, MarkdownRenderer) that can | ||
generate a html file. For example, FrameRenderer can render a DataFrame as an HTML table, | ||
MarkdownRenderer can convert Markdown string to HTML | ||
|
||
Flyte context saves a list of deck objects, and we use renderers in those decks to render | ||
the data and create an HTML file when those tasks are executed | ||
|
||
Each task has a least three decks (input, output, default). Input/output decks are | ||
used to render tasks' input/output data, and the default deck is used to render line plots, | ||
scatter plots or markdown text. In addition, users can create new decks to render | ||
their data with custom renderers. | ||
|
||
.. warning:: | ||
|
||
This feature is in beta. | ||
|
||
""" | ||
|
||
def __init__(self, name: str, html: Optional[str] = ""): | ||
self._name = name | ||
# self.renderers = renderers if isinstance(renderers, list) else [renderers] | ||
self._html = html | ||
FlyteContextManager.current_context().user_space_params.decks.append(self) | ||
|
||
def append(self, html: str) -> "Deck": | ||
assert isinstance(html, str) | ||
self._html = self._html + "\n" + html | ||
return self | ||
|
||
@property | ||
def name(self) -> str: | ||
return self._name | ||
|
||
@property | ||
def html(self) -> str: | ||
return self._html | ||
|
||
|
||
def _output_deck(task_name: str, new_user_params: ExecutionParameters): | ||
deck_map: Dict[str, str] = {} | ||
decks = new_user_params.decks | ||
ctx = FlyteContext.current_context() | ||
|
||
# TODO: upload deck file to remote filesystems (s3, gcs) | ||
output_dir = ctx.file_access.get_random_local_directory() | ||
|
||
for deck in decks: | ||
_deck_to_html_file(deck, deck_map, output_dir) | ||
|
||
root = os.path.dirname(os.path.abspath(__file__)) | ||
templates_dir = os.path.join(root, "html") | ||
env = Environment(loader=FileSystemLoader(templates_dir)) | ||
template = env.get_template("template.html") | ||
|
||
deck_path = os.path.join(output_dir, "deck.html") | ||
with open(deck_path, "w") as f: | ||
f.write(template.render(metadata=deck_map)) | ||
|
||
print(f"{task_name} output flytekit deck html to file://{deck_path}") | ||
|
||
|
||
def _deck_to_html_file(deck: Deck, deck_map: Dict[str, str], output_dir: str): | ||
file_name = deck.name + ".html" | ||
path = os.path.join(output_dir, file_name) | ||
with open(path, "w") as output: | ||
deck_map[deck.name] = file_name | ||
output.write(deck.html) |
Empty file.
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.
list of?