Files
wehub-resource-sync 6b7e6b44f1
gh-pages / build (push) Waiting to run
Python Publish (pypi) / Upload release to PyPI (push) Waiting to run
Spellcheck / spellcheck (push) Waiting to run
Python Build and Type Check / python-ci (ubuntu-latest, 3.11) (push) Has been cancelled
Python Build and Type Check / python-ci (ubuntu-latest, 3.13) (push) Has been cancelled
Python Build and Type Check / python-ci (windows-latest, 3.11) (push) Has been cancelled
Python Build and Type Check / python-ci (windows-latest, 3.13) (push) Has been cancelled
Python Integration Tests / python-ci (ubuntu-latest, 3.13) (push) Has been cancelled
Python Integration Tests / python-ci (windows-latest, 3.13) (push) Has been cancelled
Python Notebook Tests / python-ci (ubuntu-latest, 3.13) (push) Has been cancelled
Python Notebook Tests / python-ci (windows-latest, 3.13) (push) Has been cancelled
Python Smoke Tests / python-ci (ubuntu-latest, 3.13) (push) Has been cancelled
Python Smoke Tests / python-ci (windows-latest, 3.13) (push) Has been cancelled
Python Unit Tests / python-ci (ubuntu-latest, 3.13) (push) Has been cancelled
Python Unit Tests / python-ci (windows-latest, 3.13) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:37:31 +08:00

84 lines
2.1 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "44010ee7",
"metadata": {},
"outputs": [],
"source": [
"# Copyright (c) 2026 Microsoft Corporation.\n",
"# Licensed under the MIT License."
]
},
{
"cell_type": "markdown",
"id": "8df57dd3",
"metadata": {},
"source": [
"## Basic storage example\n",
"\n",
"This example creates a file storage system using the GraphRAG storage package's configuration system. The example shows setting up file storage in a specified directory and demonstrates basic storage operations like setting and getting key-value pairs."
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "9b5d302c",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Saving and retrieving a value from storage...\n",
"Setting key 'my_key' to 'value'\n",
"Getting key 'my_key':\n",
"value\n"
]
}
],
"source": [
"from graphrag_storage import StorageConfig, StorageType, create_storage\n",
"\n",
"\n",
"async def run():\n",
" \"\"\"Demonstrate basic storage operations.\"\"\"\n",
" storage = create_storage(StorageConfig(type=StorageType.File, base_dir=\"output\"))\n",
"\n",
" print(\"Saving and retrieving a value from storage...\")\n",
" print(\"Setting key 'my_key' to 'value'\")\n",
"\n",
" await storage.set(\"my_key\", \"value\")\n",
" print(\"Getting key 'my_key':\")\n",
" print(await storage.get(\"my_key\"))\n",
"\n",
"\n",
"if __name__ == \"__main__\":\n",
" await run()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.12.9"
}
},
"nbformat": 4,
"nbformat_minor": 5
}