Skip to content

Commit

Permalink
add test notebook
Browse files Browse the repository at this point in the history
Signed-off-by: esad <[email protected]>
  • Loading branch information
peridotml committed May 9, 2023
1 parent 175989b commit 41c98ee
Showing 1 changed file with 100 additions and 0 deletions.
100 changes: 100 additions & 0 deletions plugins/flytekit-papermill/tests/testdata/nb-types.ipynb
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",
" read_flytefile, read_flytedirectory, read_structureddataset,\n",
" record_outputs\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ff = read_flytefile(ff)\n",
"fd = read_flytedirectory(fd)\n",
"sd = read_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
}

0 comments on commit 41c98ee

Please sign in to comment.