Skip to content
This repository has been archived by the owner on Feb 22, 2024. It is now read-only.

Commit

Permalink
Added notebooks for tests (#142)
Browse files Browse the repository at this point in the history
Adds test notebooks for #104 .
  • Loading branch information
kravetsmic authored Mar 15, 2023
1 parent 050013d commit 4e0087a
Show file tree
Hide file tree
Showing 26 changed files with 3,166 additions and 2 deletions.
4 changes: 2 additions & 2 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ click==8.1.3
# uvicorn
defusedxml==0.7.1
# via nbconvert
fastapi==0.92.0
fastapi==0.93.0
# via unstructured-api-tools (setup.py)
fastjsonschema==2.16.3
# via nbformat
Expand Down Expand Up @@ -78,7 +78,7 @@ pkgutil-resolve-name==1.3.10
# via jsonschema
platformdirs==3.1.0
# via jupyter-core
pydantic==1.10.5
pydantic==1.10.6
# via fastapi
pygments==2.14.0
# via nbconvert
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"cells": [
{
"cell_type": "markdown",
"source": [
"# File Processing Pipeline"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# pipeline-api\n",
"def pipeline_api(\n",
" file\n",
"):\n",
" return {\"silly_result\": ' : '.join([str(len(file.read()))])}"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'silly_result': '17'}\n"
]
}
],
"source": [
"import tempfile\n",
"with tempfile.TemporaryFile() as fp:\n",
" fp.write(b'This is some data')\n",
" fp.seek(0)\n",
" print(pipeline_api(fp))"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "python3",
"language": "python",
"name": "python3"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"cells": [
{
"cell_type": "markdown",
"source": [
"# File Processing Pipeline"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# pipeline-api\n",
"def pipeline_api(\n",
" file, response_type=\"text/csv\", response_schema=\"isd\"\n",
"):\n",
" return {\"silly_result\": ' : '.join([str(len(file.read())), str(response_type), str(response_schema)])}"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'silly_result': '17 : text/csv : isd'}\n"
]
}
],
"source": [
"import tempfile\n",
"with tempfile.TemporaryFile() as fp:\n",
" fp.write(b'This is some data')\n",
" fp.seek(0)\n",
" print(pipeline_api(fp, \"text/csv\", \"isd\"))"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "python3",
"language": "python",
"name": "python3"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"cells": [
{
"cell_type": "markdown",
"source": [
"# File Processing Pipeline"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# pipeline-api\n",
"def pipeline_api(\n",
" file,\n",
" file_content_type=None,\n",
" response_type=\"application/json\",\n",
" response_schema=\"labelstudio\",\n",
" m_input1=[]\n",
"):\n",
" return {\"silly_result\": ' : '.join([\n",
" str(len(file.read())),\n",
" str(file_content_type),\n",
" str(response_type),\n",
" str(response_schema),\n",
" str(m_input1)\n",
" ])}"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'silly_result': \"17 : None : application/json : isd : ['input1', 'input2']\"}\n"
]
}
],
"source": [
"import tempfile\n",
"with tempfile.TemporaryFile() as fp:\n",
" fp.write(b'This is some data')\n",
" fp.seek(0)\n",
" print(\n",
" pipeline_api(\n",
" fp,\n",
" None,\n",
" \"application/json\",\n",
" \"isd\",\n",
" [\"input1\", \"input2\"]\n",
" )\n",
" )"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "python3",
"language": "python",
"name": "python3"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
"cells": [
{
"cell_type": "markdown",
"source": [
"# File Processing Pipeline"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# pipeline-api\n",
"def pipeline_api(\n",
" file,\n",
" file_content_type=None,\n",
" response_type=\"application/json\",\n",
" response_schema=\"labelstudio\",\n",
" m_input1=[],\n",
" m_input2=[],\n",
"):\n",
" return {\"silly_result\": ' : '.join([\n",
" str(len(file.read())),\n",
" str(file_content_type),\n",
" str(response_type),\n",
" str(response_schema),\n",
" str(m_input1),\n",
" str(m_input2),\n",
" ])}"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'silly_result': \"17 : None : application/json : isd : ['input1', 'input2'] : ['m_input2']\"}\n"
]
}
],
"source": [
"import tempfile\n",
"with tempfile.TemporaryFile() as fp:\n",
" fp.write(b'This is some data')\n",
" fp.seek(0)\n",
" print(\n",
" pipeline_api(\n",
" fp,\n",
" None,\n",
" \"application/json\",\n",
" \"isd\",\n",
" [\"input1\", \"input2\"],\n",
" [\"m_input2\"]\n",
" )\n",
" )"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "python3",
"language": "python",
"name": "python3"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Text Processing Pipeline"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# pipeline-api\n",
"def pipeline_api(\n",
" text,\n",
"):\n",
" return {\"silly_result\": ' : '.join([str(len(text)), text])}"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'silly_result': '9 : some text'}\n"
]
}
],
"source": [
"print(pipeline_api(\"some text\"))"
]
}
],
"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.8.15"
}
},
"nbformat": 4,
"nbformat_minor": 1
}
Loading

0 comments on commit 4e0087a

Please sign in to comment.