- remove build specs - move pytest.ini into pyproject.toml - update readme - add pre-commit config - run formatters - add Makefile
195 lines
9.0 KiB
Plaintext
195 lines
9.0 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 10,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"ename": "ModuleNotFoundError",
|
|
"evalue": "No module named 'pprint.pprint'; 'pprint' is not a package",
|
|
"output_type": "error",
|
|
"traceback": [
|
|
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
|
"\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
|
|
"Cell \u001b[0;32mIn [10], line 4\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01myaml\u001b[39;00m\n\u001b[1;32m 3\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01myaml\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mloader\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m FullLoader\n\u001b[0;32m----> 4\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mpprint\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mpprint\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m \u001b[38;5;21;01mpp\u001b[39;00m\n",
|
|
"\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'pprint.pprint'; 'pprint' is not a package"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"import pyinfra\n",
|
|
"import yaml\n",
|
|
"from yaml.loader import FullLoader\n",
|
|
"import pprint"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 12,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"{'logging': 0,\n",
|
|
" 'mock_analysis_endpoint': 'http://127.0.0.1:5000',\n",
|
|
" 'service': {'operations': {'classify': {'input': {'extension': 'cls_in.gz',\n",
|
|
" 'multi': True,\n",
|
|
" 'subdir': ''},\n",
|
|
" 'output': {'extension': 'cls_out.gz',\n",
|
|
" 'subdir': ''}},\n",
|
|
" 'default': {'input': {'extension': 'IN.gz',\n",
|
|
" 'multi': False,\n",
|
|
" 'subdir': ''},\n",
|
|
" 'output': {'extension': 'OUT.gz',\n",
|
|
" 'subdir': ''}},\n",
|
|
" 'extract': {'input': {'extension': 'extr_in.gz',\n",
|
|
" 'multi': False,\n",
|
|
" 'subdir': ''},\n",
|
|
" 'output': {'extension': 'gz',\n",
|
|
" 'subdir': 'extractions'}},\n",
|
|
" 'rotate': {'input': {'extension': 'rot_in.gz',\n",
|
|
" 'multi': False,\n",
|
|
" 'subdir': ''},\n",
|
|
" 'output': {'extension': 'rot_out.gz',\n",
|
|
" 'subdir': ''}},\n",
|
|
" 'stream_pages': {'input': {'extension': 'pgs_in.gz',\n",
|
|
" 'multi': False,\n",
|
|
" 'subdir': ''},\n",
|
|
" 'output': {'extension': 'pgs_out.gz',\n",
|
|
" 'subdir': 'pages'}},\n",
|
|
" 'upper': {'input': {'extension': 'up_in.gz',\n",
|
|
" 'multi': False,\n",
|
|
" 'subdir': ''},\n",
|
|
" 'output': {'extension': 'up_out.gz',\n",
|
|
" 'subdir': ''}}},\n",
|
|
" 'response_formatter': 'identity'},\n",
|
|
" 'storage': {'aws': {'access_key': 'AKIA4QVP6D4LCDAGYGN2',\n",
|
|
" 'endpoint': 'https://s3.amazonaws.com',\n",
|
|
" 'region': '$STORAGE_REGION|\"eu-west-1\"',\n",
|
|
" 'secret_key': '8N6H1TUHTsbvW2qMAm7zZlJ63hMqjcXAsdN7TYED'},\n",
|
|
" 'azure': {'connection_string': 'DefaultEndpointsProtocol=https;AccountName=iqserdevelopment;AccountKey=4imAbV9PYXaztSOMpIyAClg88bAZCXuXMGJG0GA1eIBpdh2PlnFGoRBnKqLy2YZUSTmZ3wJfC7tzfHtuC6FEhQ==;EndpointSuffix=core.windows.net'},\n",
|
|
" 'bucket': 'pyinfra-test-bucket',\n",
|
|
" 'minio': {'access_key': 'root',\n",
|
|
" 'endpoint': 'http://127.0.0.1:9000',\n",
|
|
" 'region': None,\n",
|
|
" 'secret_key': 'password'}},\n",
|
|
" 'use_docker_fixture': 1,\n",
|
|
" 'webserver': {'host': '$SERVER_HOST|\"127.0.0.1\"',\n",
|
|
" 'mode': '$SERVER_MODE|production',\n",
|
|
" 'port': '$SERVER_PORT|5000'}}\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"\n",
|
|
"# Open the file and load the file\n",
|
|
"with open('./tests/config.yml') as f:\n",
|
|
" data = yaml.load(f, Loader=FullLoader)\n",
|
|
" pprint.pprint(data)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 22,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"import os\n",
|
|
"os.environ[\"STORAGE_BACKEND\"] = \"azure\"\n",
|
|
"\n",
|
|
"# always the same\n",
|
|
"os.environ[\"STORAGE_BUCKET_NAME\"] = \"pyinfra-test-bucket\"\n",
|
|
"\n",
|
|
"# s3\n",
|
|
"os.environ[\"STORAGE_ENDPOINT\"] = \"https://s3.amazonaws.com\"\n",
|
|
"os.environ[\"STORAGE_KEY\"] = \"AKIA4QVP6D4LCDAGYGN2\"\n",
|
|
"os.environ[\"STORAGE_SECRET\"] = \"8N6H1TUHTsbvW2qMAm7zZlJ63hMqjcXAsdN7TYED\"\n",
|
|
"os.environ[\"STORAGE_REGION\"] = \"eu-west-1\"\n",
|
|
"\n",
|
|
"# aks\n",
|
|
"os.environ[\"STORAGE_AZURECONNECTIONSTRING\"] = \"DefaultEndpointsProtocol=https;AccountName=iqserdevelopment;AccountKey=4imAbV9PYXaztSOMpIyAClg88bAZCXuXMGJG0GA1eIBpdh2PlnFGoRBnKqLy2YZUSTmZ3wJfC7tzfHtuC6FEhQ==;EndpointSuffix=core.windows.net\""
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 23,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"ename": "Exception",
|
|
"evalue": "Unknown storage backend 'aks'.",
|
|
"output_type": "error",
|
|
"traceback": [
|
|
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
|
"\u001b[0;31mException\u001b[0m Traceback (most recent call last)",
|
|
"Cell \u001b[0;32mIn [23], line 2\u001b[0m\n\u001b[1;32m 1\u001b[0m config \u001b[38;5;241m=\u001b[39m pyinfra\u001b[38;5;241m.\u001b[39mconfig\u001b[38;5;241m.\u001b[39mget_config()\n\u001b[0;32m----> 2\u001b[0m storage \u001b[38;5;241m=\u001b[39m \u001b[43mpyinfra\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mstorage\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget_storage\u001b[49m\u001b[43m(\u001b[49m\u001b[43mconfig\u001b[49m\u001b[43m)\u001b[49m\n",
|
|
"File \u001b[0;32m~/dev/pyinfra/pyinfra/storage/storage.py:15\u001b[0m, in \u001b[0;36mget_storage\u001b[0;34m(config)\u001b[0m\n\u001b[1;32m 13\u001b[0m storage \u001b[39m=\u001b[39m get_azure_storage(config)\n\u001b[1;32m 14\u001b[0m \u001b[39melse\u001b[39;00m:\n\u001b[0;32m---> 15\u001b[0m \u001b[39mraise\u001b[39;00m \u001b[39mException\u001b[39;00m(\u001b[39mf\u001b[39m\u001b[39m\"\u001b[39m\u001b[39mUnknown storage backend \u001b[39m\u001b[39m'\u001b[39m\u001b[39m{\u001b[39;00mconfig\u001b[39m.\u001b[39mstorage_backend\u001b[39m}\u001b[39;00m\u001b[39m'\u001b[39m\u001b[39m.\u001b[39m\u001b[39m\"\u001b[39m)\n\u001b[1;32m 17\u001b[0m \u001b[39mreturn\u001b[39;00m storage\n",
|
|
"\u001b[0;31mException\u001b[0m: Unknown storage backend 'aks'."
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"config = pyinfra.config.get_config()\n",
|
|
"storage = pyinfra.storage.get_storage(config)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 21,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"False"
|
|
]
|
|
},
|
|
"execution_count": 21,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"storage.has_bucket(config.storage_bucket)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": []
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "Python 3.8.13 ('pyinfra-TboPpZ8z-py3.8')",
|
|
"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.13"
|
|
},
|
|
"orig_nbformat": 4,
|
|
"vscode": {
|
|
"interpreter": {
|
|
"hash": "10d7419af5ea6dfec0078ebc9d6fa1a9383fe9894853f90dc7d29a81b3de2c78"
|
|
}
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 2
|
|
}
|