-
Notifications
You must be signed in to change notification settings - Fork 301
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Issue-3617] Enables FlyteFiles, FlyteDirectors, and StructuredDatase…
…ts inputs in papermill plugin (#1612)
- Loading branch information
1 parent
a7391c9
commit 7409889
Showing
5 changed files
with
236 additions
and
11 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
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
100 changes: 100 additions & 0 deletions
100
plugins/flytekit-papermill/tests/testdata/nb-types.ipynb
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,100 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": { | ||
"tags": [ | ||
"parameters" | ||
] | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"ff = None\n", | ||
"fd = None\n", | ||
"sd = None" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import os\n", | ||
"import pandas as pd\n", | ||
"from flytekitplugins.papermill import (\n", | ||
" load_flytefile, load_flytedirectory, load_structureddataset,\n", | ||
" record_outputs\n", | ||
")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"ff = load_flytefile(ff)\n", | ||
"fd = load_flytedirectory(fd)\n", | ||
"sd = load_structureddataset(sd)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# read file\n", | ||
"with open(ff.download(), 'r') as f:\n", | ||
" text = f.read()\n", | ||
" assert text == \"abc\", \"Text does not match\"\n", | ||
"\n", | ||
"# check file inside directory\n", | ||
"with open(os.path.join(fd.download(),\"file.txt\"), 'r') as f:\n", | ||
" text = f.read()\n", | ||
" assert text == \"abc\", \"Text does not match\"\n", | ||
"\n", | ||
"# check dataset\n", | ||
"df = sd.open(pd.DataFrame).all()\n", | ||
"expected = pd.DataFrame({\"a\": [1, 2], \"b\": [3, 4]})\n", | ||
"assert df.equals(expected), \"Dataframes do not match\"" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"tags": [ | ||
"outputs" | ||
] | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"record_outputs(success=True)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.10.10" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 4 | ||
} |