-
Notifications
You must be signed in to change notification settings - Fork 297
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
Add Python Dependency Deck #2264
Conversation
- Add a new class `SourceCodeDeck` to render the source code of a task - Implement the `html` property in the `SourceCodeDeck` class Signed-off-by: jason.lai <jasonlai1218@gmail.com>
- Change the class name from `SourceCodeDeck` to `PythonDependencyDeck` - Update the deck description to reflect python dependencies instead of source code - Remove the source code rendering functionality and replace it with a table renderer for python dependencies - Add subprocess logic to fetch installed python packages and render them in an HTML table Signed-off-by: jason.lai <jasonlai1218@gmail.com>
- Add a property method for `pythondependency_deck` - Initialize `python_dependency_deck` if it is None - Remove a property method for `timeline_deck` Signed-off-by: jason.lai <jasonlai1218@gmail.com>
- Add `PythonDependencyDeck` to `flytekit/__init__.py` Signed-off-by: jason.lai <jasonlai1218@gmail.com>
- Add `pandas` import to `flytekit/deck/deck.py` - Change the input of `TableRenderer().to_html` to a `pd.DataFrame` in `flytekit/deck/deck.py` Signed-off-by: jason.lai <jasonlai1218@gmail.com>
- Update the return type annotation for `pythondependency_deck` in `context_manager.py` Signed-off-by: jason.lai <jasonlai1218@gmail.com>
- Add `PythonDependencyDeck` to the TYPE_CHECKING import - Add a method `add_deck` to `FlyteContext` class Signed-off-by: jason.lai <jasonlai1218@gmail.com>
- Refactor the code to use a DataFrame for installed packages handling Signed-off-by: jason.lai <jasonlai1218@gmail.com>
- Update the name of the PythonDependencyDeck instance from "PythonDependencyDeck" to "Python Dependency" Signed-off-by: jason.lai <jasonlai1218@gmail.com>
- Add CSS style to center align the table content Signed-off-by: jason.lai <jasonlai1218@gmail.com>
- Rename method `pythondependency_deck` to `python_dependency_deck` - Update variable names in method `python_dependency_deck` - Update method comments in class `FlyteContext` - Update method comments in class `PythonDependencyDeck` Signed-off-by: jason.lai <jasonlai1218@gmail.com>
- Remove import of `PythonDependencyDeck` from `flytekit/__init__.py` Signed-off-by: jason.lai <jasonlai1218@gmail.com>
- Remove the import of `PythonDependencyDeck` from `flytekit/core/context_manager.py` - Add an import of `Deck` to `flytekit/core/context_manager.py` Signed-off-by: jason.lai <jasonlai1218@gmail.com>
- Add a condition to check for deck existence before appending - Change single quotes to double quotes for consistency - Update package split delimiter to double quotes Signed-off-by: jason.lai <jasonlai1218@gmail.com>
- Remove the `python_dependency_deck` property from the `ExecutionParameters` class in `context_manager.py` - Update the `__init__` method signature in the `PythonDependencyDeck` class in `deck.py` Signed-off-by: jason.lai <jasonlai1218@gmail.com>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2264 +/- ##
==========================================
- Coverage 83.50% 82.68% -0.83%
==========================================
Files 324 305 -19
Lines 24754 24063 -691
Branches 3734 3523 -211
==========================================
- Hits 20672 19896 -776
- Misses 3452 3542 +90
+ Partials 630 625 -5 ☔ View full report in Codecov by Sentry. |
- Remove unnecessary import of `pandas` in `flytekit/deck/deck.py` - Add import of `pandas` in `flytekit/deck/deck.py` Signed-off-by: jason.lai <jasonlai1218@gmail.com>
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.
Thank you for the PR!
- Add a new test for the PythonDependencyDeck class in test_deck.py - Add assertions for specific strings in the HTML content in the test_python_dependency_deck() function Signed-off-by: jason.lai <jasonlai1218@gmail.com>
- Clear user space decks before adding a new deck - Ensure only one deck is added to user space params Signed-off-by: jason.lai <jasonlai1218@gmail.com>
- Import json and TableRenderer in `flytekit/deck/deck.py` - Change how installed packages are fetched in `flytekit/deck/deck.py` - Remove unused code in `flytekit/deck/deck.py` - Remove assertions for "Library" and "Version" in `tests/flytekit/unit/deck/test_deck.py` Signed-off-by: jason.lai <jasonlai1218@gmail.com>
- Modify the table headers to have left-aligned text - Add extra line breaks after the button element Signed-off-by: jason.lai <jasonlai1218@gmail.com>
- Change the assertion to check for `Name` and `Version` instead of `name` and `version` in the result Signed-off-by: jason.lai <jasonlai1218@gmail.com>
- Increase the test deadlines from 2 to 20 seconds in test_type_conversion_errors.py - Update test deadlines from 2 to 40 seconds in test_type_conversion_errors.py - Adjust test deadlines in test_eager_workflows.py for various tests Signed-off-by: jason.lai <jasonlai1218@gmail.com>
This reverts commit 1885662. Signed-off-by: Eduardo Apolinario <eapolinario@users.noreply.github.com>
Signed-off-by: Eduardo Apolinario <eapolinario@users.noreply.github.com>
Signed-off-by: Eduardo Apolinario <eapolinario@users.noreply.github.com>
…ow that we're no longer writing decks unnecessarily) Signed-off-by: Eduardo Apolinario <eapolinario@users.noreply.github.com>
Signed-off-by: Eduardo Apolinario <eapolinario@users.noreply.github.com>
Signed-off-by: Eduardo Apolinario <eapolinario@users.noreply.github.com>
- Add a patch to the `test_python_dependency_renderer` function - Include assertions for `numpy` and `1.21.0` in the test result - Update the `test_deck.py` file in the `tests/flytekit/unit/deck` directory Signed-off-by: jason.lai <jasonlai1218@gmail.com>
- Import `PythonDependencyRenderer` and `SourceCodeRenderer` in `PythonFunctionTask` from separate files - Modify the way `requirements_txt` is generated in `PythonDependencyRenderer` - Refactor the creation of the `table` variable in `PythonDependencyRenderer` to improve readability Signed-off-by: jason.lai <jasonlai1218@gmail.com>
flytekit/deck/renderer.py
Outdated
) | ||
except subprocess.CalledProcessError as e: | ||
logger.error(f"Error occurred while fetching installed packages: {e}") | ||
return "" |
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.
Having an empty HTML feels like a bad dev experience. I think it's worth having an error message:
return "" | |
return "Error occurred while fetching installed packages." |
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.
agree
</head> | ||
<body> | ||
|
||
<button onclick="copyTable()"> |
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.
@eapolinario This copy button does not work. I get this error in the console:
If we can not get this to work, I'm okay with removing the copy button and just showing the table.
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.
This is blocked on flyteorg/flyteconsole#852.
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.
That just got merged, so next Flyte release is going to have this.
source_code_deck = Deck("Source Code") | ||
renderer = SourceCodeRenderer() | ||
source_code_deck.append(renderer.to_html(source_code)) | ||
python_dependencies_deck = Deck("Python Dependencies") |
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.
flytekit/deck/renderer.py
Outdated
PythonDependencyDeck is a deck that contains information about packages installed via pip. | ||
""" | ||
|
||
def __init__(self, title: str = "Python Dependencies"): |
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.
def __init__(self, title: str = "Python Dependencies"): | |
def __init__(self, title: str = "Dependencies"): |
flytekit/deck/renderer.py
Outdated
<button onclick="copyTable()"> | ||
<span>Copy table as requirements.txt</span> | ||
</button> | ||
<br><br><br> |
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.
<br><br><br> | |
<h3>Python Dependencies</h3> |
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.
- Change the title of the deck from `Python Dependencies` to `Dependencies` - Update the error message in case of a subprocess error in fetching installed packages - Add a heading `Python Dependencies` above the table output in the HTML Signed-off-by: jason.lai <jasonlai1218@gmail.com>
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.
Assuming https://github.com/flyteorg/flytekit/pull/2264/files#r1548469361 will get resolved with a new flyte release, this PR LGTM
Signed-off-by: Eduardo Apolinario <eapolinario@users.noreply.github.com>
* feat: refactor source code rendering in `SourceCodeDeck` class - Add a new class `SourceCodeDeck` to render the source code of a task - Implement the `html` property in the `SourceCodeDeck` class Signed-off-by: jason.lai <jasonlai1218@gmail.com> * refactor: refactor deck rendering for Python dependencies - Change the class name from `SourceCodeDeck` to `PythonDependencyDeck` - Update the deck description to reflect python dependencies instead of source code - Remove the source code rendering functionality and replace it with a table renderer for python dependencies - Add subprocess logic to fetch installed python packages and render them in an HTML table Signed-off-by: jason.lai <jasonlai1218@gmail.com> * refactor: refactor class properties and initialization - Add a property method for `pythondependency_deck` - Initialize `python_dependency_deck` if it is None - Remove a property method for `timeline_deck` Signed-off-by: jason.lai <jasonlai1218@gmail.com> * - feat: consolidate Python dependencies in `flytekit/__init__.py` - Add `PythonDependencyDeck` to `flytekit/__init__.py` Signed-off-by: jason.lai <jasonlai1218@gmail.com> * refactor: refactor `flytekit/deck/deck.py` for `pandas` compatibility - Add `pandas` import to `flytekit/deck/deck.py` - Change the input of `TableRenderer().to_html` to a `pd.DataFrame` in `flytekit/deck/deck.py` Signed-off-by: jason.lai <jasonlai1218@gmail.com> * refactor: refactor return types across multiple files - Update the return type annotation for `pythondependency_deck` in `context_manager.py` Signed-off-by: jason.lai <jasonlai1218@gmail.com> * feat: consolidate Python dependency management in FlyteContext - Add `PythonDependencyDeck` to the TYPE_CHECKING import - Add a method `add_deck` to `FlyteContext` class Signed-off-by: jason.lai <jasonlai1218@gmail.com> * refactor: refactor code to use DataFrame for package handling - Refactor the code to use a DataFrame for installed packages handling Signed-off-by: jason.lai <jasonlai1218@gmail.com> * chore: refactor code for improved naming conventions - Update the name of the PythonDependencyDeck instance from "PythonDependencyDeck" to "Python Dependency" Signed-off-by: jason.lai <jasonlai1218@gmail.com> * style: improve table alignment styling in CSS - Add CSS style to center align the table content Signed-off-by: jason.lai <jasonlai1218@gmail.com> * refactor: refactor method and variable names across files - Rename method `pythondependency_deck` to `python_dependency_deck` - Update variable names in method `python_dependency_deck` - Update method comments in class `FlyteContext` - Update method comments in class `PythonDependencyDeck` Signed-off-by: jason.lai <jasonlai1218@gmail.com> * refactor: refactor imports in flytekit package - Remove import of `PythonDependencyDeck` from `flytekit/__init__.py` Signed-off-by: jason.lai <jasonlai1218@gmail.com> * refactor: consolidate import statements in core/context_manager.py - Remove the import of `PythonDependencyDeck` from `flytekit/core/context_manager.py` - Add an import of `Deck` to `flytekit/core/context_manager.py` Signed-off-by: jason.lai <jasonlai1218@gmail.com> * style: improve code consistency and error checking - Add a condition to check for deck existence before appending - Change single quotes to double quotes for consistency - Update package split delimiter to double quotes Signed-off-by: jason.lai <jasonlai1218@gmail.com> * refactor: refactor Python dependency handling in classes - Remove the `python_dependency_deck` property from the `ExecutionParameters` class in `context_manager.py` - Update the `__init__` method signature in the `PythonDependencyDeck` class in `deck.py` Signed-off-by: jason.lai <jasonlai1218@gmail.com> * chore: optimize imports in deck.py files - Remove unnecessary import of `pandas` in `flytekit/deck/deck.py` - Add import of `pandas` in `flytekit/deck/deck.py` Signed-off-by: jason.lai <jasonlai1218@gmail.com> * test: improve test coverage for PythonDependencyDeck class - Add a new test for the PythonDependencyDeck class in test_deck.py - Add assertions for specific strings in the HTML content in the test_python_dependency_deck() function Signed-off-by: jason.lai <jasonlai1218@gmail.com> * feat: enhance user space deck management - Clear user space decks before adding a new deck - Ensure only one deck is added to user space params Signed-off-by: jason.lai <jasonlai1218@gmail.com> * refactor: refactor deck module and unit tests - Import json and TableRenderer in `flytekit/deck/deck.py` - Change how installed packages are fetched in `flytekit/deck/deck.py` - Remove unused code in `flytekit/deck/deck.py` - Remove assertions for "Library" and "Version" in `tests/flytekit/unit/deck/test_deck.py` Signed-off-by: jason.lai <jasonlai1218@gmail.com> * fix: update subprocess calls to use `sys.executable` - Import `sys` to fix an issue with subprocess execution - Update the subprocess call to use `sys.executable` instead of `pip` Signed-off-by: jason.lai <jasonlai1218@gmail.com> * feat: refactor HTML generation logic and improve user experience - Update the HTML generation logic to include a button for copying the table as requirements.txt. Signed-off-by: jason.lai <jasonlai1218@gmail.com> * feat: enhance table content copying functionality - Add functionality to copy table content as requirements.txt - Improve error handling when copying table content - Display table content as hidden div for copying Signed-off-by: jason.lai <jasonlai1218@gmail.com> * refactor: improve table content copying functionality - Remove unnecessary code for table content copying - Update table content copying functionality to use innerText of requirements_txt element Signed-off-by: jason.lai <jasonlai1218@gmail.com> * refactor: improve package management and error handling - Add logic to generate a `requirements.txt` file from installed packages - Update error logging message in case of subprocess error - Update console log message when accessing clipboard - Update `requirements_txt` div content with actual `requirements_txt` variable Signed-off-by: jason.lai <jasonlai1218@gmail.com> * chore: standardize whitespace in requirements_txt handling - Remove trailing whitespace from `requirements_txt` string - Add a whitespace to the end of the `requirements_txt` variable - Log an error message when fetching installed packages fails Signed-off-by: jason.lai <jasonlai1218@gmail.com> * style: standardize quotation marks for package_info keys - Corrected quotation marks in package_info keys - Changed single quotes to double quotes for consistency Signed-off-by: jason.lai <jasonlai1218@gmail.com> * refactor: simplify requirements_txt generation - Refactor code to simplify the generation of `requirements_txt` - Add the output of `pip freeze` to `requirements_txt` Signed-off-by: jason.lai <jasonlai1218@gmail.com> * docs: fix typos and improve code consistency across files - Fix a typo in the usage of the `pip freeze` command in the PythonDependencyDeck class Signed-off-by: jason.lai <jasonlai1218@gmail.com> * refactor: refactor dependency handling in PythonDependencyDeck class - Update the way `requirements_txt` is populated in the `PythonDependencyDeck` class Signed-off-by: jason.lai <jasonlai1218@gmail.com> * refactor: update default name and test assertion in PythonDependencyDeck - Update the default name in the PythonDependencyDeck constructor from "Python Dependency" to "Python Dependencies" - Update the assertion in the test_python_dependency_deck function to check for the new default name "Python Dependencies" Signed-off-by: jason.lai <jasonlai1218@gmail.com> * refactor: update rendering of Pandas DataFrame using MarkdownRenderer - Import `MarkdownRenderer` from `flytekit.deck` instead of `TableRenderer` - Render the Pandas DataFrame as markdown using `MarkdownRenderer` instead of `TableRenderer` Signed-off-by: jason.lai <jasonlai1218@gmail.com> * refactor: refactor PythonDependencyDeck and related classes - Remove the `add_deck` method from `FlyteContext` - Add imports for `PythonDependencyRenderer` and `PythonDependencyDeck` in `PythonFunctionTask` - Remove the `PythonDependencyDeck` class and related methods from the `deck.py` file - Add the `PythonDependencyRenderer` class in `renderer.py` Signed-off-by: jason.lai <jasonlai1218@gmail.com> * feat: use `TableRenderer` for rendering DataFrames - Import `TableRenderer` from a different module - Replace the `MarkdownRenderer` with `TableRenderer` to render a DataFrame as a table Signed-off-by: jason.lai <jasonlai1218@gmail.com> * test: refactor codebase for improved performance - Remove unused import statements in `flytekit/deck/renderer.py` - Add a new test for `PythonDependencyRenderer` in `tests/flytekit/unit/deck/test_deck.py` Signed-off-by: jason.lai <jasonlai1218@gmail.com> * test: update test_deck.py for python dependency deck testing - Update test_deck.py to include python dependency deck in various test cases - Adjust expected deck counts in test cases to reflect the changes - Add test cases for scenarios involving python dependency deck and input and output decks Signed-off-by: jason.lai <jasonlai1218@gmail.com> * style: standardize import statements for pandas in project files - Remove `import pandas as pd` and replace it with `import pandas as pandas` Signed-off-by: jason.lai <jasonlai1218@gmail.com> * refactor: refactor import statements for `TableRenderer` usage - Import `TableRenderer` from a different location in `flytekit/deck/renderer.py` - Remove `TableRenderer` from the imports in `flytekit-deck-standard/flytekitplugins/deck/__init__.py` Signed-off-by: jason.lai <jasonlai1218@gmail.com> * refactor: update PythonDependencyRenderer description - Update the description of PythonDependencyDeck in PythonDependencyRenderer Signed-off-by: jason.lai <jasonlai1218@gmail.com> * refactor: refactor type hints and assertions across files - Change the type hint for `df` parameter to `pandas.DataFrame` - Add an assertion to check the type of `df` is `pandas.DataFrame` Signed-off-by: jason.lai <jasonlai1218@gmail.com> * feat: refactor rendering classes in deck and plugins - Add TableRenderer to TimeLineDeck class in deck.py - Remove TableRenderer from deck/renderer.py - Add TableRenderer to PythonDependencyRenderer in deck/renderer.py - Add TableRenderer to flytekit-deck-standard plugin - Remove TableRenderer from test_renderer.py Signed-off-by: jason.lai <jasonlai1218@gmail.com> * docs: standardize markdown formatting across files - Update the markdown table format in PythonDependencyRenderer class Signed-off-by: jason.lai <jasonlai1218@gmail.com> * refactor: refactor markdown table rendering in PythonDependencyRenderer - Update the markdown table format in the PythonDependencyRenderer class to use HTML table tags - Modify the markdown_table variable concatenation for installed packages entries in the PythonDependencyRenderer class Signed-off-by: jason.lai <jasonlai1218@gmail.com> * style: improve code consistency in PythonDependencyRenderer - Add a line break after the button element in PythonDependencyRenderer Signed-off-by: jason.lai <jasonlai1218@gmail.com> * style: standardize formatting for better readability - Modify the table headers to have left-aligned text - Add extra line breaks after the button element Signed-off-by: jason.lai <jasonlai1218@gmail.com> * fix: update assertion to check for `Name` and `Version` consistency - Change the assertion to check for `Name` and `Version` instead of `name` and `version` in the result Signed-off-by: jason.lai <jasonlai1218@gmail.com> * test: extend test deadlines across various tests - Increase the test deadlines from 2 to 20 seconds in test_type_conversion_errors.py - Update test deadlines from 2 to 40 seconds in test_type_conversion_errors.py - Adjust test deadlines in test_eager_workflows.py for various tests Signed-off-by: jason.lai <jasonlai1218@gmail.com> * Revert "test: extend test deadlines across various tests" This reverts commit 1885662. Signed-off-by: Eduardo Apolinario <eapolinario@users.noreply.github.com> * Only run generate decks in python_function_task if decks are enabled Signed-off-by: Eduardo Apolinario <eapolinario@users.noreply.github.com> * Remove breakpoint Signed-off-by: Eduardo Apolinario <eapolinario@users.noreply.github.com> * Fix test_deck.py tests to account for the number of expected decks (now that we're no longer writing decks unnecessarily) Signed-off-by: Eduardo Apolinario <eapolinario@users.noreply.github.com> * Increase deadline of eager tests Signed-off-by: Eduardo Apolinario <eapolinario@users.noreply.github.com> * Fix lint error Signed-off-by: Eduardo Apolinario <eapolinario@users.noreply.github.com> * test: update test assertions in test_deck.py - Add a patch to the `test_python_dependency_renderer` function - Include assertions for `numpy` and `1.21.0` in the test result - Update the `test_deck.py` file in the `tests/flytekit/unit/deck` directory Signed-off-by: jason.lai <jasonlai1218@gmail.com> * refactor: refactor Python code organization - Import `PythonDependencyRenderer` and `SourceCodeRenderer` in `PythonFunctionTask` from separate files - Modify the way `requirements_txt` is generated in `PythonDependencyRenderer` - Refactor the creation of the `table` variable in `PythonDependencyRenderer` to improve readability Signed-off-by: jason.lai <jasonlai1218@gmail.com> * docs: refactor project structure and improve user experience - Change the title of the deck from `Python Dependencies` to `Dependencies` - Update the error message in case of a subprocess error in fetching installed packages - Add a heading `Python Dependencies` above the table output in the HTML Signed-off-by: jason.lai <jasonlai1218@gmail.com> * Separate out tests that require hypothesis Signed-off-by: Eduardo Apolinario <eapolinario@users.noreply.github.com> --------- Signed-off-by: jason.lai <jasonlai1218@gmail.com> Signed-off-by: Eduardo Apolinario <eapolinario@users.noreply.github.com> Co-authored-by: Eduardo Apolinario <eapolinario@users.noreply.github.com>
* feat: refactor source code rendering in `SourceCodeDeck` class - Add a new class `SourceCodeDeck` to render the source code of a task - Implement the `html` property in the `SourceCodeDeck` class Signed-off-by: jason.lai <jasonlai1218@gmail.com> * refactor: refactor deck rendering for Python dependencies - Change the class name from `SourceCodeDeck` to `PythonDependencyDeck` - Update the deck description to reflect python dependencies instead of source code - Remove the source code rendering functionality and replace it with a table renderer for python dependencies - Add subprocess logic to fetch installed python packages and render them in an HTML table Signed-off-by: jason.lai <jasonlai1218@gmail.com> * refactor: refactor class properties and initialization - Add a property method for `pythondependency_deck` - Initialize `python_dependency_deck` if it is None - Remove a property method for `timeline_deck` Signed-off-by: jason.lai <jasonlai1218@gmail.com> * - feat: consolidate Python dependencies in `flytekit/__init__.py` - Add `PythonDependencyDeck` to `flytekit/__init__.py` Signed-off-by: jason.lai <jasonlai1218@gmail.com> * refactor: refactor `flytekit/deck/deck.py` for `pandas` compatibility - Add `pandas` import to `flytekit/deck/deck.py` - Change the input of `TableRenderer().to_html` to a `pd.DataFrame` in `flytekit/deck/deck.py` Signed-off-by: jason.lai <jasonlai1218@gmail.com> * refactor: refactor return types across multiple files - Update the return type annotation for `pythondependency_deck` in `context_manager.py` Signed-off-by: jason.lai <jasonlai1218@gmail.com> * feat: consolidate Python dependency management in FlyteContext - Add `PythonDependencyDeck` to the TYPE_CHECKING import - Add a method `add_deck` to `FlyteContext` class Signed-off-by: jason.lai <jasonlai1218@gmail.com> * refactor: refactor code to use DataFrame for package handling - Refactor the code to use a DataFrame for installed packages handling Signed-off-by: jason.lai <jasonlai1218@gmail.com> * chore: refactor code for improved naming conventions - Update the name of the PythonDependencyDeck instance from "PythonDependencyDeck" to "Python Dependency" Signed-off-by: jason.lai <jasonlai1218@gmail.com> * style: improve table alignment styling in CSS - Add CSS style to center align the table content Signed-off-by: jason.lai <jasonlai1218@gmail.com> * refactor: refactor method and variable names across files - Rename method `pythondependency_deck` to `python_dependency_deck` - Update variable names in method `python_dependency_deck` - Update method comments in class `FlyteContext` - Update method comments in class `PythonDependencyDeck` Signed-off-by: jason.lai <jasonlai1218@gmail.com> * refactor: refactor imports in flytekit package - Remove import of `PythonDependencyDeck` from `flytekit/__init__.py` Signed-off-by: jason.lai <jasonlai1218@gmail.com> * refactor: consolidate import statements in core/context_manager.py - Remove the import of `PythonDependencyDeck` from `flytekit/core/context_manager.py` - Add an import of `Deck` to `flytekit/core/context_manager.py` Signed-off-by: jason.lai <jasonlai1218@gmail.com> * style: improve code consistency and error checking - Add a condition to check for deck existence before appending - Change single quotes to double quotes for consistency - Update package split delimiter to double quotes Signed-off-by: jason.lai <jasonlai1218@gmail.com> * refactor: refactor Python dependency handling in classes - Remove the `python_dependency_deck` property from the `ExecutionParameters` class in `context_manager.py` - Update the `__init__` method signature in the `PythonDependencyDeck` class in `deck.py` Signed-off-by: jason.lai <jasonlai1218@gmail.com> * chore: optimize imports in deck.py files - Remove unnecessary import of `pandas` in `flytekit/deck/deck.py` - Add import of `pandas` in `flytekit/deck/deck.py` Signed-off-by: jason.lai <jasonlai1218@gmail.com> * test: improve test coverage for PythonDependencyDeck class - Add a new test for the PythonDependencyDeck class in test_deck.py - Add assertions for specific strings in the HTML content in the test_python_dependency_deck() function Signed-off-by: jason.lai <jasonlai1218@gmail.com> * feat: enhance user space deck management - Clear user space decks before adding a new deck - Ensure only one deck is added to user space params Signed-off-by: jason.lai <jasonlai1218@gmail.com> * refactor: refactor deck module and unit tests - Import json and TableRenderer in `flytekit/deck/deck.py` - Change how installed packages are fetched in `flytekit/deck/deck.py` - Remove unused code in `flytekit/deck/deck.py` - Remove assertions for "Library" and "Version" in `tests/flytekit/unit/deck/test_deck.py` Signed-off-by: jason.lai <jasonlai1218@gmail.com> * fix: update subprocess calls to use `sys.executable` - Import `sys` to fix an issue with subprocess execution - Update the subprocess call to use `sys.executable` instead of `pip` Signed-off-by: jason.lai <jasonlai1218@gmail.com> * feat: refactor HTML generation logic and improve user experience - Update the HTML generation logic to include a button for copying the table as requirements.txt. Signed-off-by: jason.lai <jasonlai1218@gmail.com> * feat: enhance table content copying functionality - Add functionality to copy table content as requirements.txt - Improve error handling when copying table content - Display table content as hidden div for copying Signed-off-by: jason.lai <jasonlai1218@gmail.com> * refactor: improve table content copying functionality - Remove unnecessary code for table content copying - Update table content copying functionality to use innerText of requirements_txt element Signed-off-by: jason.lai <jasonlai1218@gmail.com> * refactor: improve package management and error handling - Add logic to generate a `requirements.txt` file from installed packages - Update error logging message in case of subprocess error - Update console log message when accessing clipboard - Update `requirements_txt` div content with actual `requirements_txt` variable Signed-off-by: jason.lai <jasonlai1218@gmail.com> * chore: standardize whitespace in requirements_txt handling - Remove trailing whitespace from `requirements_txt` string - Add a whitespace to the end of the `requirements_txt` variable - Log an error message when fetching installed packages fails Signed-off-by: jason.lai <jasonlai1218@gmail.com> * style: standardize quotation marks for package_info keys - Corrected quotation marks in package_info keys - Changed single quotes to double quotes for consistency Signed-off-by: jason.lai <jasonlai1218@gmail.com> * refactor: simplify requirements_txt generation - Refactor code to simplify the generation of `requirements_txt` - Add the output of `pip freeze` to `requirements_txt` Signed-off-by: jason.lai <jasonlai1218@gmail.com> * docs: fix typos and improve code consistency across files - Fix a typo in the usage of the `pip freeze` command in the PythonDependencyDeck class Signed-off-by: jason.lai <jasonlai1218@gmail.com> * refactor: refactor dependency handling in PythonDependencyDeck class - Update the way `requirements_txt` is populated in the `PythonDependencyDeck` class Signed-off-by: jason.lai <jasonlai1218@gmail.com> * refactor: update default name and test assertion in PythonDependencyDeck - Update the default name in the PythonDependencyDeck constructor from "Python Dependency" to "Python Dependencies" - Update the assertion in the test_python_dependency_deck function to check for the new default name "Python Dependencies" Signed-off-by: jason.lai <jasonlai1218@gmail.com> * refactor: update rendering of Pandas DataFrame using MarkdownRenderer - Import `MarkdownRenderer` from `flytekit.deck` instead of `TableRenderer` - Render the Pandas DataFrame as markdown using `MarkdownRenderer` instead of `TableRenderer` Signed-off-by: jason.lai <jasonlai1218@gmail.com> * refactor: refactor PythonDependencyDeck and related classes - Remove the `add_deck` method from `FlyteContext` - Add imports for `PythonDependencyRenderer` and `PythonDependencyDeck` in `PythonFunctionTask` - Remove the `PythonDependencyDeck` class and related methods from the `deck.py` file - Add the `PythonDependencyRenderer` class in `renderer.py` Signed-off-by: jason.lai <jasonlai1218@gmail.com> * feat: use `TableRenderer` for rendering DataFrames - Import `TableRenderer` from a different module - Replace the `MarkdownRenderer` with `TableRenderer` to render a DataFrame as a table Signed-off-by: jason.lai <jasonlai1218@gmail.com> * test: refactor codebase for improved performance - Remove unused import statements in `flytekit/deck/renderer.py` - Add a new test for `PythonDependencyRenderer` in `tests/flytekit/unit/deck/test_deck.py` Signed-off-by: jason.lai <jasonlai1218@gmail.com> * test: update test_deck.py for python dependency deck testing - Update test_deck.py to include python dependency deck in various test cases - Adjust expected deck counts in test cases to reflect the changes - Add test cases for scenarios involving python dependency deck and input and output decks Signed-off-by: jason.lai <jasonlai1218@gmail.com> * style: standardize import statements for pandas in project files - Remove `import pandas as pd` and replace it with `import pandas as pandas` Signed-off-by: jason.lai <jasonlai1218@gmail.com> * refactor: refactor import statements for `TableRenderer` usage - Import `TableRenderer` from a different location in `flytekit/deck/renderer.py` - Remove `TableRenderer` from the imports in `flytekit-deck-standard/flytekitplugins/deck/__init__.py` Signed-off-by: jason.lai <jasonlai1218@gmail.com> * refactor: update PythonDependencyRenderer description - Update the description of PythonDependencyDeck in PythonDependencyRenderer Signed-off-by: jason.lai <jasonlai1218@gmail.com> * refactor: refactor type hints and assertions across files - Change the type hint for `df` parameter to `pandas.DataFrame` - Add an assertion to check the type of `df` is `pandas.DataFrame` Signed-off-by: jason.lai <jasonlai1218@gmail.com> * feat: refactor rendering classes in deck and plugins - Add TableRenderer to TimeLineDeck class in deck.py - Remove TableRenderer from deck/renderer.py - Add TableRenderer to PythonDependencyRenderer in deck/renderer.py - Add TableRenderer to flytekit-deck-standard plugin - Remove TableRenderer from test_renderer.py Signed-off-by: jason.lai <jasonlai1218@gmail.com> * docs: standardize markdown formatting across files - Update the markdown table format in PythonDependencyRenderer class Signed-off-by: jason.lai <jasonlai1218@gmail.com> * refactor: refactor markdown table rendering in PythonDependencyRenderer - Update the markdown table format in the PythonDependencyRenderer class to use HTML table tags - Modify the markdown_table variable concatenation for installed packages entries in the PythonDependencyRenderer class Signed-off-by: jason.lai <jasonlai1218@gmail.com> * style: improve code consistency in PythonDependencyRenderer - Add a line break after the button element in PythonDependencyRenderer Signed-off-by: jason.lai <jasonlai1218@gmail.com> * style: standardize formatting for better readability - Modify the table headers to have left-aligned text - Add extra line breaks after the button element Signed-off-by: jason.lai <jasonlai1218@gmail.com> * fix: update assertion to check for `Name` and `Version` consistency - Change the assertion to check for `Name` and `Version` instead of `name` and `version` in the result Signed-off-by: jason.lai <jasonlai1218@gmail.com> * test: extend test deadlines across various tests - Increase the test deadlines from 2 to 20 seconds in test_type_conversion_errors.py - Update test deadlines from 2 to 40 seconds in test_type_conversion_errors.py - Adjust test deadlines in test_eager_workflows.py for various tests Signed-off-by: jason.lai <jasonlai1218@gmail.com> * Revert "test: extend test deadlines across various tests" This reverts commit 1885662. Signed-off-by: Eduardo Apolinario <eapolinario@users.noreply.github.com> * Only run generate decks in python_function_task if decks are enabled Signed-off-by: Eduardo Apolinario <eapolinario@users.noreply.github.com> * Remove breakpoint Signed-off-by: Eduardo Apolinario <eapolinario@users.noreply.github.com> * Fix test_deck.py tests to account for the number of expected decks (now that we're no longer writing decks unnecessarily) Signed-off-by: Eduardo Apolinario <eapolinario@users.noreply.github.com> * Increase deadline of eager tests Signed-off-by: Eduardo Apolinario <eapolinario@users.noreply.github.com> * Fix lint error Signed-off-by: Eduardo Apolinario <eapolinario@users.noreply.github.com> * test: update test assertions in test_deck.py - Add a patch to the `test_python_dependency_renderer` function - Include assertions for `numpy` and `1.21.0` in the test result - Update the `test_deck.py` file in the `tests/flytekit/unit/deck` directory Signed-off-by: jason.lai <jasonlai1218@gmail.com> * refactor: refactor Python code organization - Import `PythonDependencyRenderer` and `SourceCodeRenderer` in `PythonFunctionTask` from separate files - Modify the way `requirements_txt` is generated in `PythonDependencyRenderer` - Refactor the creation of the `table` variable in `PythonDependencyRenderer` to improve readability Signed-off-by: jason.lai <jasonlai1218@gmail.com> * docs: refactor project structure and improve user experience - Change the title of the deck from `Python Dependencies` to `Dependencies` - Update the error message in case of a subprocess error in fetching installed packages - Add a heading `Python Dependencies` above the table output in the HTML Signed-off-by: jason.lai <jasonlai1218@gmail.com> * Separate out tests that require hypothesis Signed-off-by: Eduardo Apolinario <eapolinario@users.noreply.github.com> --------- Signed-off-by: jason.lai <jasonlai1218@gmail.com> Signed-off-by: Eduardo Apolinario <eapolinario@users.noreply.github.com> Co-authored-by: Eduardo Apolinario <eapolinario@users.noreply.github.com> Signed-off-by: Jan Fiedler <jan@union.ai>
Tracking issue
Why are the changes needed?
In Python Dependency Deck, the version of the Python package currently being used can be displayed, which can make debugging easier.
What changes were proposed in this pull request?
PythonDependencyDeck
to deck.pyadd_deck
toFlyteContext
classHow was this patch tested?
Setup process
Screenshots
click copy button and paste result:
Check all the applicable boxes
Related PRs
flyteorg/flyteconsole#852
Docs link