Merge pull request 'Zaktualizowano wywołania pythona' (#28) from tzietkiewicz/aitech-ium:master into master

Reviewed-on: AITech/aitech-ium#28
This commit is contained in:
Tomasz Zietkiewicz 2022-04-25 11:24:01 +02:00
commit ea4a2b110d
7 changed files with 286 additions and 186 deletions

View File

@ -2,7 +2,6 @@
"cells": [
{
"cell_type": "markdown",
"id": "ac87c554",
"metadata": {},
"source": [
"# Środowisko wykorzystywane na zajęciach"
@ -10,7 +9,6 @@
},
{
"cell_type": "markdown",
"id": "167416f3",
"metadata": {},
"source": [
"Certificat SSL dla strony: https://letsencrypt.org/\n",
@ -57,7 +55,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "60970c71",
"metadata": {},
"outputs": [],
"source": []
@ -79,7 +76,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.1"
"version": "3.6.9"
}
},
"nbformat": 4,

View File

@ -494,7 +494,7 @@
"celltoolbar": "Slideshow",
"email": "tomasz.zietkiewicz@amu.edu.pl",
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
@ -509,7 +509,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.10"
"version": "3.6.9"
},
"slideshow": {
"slide_type": "slide"

View File

@ -594,7 +594,7 @@
"celltoolbar": "Slideshow",
"email": "tomasz.zietkiewicz@amu.edu.pl",
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
@ -609,7 +609,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.10"
"version": "3.6.9"
},
"slideshow": {
"slide_type": "slide"

View File

@ -227,7 +227,7 @@
"celltoolbar": "Slideshow",
"email": "tomasz.zietkiewicz@amu.edu.pl",
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
@ -242,7 +242,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.10"
"version": "3.6.9"
},
"slideshow": {
"slide_type": "slide"

View File

@ -100,7 +100,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 4,
"metadata": {
"slideshow": {
"slide_type": "slide"
@ -112,40 +112,74 @@
"output_type": "stream",
"text": [
"Collecting sacred\n",
" Downloading sacred-0.8.2-py2.py3-none-any.whl (106 kB)\n",
"\u001b[K |████████████████████████████████| 106 kB 1.7 MB/s eta 0:00:01\n",
"\u001b[?25hRequirement already satisfied: packaging>=18.0 in /media/tomek/Linux_data/home/tomek/anaconda3/lib/python3.8/site-packages (from sacred) (20.4)\n",
"Collecting jsonpickle<2.0,>=1.2\n",
" Downloading jsonpickle-1.5.2-py2.py3-none-any.whl (37 kB)\n",
"Requirement already satisfied: GitPython in /media/tomek/Linux_data/home/tomek/anaconda3/lib/python3.8/site-packages (from sacred) (3.1.14)\n",
"Collecting munch<3.0,>=2.0.2\n",
" Downloading munch-2.5.0-py2.py3-none-any.whl (10 kB)\n",
"Collecting py-cpuinfo>=4.0\n",
" Downloading py-cpuinfo-8.0.0.tar.gz (99 kB)\n",
"\u001b[K |████████████████████████████████| 99 kB 2.7 MB/s eta 0:00:011\n",
"\u001b[?25hCollecting docopt<1.0,>=0.3\n",
" Downloading docopt-0.6.2.tar.gz (25 kB)\n",
"Requirement already satisfied: wrapt<2.0,>=1.0 in /media/tomek/Linux_data/home/tomek/anaconda3/lib/python3.8/site-packages (from sacred) (1.11.2)\n",
"Requirement already satisfied: colorama>=0.4 in /media/tomek/Linux_data/home/tomek/anaconda3/lib/python3.8/site-packages (from sacred) (0.4.4)\n",
"Requirement already satisfied: pyparsing>=2.0.2 in /media/tomek/Linux_data/home/tomek/anaconda3/lib/python3.8/site-packages (from packaging>=18.0->sacred) (2.4.7)\n",
"Requirement already satisfied: six in /media/tomek/Linux_data/home/tomek/anaconda3/lib/python3.8/site-packages (from packaging>=18.0->sacred) (1.15.0)\n",
"Requirement already satisfied: gitdb<5,>=4.0.1 in /media/tomek/Linux_data/home/tomek/anaconda3/lib/python3.8/site-packages (from GitPython->sacred) (4.0.5)\n",
"Requirement already satisfied: smmap<4,>=3.0.1 in /media/tomek/Linux_data/home/tomek/anaconda3/lib/python3.8/site-packages (from gitdb<5,>=4.0.1->GitPython->sacred) (3.0.5)\n",
"\u001b[33m Cache entry deserialization failed, entry ignored\u001b[0m\n",
"\u001b[33m Cache entry deserialization failed, entry ignored\u001b[0m\n",
" Downloading https://files.pythonhosted.org/packages/f4/8c/b99f668e8ca9747dcd374bb46cac808e58f3cb8e446df1b3e667f6be9778/sacred-0.8.2-py2.py3-none-any.whl (106kB)\n",
"\u001b[K 100% |████████████████████████████████| 112kB 1.2MB/s ta 0:00:01\n",
"\u001b[?25hCollecting py-cpuinfo>=4.0 (from sacred)\n",
"\u001b[33m Cache entry deserialization failed, entry ignored\u001b[0m\n",
"\u001b[33m Cache entry deserialization failed, entry ignored\u001b[0m\n",
" Downloading https://files.pythonhosted.org/packages/e6/ba/77120e44cbe9719152415b97d5bfb29f4053ee987d6cb63f55ce7d50fadc/py-cpuinfo-8.0.0.tar.gz (99kB)\n",
"\u001b[K 100% |████████████████████████████████| 102kB 1.4MB/s a 0:00:01\n",
"\u001b[?25hCollecting wrapt<2.0,>=1.0 (from sacred)\n",
"\u001b[33m Cache entry deserialization failed, entry ignored\u001b[0m\n",
" Downloading https://files.pythonhosted.org/packages/ba/8c/3d3dff02ae905157ba417b801f4a7aa4e6fedbc43882e9c765b7aae438ac/wrapt-1.14.0-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (74kB)\n",
"\u001b[K 100% |████████████████████████████████| 81kB 2.0MB/s ta 0:00:01\n",
"\u001b[?25hCollecting jsonpickle<2.0,>=1.2 (from sacred)\n",
"\u001b[33m Cache entry deserialization failed, entry ignored\u001b[0m\n",
"\u001b[33m Cache entry deserialization failed, entry ignored\u001b[0m\n",
" Downloading https://files.pythonhosted.org/packages/e9/ec/35910cf6ab87f8a013036f01f732f871a23b6058123a7bd0c7b08fbbc937/jsonpickle-1.5.2-py2.py3-none-any.whl\n",
"Collecting colorama>=0.4 (from sacred)\n",
"\u001b[33m Cache entry deserialization failed, entry ignored\u001b[0m\n",
"\u001b[33m Cache entry deserialization failed, entry ignored\u001b[0m\n",
" Downloading https://files.pythonhosted.org/packages/44/98/5b86278fbbf250d239ae0ecb724f8572af1c91f4a11edf4d36a206189440/colorama-0.4.4-py2.py3-none-any.whl\n",
"Collecting munch<3.0,>=2.0.2 (from sacred)\n",
"\u001b[33m Cache entry deserialization failed, entry ignored\u001b[0m\n",
"\u001b[33m Cache entry deserialization failed, entry ignored\u001b[0m\n",
" Downloading https://files.pythonhosted.org/packages/cc/ab/85d8da5c9a45e072301beb37ad7f833cd344e04c817d97e0cc75681d248f/munch-2.5.0-py2.py3-none-any.whl\n",
"Collecting packaging>=18.0 (from sacred)\n",
"\u001b[33m Cache entry deserialization failed, entry ignored\u001b[0m\n",
" Using cached https://files.pythonhosted.org/packages/05/8e/8de486cbd03baba4deef4142bd643a3e7bbe954a784dc1bb17142572d127/packaging-21.3-py3-none-any.whl\n",
"Collecting GitPython (from sacred)\n",
"\u001b[33m Cache entry deserialization failed, entry ignored\u001b[0m\n",
" Downloading https://files.pythonhosted.org/packages/55/60/f884f01eef2a7255875862ec1b12d57d74113ec6e8d9e16c4d254cd6aa3c/GitPython-3.1.20-py3-none-any.whl (178kB)\n",
"\u001b[K 100% |████████████████████████████████| 184kB 1.9MB/s ta 0:00:01\n",
"\u001b[?25hCollecting docopt<1.0,>=0.3 (from sacred)\n",
"\u001b[33m Cache entry deserialization failed, entry ignored\u001b[0m\n",
"\u001b[33m Cache entry deserialization failed, entry ignored\u001b[0m\n",
" Downloading https://files.pythonhosted.org/packages/a2/55/8f8cab2afd404cf578136ef2cc5dfb50baa1761b68c9da1fb1e4eed343c9/docopt-0.6.2.tar.gz\n",
"Collecting importlib-metadata; python_version < \"3.8\" (from jsonpickle<2.0,>=1.2->sacred)\n",
"\u001b[33m Cache entry deserialization failed, entry ignored\u001b[0m\n",
" Using cached https://files.pythonhosted.org/packages/a0/a1/b153a0a4caf7a7e3f15c2cd56c7702e2cf3d89b1b359d1f1c5e59d68f4ce/importlib_metadata-4.8.3-py3-none-any.whl\n",
"Collecting six (from munch<3.0,>=2.0.2->sacred)\n",
" Using cached https://files.pythonhosted.org/packages/d9/5a/e7c31adbe875f2abbb91bd84cf2dc52d792b5a01506781dbcf25c91daf11/six-1.16.0-py2.py3-none-any.whl\n",
"Collecting pyparsing!=3.0.5,>=2.0.2 (from packaging>=18.0->sacred)\n",
"\u001b[33m Cache entry deserialization failed, entry ignored\u001b[0m\n",
" Using cached https://files.pythonhosted.org/packages/d9/41/d9cfb4410589805cd787f8a82cddd13142d9bf7449d12adf2d05a4a7d633/pyparsing-3.0.8-py3-none-any.whl\n",
"Collecting gitdb<5,>=4.0.1 (from GitPython->sacred)\n",
" Downloading https://files.pythonhosted.org/packages/a3/7c/5d747655049bfbf75b5fcec57c8115896cb78d6fafa84f6d3ef4c0f13a98/gitdb-4.0.9-py3-none-any.whl (63kB)\n",
"\u001b[K 100% |████████████████████████████████| 71kB 1.9MB/s ta 0:00:01\n",
"\u001b[?25hCollecting typing-extensions>=3.7.4.3; python_version < \"3.10\" (from GitPython->sacred)\n",
" Using cached https://files.pythonhosted.org/packages/45/6b/44f7f8f1e110027cf88956b59f2fad776cca7e1704396d043f89effd3a0e/typing_extensions-4.1.1-py3-none-any.whl\n",
"Collecting zipp>=0.5 (from importlib-metadata; python_version < \"3.8\"->jsonpickle<2.0,>=1.2->sacred)\n",
"\u001b[33m Cache entry deserialization failed, entry ignored\u001b[0m\n",
" Using cached https://files.pythonhosted.org/packages/bd/df/d4a4974a3e3957fd1c1fa3082366d7fff6e428ddb55f074bf64876f8e8ad/zipp-3.6.0-py3-none-any.whl\n",
"Collecting smmap<6,>=3.0.1 (from gitdb<5,>=4.0.1->GitPython->sacred)\n",
"\u001b[33m Cache entry deserialization failed, entry ignored\u001b[0m\n",
" Downloading https://files.pythonhosted.org/packages/6d/01/7caa71608bc29952ae09b0be63a539e50d2484bc37747797a66a60679856/smmap-5.0.0-py3-none-any.whl\n",
"Building wheels for collected packages: py-cpuinfo, docopt\n",
" Building wheel for py-cpuinfo (setup.py) ... \u001b[?25ldone\n",
"\u001b[?25h Created wheel for py-cpuinfo: filename=py_cpuinfo-8.0.0-py3-none-any.whl size=22245 sha256=556a8ea1e899c40b6266eab7562141327aecacfb2cdb6509279a85c91bf729b2\n",
" Stored in directory: /home/tomek/.cache/pip/wheels/57/cb/6d/bab2257f26c5be4a96ff65c3d2a7122c96529b73773ee37f36\n",
" Building wheel for docopt (setup.py) ... \u001b[?25ldone\n",
"\u001b[?25h Created wheel for docopt: filename=docopt-0.6.2-py2.py3-none-any.whl size=13704 sha256=a9cd4cc934499c413a39353a865132382f2f2b230f614d2a2a495b1ccc0b2dd4\n",
" Stored in directory: /home/tomek/.cache/pip/wheels/56/ea/58/ead137b087d9e326852a851351d1debf4ada529b6ac0ec4e8c\n",
" Running setup.py bdist_wheel for py-cpuinfo ... \u001b[?25ldone\n",
"\u001b[?25h Stored in directory: /home/tomek/.cache/pip/wheels/2e/15/f5/aa2a056d223903b52cf4870134e3a01df0c723816835dd08db\n",
" Running setup.py bdist_wheel for docopt ... \u001b[?25ldone\n",
"\u001b[?25h Stored in directory: /home/tomek/.cache/pip/wheels/9b/04/dd/7daf4150b6d9b12949298737de9431a324d4b797ffd63f526e\n",
"Successfully built py-cpuinfo docopt\n",
"Installing collected packages: jsonpickle, munch, py-cpuinfo, docopt, sacred\n",
"Successfully installed docopt-0.6.2 jsonpickle-1.5.2 munch-2.5.0 py-cpuinfo-8.0.0 sacred-0.8.2\n"
"Installing collected packages: py-cpuinfo, wrapt, typing-extensions, zipp, importlib-metadata, jsonpickle, colorama, six, munch, pyparsing, packaging, smmap, gitdb, GitPython, docopt, sacred\n",
"Successfully installed GitPython-3.1.20 colorama-0.4.4 docopt-0.6.2 gitdb-4.0.9 importlib-metadata-4.8.3 jsonpickle-1.5.2 munch-2.5.0 packaging-21.3 py-cpuinfo-8.0.0 pyparsing-3.0.8 sacred-0.8.2 six-1.16.0 smmap-5.0.0 typing-extensions-4.1.1 wrapt-1.14.0 zipp-3.6.0\n"
]
}
],
"source": [
"!pip install sacred"
"!pip3 install sacred"
]
},
{
@ -161,15 +195,23 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 4,
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Overwriting sacred_hello.py\n"
]
}
],
"source": [
"# %load sacred_hello.py\n",
"%%writefile sacred_hello.py\n",
"from sacred import Experiment\n",
"\n",
"ex = Experiment()\n",
@ -181,10 +223,10 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 14,
"metadata": {
"slideshow": {
"slide_type": "slide"
"slide_type": "fragment"
}
},
"outputs": [
@ -201,7 +243,7 @@
}
],
"source": [
"!python IUM_07/sacred_hello.py"
"!python3 IUM_07/sacred_hello.py"
]
},
{
@ -214,7 +256,7 @@
"source": [
"##### Co się dzieje w kodzie powyżej?\n",
"1. Tworzymy obiekt klasy Experiment\n",
"2. Dekorujemy funkcję \"ma_main\" dekoratorem [automain](https://sacred.readthedocs.io/en/stable/apidoc.html#sacred.Experiment.automain)\n",
"2. Dekorujemy funkcję \"my_main\" dekoratorem [automain](https://sacred.readthedocs.io/en/stable/apidoc.html#sacred.Experiment.automain)\n",
" Dzięki temu:\n",
" - otrzymujemy interfejs CLI, m.in. do kontrolowania poziomu logowania, przekazywania parametrów itp.\n",
" - oznaczamy funkcję \"my_main\" jako główną funkcję, która będzie wywoływana podczas wykonywania eksperymentu\n",
@ -235,10 +277,10 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 15,
"metadata": {
"slideshow": {
"slide_type": "slide"
"slide_type": "fragment"
}
},
"outputs": [
@ -316,7 +358,7 @@
}
],
"source": [
"!python IUM_07/sacred_hello.py -h"
"!python3 IUM_07/sacred_hello.py -h"
]
},
{
@ -332,7 +374,7 @@
" - Ułatwiają przekazywanie parametrów - zmienne z konfiguracji są wstrzykiwane do funkcji wywoływanych \n",
" - Mogą być automatycznie zapisywane (dzięki czemu możemy śledzić jak zmieniały się parametry i jaki miały wpływ na wyniki)\n",
" - Konfigurację można stworzyć w jeden z 3 sposobów:\n",
" - używając config scopes (zasięg konfiguracji)\n",
" - używając config scopes (z dekoratorem `@config`)\n",
" - jako słownik\n",
" - wczytując ją z pliku"
]
@ -346,12 +388,12 @@
},
"source": [
"### Konfiguracje - config scopes\n",
"Jeśli oznaczymy jakąś funkcję dekoratorem `config`, to zostanie ona uruchoniona przed wywołaniem eksperymentu i wszystkie jej lokalne zmienne, które da sie zserializować jako json, zostaną dodane do konfiguracji. Potem ich wartości zostaną wstrzyknięte "
"Jeśli oznaczymy jakąś funkcję dekoratorem `@config`, to zostanie ona uruchoniona przed wywołaniem eksperymentu i wszystkie jej lokalne zmienne, które da się zserializować jako json, zostaną dodane do konfiguracji. Potem ich wartości zostaną wstrzyknięte do innych funkcji wywoływanych w eksperymencie. "
]
},
{
"cell_type": "code",
"execution_count": 91,
"execution_count": 5,
"metadata": {
"slideshow": {
"slide_type": "slide"
@ -364,7 +406,7 @@
"exint = Experiment(\"sacred_scopes\", interactive=True) #Jeśli wykonujemy interaktywnie (w konsoli Pythona albo w Jupyter):\n",
"# - musimy podać nazwę eksperymentu (domyślnie jako nazwa używana jest nazwa pliku źródłowego)\n",
"# - musimy dodać parametr \"interactive=True\"\n",
"# - zamiast \"automain\" używamy parametru \"main\"\n",
"# - zamiast dekoratora \"@ex.automain\" używamy \"@ex.main\"\n",
"\n",
"@exint.config\n",
"def my_config():\n",
@ -380,10 +422,10 @@
},
{
"cell_type": "code",
"execution_count": 92,
"execution_count": 6,
"metadata": {
"slideshow": {
"slide_type": "slide"
"slide_type": "fragment"
}
},
"outputs": [
@ -407,10 +449,10 @@
{
"data": {
"text/plain": [
"<sacred.run.Run at 0x7f423da33160>"
"<sacred.run.Run at 0x7f641e9ddba8>"
]
},
"execution_count": 92,
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
@ -432,10 +474,10 @@
},
{
"cell_type": "code",
"execution_count": 93,
"execution_count": 19,
"metadata": {
"slideshow": {
"slide_type": "slide"
"slide_type": "fragment"
}
},
"outputs": [
@ -445,7 +487,7 @@
"{'recipient': 'Świecie', 'greeting': 'Witaj', 'message': 'Witaj Świecie!'}"
]
},
"execution_count": 93,
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
@ -471,7 +513,7 @@
"execution_count": null,
"metadata": {
"slideshow": {
"slide_type": "slide"
"slide_type": "fragment"
}
},
"outputs": [],
@ -494,10 +536,10 @@
},
{
"cell_type": "code",
"execution_count": 88,
"execution_count": 21,
"metadata": {
"slideshow": {
"slide_type": "slide"
"slide_type": "fragment"
}
},
"outputs": [
@ -514,15 +556,15 @@
}
],
"source": [
"!python IUM_07/sacred_scopes.py with 'recipient=Przygodo'"
"!python3 IUM_07/sacred_scopes.py with 'recipient=Przygodo'"
]
},
{
"cell_type": "code",
"execution_count": 89,
"execution_count": 24,
"metadata": {
"slideshow": {
"slide_type": "slide"
"slide_type": "fragment"
}
},
"outputs": [
@ -536,13 +578,13 @@
" greeting = 'Witaj'\r\n",
" message = 'Witaj Świecie!'\r\n",
" recipient = 'Świecie'\r\n",
" seed = 29744255 \u001b[2m# the random seed for this experiment\u001b[0m\r\n",
" seed = 539001265 \u001b[2m# the random seed for this experiment\u001b[0m\r\n",
"INFO - sacred_scopes - Completed after 0:00:00\r\n"
]
}
],
"source": [
"!python IUM_07/sacred_scopes.py print_config"
"!python3 IUM_07/sacred_scopes.py print_config"
]
},
{
@ -550,7 +592,7 @@
"execution_count": 90,
"metadata": {
"slideshow": {
"slide_type": "slide"
"slide_type": "fragment"
}
},
"outputs": [
@ -586,13 +628,24 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 7,
"metadata": {
"slideshow": {
"slide_type": "slide"
"slide_type": "fragment"
}
},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"{'recipient': 'samotności', 'greeting': 'Żegnaj'}"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# %load IUM_07/config.json\n",
"{\n",
@ -636,7 +689,7 @@
"execution_count": 120,
"metadata": {
"slideshow": {
"slide_type": "slide"
"slide_type": "fragment"
}
},
"outputs": [
@ -667,7 +720,7 @@
"execution_count": 121,
"metadata": {
"slideshow": {
"slide_type": "slide"
"slide_type": "fragment"
}
},
"outputs": [
@ -702,7 +755,7 @@
"execution_count": 124,
"metadata": {
"slideshow": {
"slide_type": "slide"
"slide_type": "fragment"
}
},
"outputs": [
@ -736,9 +789,9 @@
}
},
"source": [
"#### Wtrzykiwanie zależności\n",
"#### Wstrzykiwanie zależności\n",
" - Oprócz funkcji głównej, wartości z konfiguracji są też wstrzykiwane do funkcji udekorowanych dekoratorem `@ex.capture`\n",
" - Możemy skorzystać w nich ze specjalnych parametrów, np.:\n",
" - Możemy korzystać w nich ze specjalnych parametrów, np.:\n",
" - `_log` - daje nam dostęp do obiektu logera (więcej: [logowanie](https://sacred.readthedocs.io/en/stable/logging.html))\n",
" - `_run` - daje dostęp do obiektu reprezentującego aktualne wywołanie eksperymentu (przykład później)"
]
@ -859,15 +912,23 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 9,
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Overwriting IUM_07/file_observer.py\n"
]
}
],
"source": [
"# %load IUM_07/file_observer.py\n",
"%%writefile IUM_07/file_observer.py\n",
"from sacred.observers import FileStorageObserver\n",
"from sacred import Experiment\n",
"\n",
@ -891,10 +952,10 @@
},
{
"cell_type": "code",
"execution_count": 159,
"execution_count": 11,
"metadata": {
"slideshow": {
"slide_type": "slide"
"slide_type": "fragment"
}
},
"outputs": [
@ -903,14 +964,14 @@
"output_type": "stream",
"text": [
"INFO - file_observer - Running command 'my_main'\r\n",
"INFO - file_observer - Started run with ID \"2\"\r\n",
"INFO - file_observer - Started run with ID \"1\"\r\n",
"Witaj Świecie!\r\n",
"INFO - file_observer - Completed after 0:00:00\r\n"
]
}
],
"source": [
"!python IUM_07/file_observer.py"
"!python3 IUM_07/file_observer.py"
]
},
{
@ -926,7 +987,7 @@
},
{
"cell_type": "code",
"execution_count": 160,
"execution_count": 12,
"metadata": {
"slideshow": {
"slide_type": "slide"
@ -937,10 +998,9 @@
"name": "stdout",
"output_type": "stream",
"text": [
"total 12\r\n",
"drwxrwxr-x 2 tomek tomek 4096 kwi 26 09:54 1\r\n",
"drwxrwxr-x 2 tomek tomek 4096 kwi 26 10:21 2\r\n",
"drwxrwxr-x 2 tomek tomek 4096 kwi 26 10:21 _sources\r\n"
"total 0\r\n",
"drwxr-xr-x 1 tomek tomek 512 Apr 25 09:51 1\r\n",
"drwxr-xr-x 1 tomek tomek 512 Apr 25 09:51 _sources\r\n"
]
}
],
@ -950,7 +1010,7 @@
},
{
"cell_type": "code",
"execution_count": 164,
"execution_count": 14,
"metadata": {
"slideshow": {
"slide_type": "slide"
@ -961,69 +1021,16 @@
"name": "stdout",
"output_type": "stream",
"text": [
"total 16\r\n",
"-rw-rw-r-- 1 tomek tomek 76 kwi 26 10:21 config.json\r\n",
"-rw-rw-r-- 1 tomek tomek 159 kwi 26 10:21 cout.txt\r\n",
"-rw-rw-r-- 1 tomek tomek 2 kwi 26 10:21 metrics.json\r\n",
"-rw-rw-r-- 1 tomek tomek 1686 kwi 26 10:21 run.json\r\n"
"total 4\r\n",
"-rw-r--r-- 1 tomek tomek 77 Apr 25 09:51 config.json\r\n",
"-rw-r--r-- 1 tomek tomek 159 Apr 25 09:51 cout.txt\r\n",
"-rw-r--r-- 1 tomek tomek 2 Apr 25 09:51 metrics.json\r\n",
"-rw-r--r-- 1 tomek tomek 1659 Apr 25 09:51 run.json\r\n"
]
}
],
"source": [
"!ls -l my_runs/2"
]
},
{
"cell_type": "code",
"execution_count": 162,
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"{'greeting': 'Witaj', 'recipient': 'Świecie', 'seed': 178660254}"
]
},
"execution_count": 162,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# %load my_runs/2/config.json\n",
"{\n",
" \"greeting\": \"Witaj\",\n",
" \"recipient\": \"\\u015awiecie\",\n",
" \"seed\": 178660254\n",
"}"
]
},
{
"cell_type": "code",
"execution_count": 165,
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO - file_observer - Running command 'my_main'\r\n",
"INFO - file_observer - Started run with ID \"2\"\r\n",
"Witaj Świecie!\r\n",
"INFO - file_observer - Completed after 0:00:00\r\n"
]
}
],
"source": [
"!cat my_runs/2/cout.txt"
"!ls -l my_runs/1"
]
},
{
@ -1036,42 +1043,83 @@
},
"outputs": [],
"source": [
"# %load my_runs/2/run.json\n",
"# %load my_runs/1/config.json\n",
"{\n",
" \"greeting\": \"Witaj\",\n",
" \"recipient\": \"\\u015awiecie\",\n",
" \"seed\": 805857632\n",
"}"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO - file_observer - Running command 'my_main'\r\n",
"INFO - file_observer - Started run with ID \"1\"\r\n",
"Witaj Świecie!\r\n",
"INFO - file_observer - Completed after 0:00:00\r\n"
]
}
],
"source": [
"!cat my_runs/1/cout.txt"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"outputs": [],
"source": [
"# %load my_runs/1/run.json\n",
"{\n",
" \"artifacts\": [],\n",
" \"command\": \"my_main\",\n",
" \"experiment\": {\n",
" \"base_dir\": \"/home/tomek/AITech/repo/aitech-ium-private/IUM_07\",\n",
" \"base_dir\": \"/home/tomek/repos/aitech/aitech-ium/IUM_07\",\n",
" \"dependencies\": [\n",
" \"numpy==1.19.2\",\n",
" \"sacred==0.8.2\"\n",
" ],\n",
" \"mainfile\": \"file_observer.py\",\n",
" \"name\": \"file_observer\",\n",
" \"repositories\": [\n",
" {\n",
" \"commit\": \"9a2064faaf4d209233ab0e20ad522638bb99b6f4\",\n",
" \"commit\": \"3055a4f1c2ef06ea1c29e3d41d862827cede7e2a\",\n",
" \"dirty\": true,\n",
" \"url\": \"git@git.wmi.amu.edu.pl:tzietkiewicz/aitech-ium-private.git\"\n",
" \"url\": \"git@git.wmi.amu.edu.pl:tzietkiewicz/aitech-ium.git\"\n",
" }\n",
" ],\n",
" \"sources\": [\n",
" [\n",
" \"file_observer.py\",\n",
" \"_sources/file_observer_bb0a5c4720d1072b641d23da080696b6.py\"\n",
" \"_sources/file_observer_cd34a0ef4a32fb0a966eaa01ea6371ad.py\"\n",
" ]\n",
" ]\n",
" },\n",
" \"heartbeat\": \"2021-04-26T08:21:35.718761\",\n",
" \"heartbeat\": \"2022-04-25T07:51:37.853633\",\n",
" \"host\": {\n",
" \"ENV\": {},\n",
" \"cpu\": \"Intel(R) Core(TM) i5-4200H CPU @ 2.80GHz\",\n",
" \"hostname\": \"tomek-asus\",\n",
" \"hostname\": \"ASUSEK\",\n",
" \"os\": [\n",
" \"Linux\",\n",
" \"Linux-5.4.0-72-generic-x86_64-with-glibc2.10\"\n",
" \"Linux-4.4.0-19041-Microsoft-x86_64-with-Ubuntu-18.04-bionic\"\n",
" ],\n",
" \"python_version\": \"3.8.5\"\n",
" \"python_version\": \"3.6.9\"\n",
" },\n",
" \"meta\": {\n",
" \"command\": \"my_main\",\n",
@ -1103,9 +1151,9 @@
" },\n",
" \"resources\": [],\n",
" \"result\": null,\n",
" \"start_time\": \"2021-04-26T08:21:35.714091\",\n",
" \"start_time\": \"2022-04-25T07:51:37.831461\",\n",
" \"status\": \"COMPLETED\",\n",
" \"stop_time\": \"2021-04-26T08:21:35.717141\"\n",
" \"stop_time\": \"2022-04-25T07:51:37.849334\"\n",
"}"
]
},
@ -1178,7 +1226,7 @@
},
{
"cell_type": "code",
"execution_count": 183,
"execution_count": 22,
"metadata": {
"slideshow": {
"slide_type": "slide"
@ -1190,7 +1238,7 @@
"output_type": "stream",
"text": [
"INFO - file_observer - Running command 'my_main'\n",
"INFO - file_observer - Started run with ID \"6\"\n",
"INFO - file_observer - Started run with ID \"2\"\n",
"INFO - file_observer - Completed after 0:00:00\n"
]
},
@ -1288,7 +1336,7 @@
},
{
"cell_type": "code",
"execution_count": 134,
"execution_count": 19,
"metadata": {
"slideshow": {
"slide_type": "slide"
@ -1299,17 +1347,21 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Requirement already satisfied: pymongo in /media/tomek/Linux_data/home/tomek/anaconda3/lib/python3.8/site-packages (3.11.3)\r\n"
"Collecting pymongo\n",
" Downloading https://files.pythonhosted.org/packages/10/3b/46541b4ee3000019b8ef5b1847292ddc77f492c162bc4d49c424db7fc97a/pymongo-4.1.1-cp36-cp36m-manylinux1_x86_64.whl (464kB)\n",
"\u001b[K 100% |████████████████████████████████| 471kB 959kB/s ta 0:00:01\n",
"\u001b[?25hInstalling collected packages: pymongo\n",
"Successfully installed pymongo-4.1.1\n"
]
}
],
"source": [
"!pip install pymongo"
"!pip3 install pymongo"
]
},
{
"cell_type": "code",
"execution_count": 155,
"execution_count": 23,
"metadata": {
"slideshow": {
"slide_type": "slide"
@ -1321,26 +1373,77 @@
"output_type": "stream",
"text": [
"INFO - sacred_scopes - Running command 'my_main'\n",
"INFO - sacred_scopes - Started run with ID \"2\"\n",
"INFO - sacred_scopes - Completed after 0:00:00\n"
"ERROR - sacred_scopes - Failed after 0:00:30!\n",
"ERROR - sacred_scopes - Traceback (most recent call last):\n",
" File \"/home/tomek/.local/lib/python3.6/site-packages/sacred/run.py\", line 235, in __call__\n",
" self._emit_started()\n",
" File \"/home/tomek/.local/lib/python3.6/site-packages/sacred/run.py\", line 333, in _emit_started\n",
" _id=self._id,\n",
" File \"/home/tomek/.local/lib/python3.6/site-packages/sacred/observers/mongo.py\", line 258, in started_event\n",
" self.insert()\n",
" File \"/home/tomek/.local/lib/python3.6/site-packages/sacred/observers/mongo.py\", line 367, in insert\n",
" c.next()[\"_id\"] + 1 if self.runs.count_documents({}, limit=1) else 1\n",
" File \"/home/tomek/.local/lib/python3.6/site-packages/pymongo/collection.py\", line 1811, in count_documents\n",
" return self._retryable_non_cursor_read(_cmd, session)\n",
" File \"/home/tomek/.local/lib/python3.6/site-packages/pymongo/collection.py\", line 1816, in _retryable_non_cursor_read\n",
" with client._tmp_session(session) as s:\n",
" File \"/usr/lib/python3.6/contextlib.py\", line 81, in __enter__\n",
" return next(self.gen)\n",
" File \"/home/tomek/.local/lib/python3.6/site-packages/pymongo/mongo_client.py\", line 1676, in _tmp_session\n",
" s = self._ensure_session(session)\n",
" File \"/home/tomek/.local/lib/python3.6/site-packages/pymongo/mongo_client.py\", line 1663, in _ensure_session\n",
" return self.__start_session(True, causal_consistency=False)\n",
" File \"/home/tomek/.local/lib/python3.6/site-packages/pymongo/mongo_client.py\", line 1608, in __start_session\n",
" self._topology._check_implicit_session_support()\n",
" File \"/home/tomek/.local/lib/python3.6/site-packages/pymongo/topology.py\", line 519, in _check_implicit_session_support\n",
" self._check_session_support()\n",
" File \"/home/tomek/.local/lib/python3.6/site-packages/pymongo/topology.py\", line 536, in _check_session_support\n",
" readable_server_selector, self._settings.server_selection_timeout, None\n",
" File \"/home/tomek/.local/lib/python3.6/site-packages/pymongo/topology.py\", line 229, in _select_servers_loop\n",
" % (self._error_message(selector), timeout, self.description)\n",
"pymongo.errors.ServerSelectionTimeoutError: localhost:27017: [Errno 111] Connection refused, Timeout: 30s, Topology Description: <TopologyDescription id: 6266603d3269f60a67f61383, topology_type: Unknown, servers: [<ServerDescription ('localhost', 27017) server_type: Unknown, rtt: None, error=AutoReconnect('localhost:27017: [Errno 111] Connection refused',)>]>\n",
"\n",
"During handling of the above exception, another exception occurred:\n",
"\n",
"Traceback (most recent call last):\n",
" File \"/home/tomek/.local/lib/python3.6/site-packages/sacred/run.py\", line 429, in _final_call\n",
" getattr(observer, method)(**kwargs)\n",
" File \"/home/tomek/.local/lib/python3.6/site-packages/sacred/observers/mongo.py\", line 283, in failed_event\n",
" self.final_save(attempts=1)\n",
" File \"/home/tomek/.local/lib/python3.6/site-packages/sacred/observers/mongo.py\", line 421, in final_save\n",
" os.makedirs(self.failure_dir, exist_ok=True)\n",
" File \"/usr/lib/python3.6/os.py\", line 205, in makedirs\n",
" head, tail = path.split(name)\n",
" File \"/usr/lib/python3.6/posixpath.py\", line 107, in split\n",
" p = os.fspath(p)\n",
"TypeError: expected str, bytes or os.PathLike object, not NoneType\n",
"\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Witaj Świecie!\n"
"ename": "ServerSelectionTimeoutError",
"evalue": "localhost:27017: [Errno 111] Connection refused, Timeout: 30s, Topology Description: <TopologyDescription id: 6266603d3269f60a67f61383, topology_type: Unknown, servers: [<ServerDescription ('localhost', 27017) server_type: Unknown, rtt: None, error=AutoReconnect('localhost:27017: [Errno 111] Connection refused',)>]>",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mServerSelectionTimeoutError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-23-95f1b404dde7>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 19\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mprepare_message\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;31m## Nie musimy przekazywać wartości\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 20\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 21\u001b[0;31m \u001b[0mex\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mrun\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;32m~/.local/lib/python3.6/site-packages/sacred/experiment.py\u001b[0m in \u001b[0;36mrun\u001b[0;34m(self, command_name, config_updates, named_configs, info, meta_info, options)\u001b[0m\n\u001b[1;32m 274\u001b[0m \u001b[0mcommand_name\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mconfig_updates\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mnamed_configs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0minfo\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mmeta_info\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0moptions\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 275\u001b[0m )\n\u001b[0;32m--> 276\u001b[0;31m \u001b[0mrun\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 277\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mrun\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 278\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m~/.local/lib/python3.6/site-packages/sacred/run.py\u001b[0m in \u001b[0;36m__call__\u001b[0;34m(self, *args)\u001b[0m\n\u001b[1;32m 233\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 234\u001b[0m \u001b[0;32mwith\u001b[0m \u001b[0mcapture_stdout\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_output_file\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 235\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_emit_started\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 236\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_start_heartbeat\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 237\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_execute_pre_run_hooks\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m~/.local/lib/python3.6/site-packages/sacred/run.py\u001b[0m in \u001b[0;36m_emit_started\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 331\u001b[0m \u001b[0mconfig\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mconfig\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 332\u001b[0m \u001b[0mmeta_info\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmeta_info\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 333\u001b[0;31m \u001b[0m_id\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_id\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 334\u001b[0m )\n\u001b[1;32m 335\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_id\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m~/.local/lib/python3.6/site-packages/sacred/observers/mongo.py\u001b[0m in \u001b[0;36mstarted_event\u001b[0;34m(self, ex_info, command, host_info, start_time, config, meta_info, _id)\u001b[0m\n\u001b[1;32m 256\u001b[0m \u001b[0;31m# save sources\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 257\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mrun_entry\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m\"experiment\"\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m\"sources\"\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msave_sources\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mex_info\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 258\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0minsert\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 259\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mrun_entry\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m\"_id\"\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 260\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m~/.local/lib/python3.6/site-packages/sacred/observers/mongo.py\u001b[0m in \u001b[0;36minsert\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 365\u001b[0m \u001b[0mc\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mc\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msort\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"_id\"\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mpymongo\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mDESCENDING\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mlimit\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 366\u001b[0m self.run_entry[\"_id\"] = (\n\u001b[0;32m--> 367\u001b[0;31m \u001b[0mc\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mnext\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m\"_id\"\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0;36m1\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mruns\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcount_documents\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m{\u001b[0m\u001b[0;34m}\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mlimit\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32melse\u001b[0m \u001b[0;36m1\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 368\u001b[0m )\n\u001b[1;32m 369\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m~/.local/lib/python3.6/site-packages/pymongo/collection.py\u001b[0m in \u001b[0;36mcount_documents\u001b[0;34m(self, filter, session, comment, **kwargs)\u001b[0m\n\u001b[1;32m 1809\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mresult\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m\"n\"\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1810\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1811\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_retryable_non_cursor_read\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0m_cmd\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0msession\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1812\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1813\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m_retryable_non_cursor_read\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mfunc\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0msession\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m~/.local/lib/python3.6/site-packages/pymongo/collection.py\u001b[0m in \u001b[0;36m_retryable_non_cursor_read\u001b[0;34m(self, func, session)\u001b[0m\n\u001b[1;32m 1814\u001b[0m \u001b[0;34m\"\"\"Non-cursor read helper to handle implicit session creation.\"\"\"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1815\u001b[0m \u001b[0mclient\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__database\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mclient\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1816\u001b[0;31m \u001b[0;32mwith\u001b[0m \u001b[0mclient\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_tmp_session\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0msession\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0ms\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1817\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mclient\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_retryable_read\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfunc\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_read_preference_for\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0ms\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0ms\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1818\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/usr/lib/python3.6/contextlib.py\u001b[0m in \u001b[0;36m__enter__\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 79\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m__enter__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 80\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 81\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mnext\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mgen\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 82\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mStopIteration\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 83\u001b[0m \u001b[0;32mraise\u001b[0m \u001b[0mRuntimeError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"generator didn't yield\"\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m~/.local/lib/python3.6/site-packages/pymongo/mongo_client.py\u001b[0m in \u001b[0;36m_tmp_session\u001b[0;34m(self, session, close)\u001b[0m\n\u001b[1;32m 1674\u001b[0m \u001b[0;32mreturn\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1675\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1676\u001b[0;31m \u001b[0ms\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_ensure_session\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0msession\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1677\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0ms\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1678\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m~/.local/lib/python3.6/site-packages/pymongo/mongo_client.py\u001b[0m in \u001b[0;36m_ensure_session\u001b[0;34m(self, session)\u001b[0m\n\u001b[1;32m 1661\u001b[0m \u001b[0;31m# Don't make implicit sessions causally consistent. Applications\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1662\u001b[0m \u001b[0;31m# should always opt-in.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1663\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__start_session\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;32mTrue\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcausal_consistency\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mFalse\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1664\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mConfigurationError\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mInvalidOperation\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1665\u001b[0m \u001b[0;31m# Sessions not supported.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m~/.local/lib/python3.6/site-packages/pymongo/mongo_client.py\u001b[0m in \u001b[0;36m__start_session\u001b[0;34m(self, implicit, **kwargs)\u001b[0m\n\u001b[1;32m 1606\u001b[0m \u001b[0;31m# Raises ConfigurationError if sessions are not supported.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1607\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mimplicit\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1608\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_topology\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_check_implicit_session_support\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1609\u001b[0m \u001b[0mserver_session\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0m_EmptyServerSession\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1610\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m~/.local/lib/python3.6/site-packages/pymongo/topology.py\u001b[0m in \u001b[0;36m_check_implicit_session_support\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 517\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m_check_implicit_session_support\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 518\u001b[0m \u001b[0;32mwith\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_lock\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 519\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_check_session_support\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 520\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 521\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m_check_session_support\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m~/.local/lib/python3.6/site-packages/pymongo/topology.py\u001b[0m in \u001b[0;36m_check_session_support\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 534\u001b[0m \u001b[0;32melif\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_description\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mreadable_servers\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 535\u001b[0m self._select_servers_loop(\n\u001b[0;32m--> 536\u001b[0;31m \u001b[0mreadable_server_selector\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_settings\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mserver_selection_timeout\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 537\u001b[0m )\n\u001b[1;32m 538\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m~/.local/lib/python3.6/site-packages/pymongo/topology.py\u001b[0m in \u001b[0;36m_select_servers_loop\u001b[0;34m(self, selector, timeout, address)\u001b[0m\n\u001b[1;32m 227\u001b[0m raise ServerSelectionTimeoutError(\n\u001b[1;32m 228\u001b[0m \u001b[0;34m\"%s, Timeout: %ss, Topology Description: %r\"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 229\u001b[0;31m \u001b[0;34m%\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_error_message\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mselector\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtimeout\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdescription\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 230\u001b[0m )\n\u001b[1;32m 231\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mServerSelectionTimeoutError\u001b[0m: localhost:27017: [Errno 111] Connection refused, Timeout: 30s, Topology Description: <TopologyDescription id: 6266603d3269f60a67f61383, topology_type: Unknown, servers: [<ServerDescription ('localhost', 27017) server_type: Unknown, rtt: None, error=AutoReconnect('localhost:27017: [Errno 111] Connection refused',)>]>"
]
},
{
"data": {
"text/plain": [
"<sacred.run.Run at 0x7f423c3667c0>"
]
},
"execution_count": 155,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
@ -1530,7 +1633,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.1"
"version": "3.6.9"
},
"slideshow": {
"slide_type": "slide"

View File

@ -1440,7 +1440,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.1"
"version": "3.6.9"
},
"slideshow": {
"slide_type": "slide"