pocketflow/cookbook/parallel_exp.ipynb

105 lines
2.8 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "ki9N8iqRxu0I",
"outputId": "fd1628a5-d2a4-44a4-89b4-31151d21c8f3"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Collecting pocketflow\n",
" Downloading pocketflow-0.0.1-py3-none-any.whl.metadata (270 bytes)\n",
"Downloading pocketflow-0.0.1-py3-none-any.whl (3.3 kB)\n",
"Installing collected packages: pocketflow\n",
"Successfully installed pocketflow-0.0.1\n"
]
}
],
"source": [
"pip install pocketflow"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"id": "mHZpGv8txy4L"
},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "zfnhW3f-0W6o",
"outputId": "3737e2e5-5cae-4c6b-a894-e880cf338d1f"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"=== Running Sequential (AsyncBatchNode) ===\n",
"[Sequential] Summarizing file1.txt...\n",
"[Sequential] Summarizing file2.txt...\n",
"[Sequential] Summarizing file3.txt...\n",
"\n",
"=== Running Parallel (AsyncParallelBatchNode) ===\n",
"[Parallel] Summarizing file1.txt...\n",
"[Parallel] Summarizing file2.txt...\n",
"[Parallel] Summarizing file3.txt...\n",
"\n",
"--- Results ---\n",
"Sequential Summaries: {'file1.txt': 'Summarized(13 chars)', 'file2.txt': 'Summarized(13 chars)', 'file3.txt': 'Summarized(13 chars)'}\n",
"Parallel Summaries: {'file1.txt': 'Summarized(13 chars)', 'file2.txt': 'Summarized(13 chars)', 'file3.txt': 'Summarized(13 chars)'}\n",
"Sequential took: 3.00 seconds\n",
"Parallel took: 1.00 seconds\n"
]
}
],
"source": [
"# if in a notebook\n",
"await main()\n",
"\n",
"asyncio.run(main())"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "ystwa74D0Z_k"
},
"outputs": [],
"source": []
}
],
"metadata": {
"colab": {
"provenance": []
},
"kernelspec": {
"display_name": "Python 3",
"name": "python3"
},
"language_info": {
"name": "python"
}
},
"nbformat": 4,
"nbformat_minor": 0
}