aitech-ium/IUM_10.DVC.ipynb

1812 lines
72 KiB
Plaintext
Raw Normal View History

2021-05-31 11:55:27 +02:00
{
"cells": [
2021-09-28 10:56:21 +02:00
{
"cell_type": "markdown",
"id": "7fe475ae",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"![Logo 1](https://git.wmi.amu.edu.pl/AITech/Szablon/raw/branch/master/Logotyp_AITech1.jpg)\n",
"<div class=\"alert alert-block alert-info\">\n",
"<h1> Inżynieria uczenia maszynowego </h1>\n",
"<h2> 10. <i>DVC</i> [laboratoria]</h2> \n",
2023-04-26 13:44:55 +02:00
"<h3> Tomasz Ziętkiewicz (2023)</h3>\n",
2021-09-28 10:56:21 +02:00
"</div>\n",
"\n",
"![Logo 2](https://git.wmi.amu.edu.pl/AITech/Szablon/raw/branch/master/Logotyp_AITech2.jpg)"
]
},
2021-05-31 11:55:27 +02:00
{
"cell_type": "markdown",
"id": "0c6f27a5",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"<img src=\"img/expcontrol/dvc-logo.png\">"
]
},
{
"cell_type": "markdown",
"id": "560eec71",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## DVC - Data Version Control\n",
"- [dvc.org](https://dvc.org/)\n",
"- \"Version Control System for Machine Learning Projects\" (System kontroli wersji dla projektów uczenia maszynowego)\n",
"- Open Source\n",
"- Umożliwia:\n",
" - wersjonowanie danych i modeli. \"Git dla danych i modeli\"\n",
" - budowanie potoków (\"pipeline\") definiujących jak budować/trenować/ewaluować modele. \"Makefile dla uczenia maszynowego\"\n",
2022-05-23 09:57:46 +02:00
" - śledzenie, porównywanie metryk i parametrów\n",
2021-05-31 11:55:27 +02:00
"- ściśle zintegowany z gitem\n",
"- działa niezależnie od używanego języka/bibliotek i systemu operacyjnego\n",
"- 5-minutowe wprowadzenie: https://www.youtube.com/watch?v=UbL7VUpv1Bs&t=197s"
]
},
2023-04-26 13:44:55 +02:00
{
"cell_type": "markdown",
"id": "3d4ce1cb",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## Śledzenie plików za pomocą DVC\n",
" - dużymi plikami, takimi jak plikami z danymi wejściowymi czy plikami modeli, trudno zarządza się za pomocą gita, ze względu na problemy z:\n",
" - wydajnością\n",
" - przestrzenią w repozytorium\n",
" - ograniczenia ze strony serwisu (np. [limit 100 MB na plik w Github](https://docs.github.com/en/repositories/working-with-files/managing-large-files/about-large-files-on-github))\n",
" - Git posiada rozszerzenie [lfs(Large File Storage)](https://git-lfs.github.com/), które stanowi pewne rozwiązanie tego problemu. \n",
" - Same pliki przechowywane są na specjalnym zdalnym serwerze, w repozytorium przechowywane są jedynie odnośniki do tych plików i pewne metadane\n",
" - Github ma zintegrowany LFS z [limitem 1GB dla kont bezpłatnych](https://docs.github.com/en/repositories/working-with-files/managing-large-files/about-storage-and-bandwidth-usage)"
]
},
{
"cell_type": "markdown",
"id": "dd8e529b",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
" - DVC proponuje podobne podejście co LFS, ale:\n",
" - pliki mogą być przechowywane na niemal dowolnym serwerze, również lokalnie\n",
" - brak limitu wielkości plików (w Git-LFS na Github [limit 2GB](https://docs.github.com/en/repositories/working-with-files/managing-large-files/about-git-large-file-storage))\n",
" - DVC zapewnia dodatkowe narzędzie umożliwiające śledzenie plików i ich powiązań z wynikami eksperymentów\n",
" - więcej, patrz [tutaj](https://dvc.org/doc/user-guide/related-technologies)"
]
},
2021-05-31 11:55:27 +02:00
{
"cell_type": "markdown",
"id": "9bfb356e",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## Instalacja i inicjalizacja\n",
" - https://dvc.org/doc/install\n",
" - ```pip(x) install dvc``` albo:\n",
" - ```conda install dvc```"
]
},
{
"cell_type": "code",
2023-04-26 13:44:55 +02:00
"execution_count": 6,
2021-05-31 11:55:27 +02:00
"id": "054c7a11",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
2022-05-23 09:57:46 +02:00
"Collecting dvc\n",
2023-04-26 13:44:55 +02:00
" Downloading dvc-2.55.0-py3-none-any.whl (419 kB)\n",
"\u001b[K |████████████████████████████████| 419 kB 794 kB/s eta 0:00:01\n",
"\u001b[?25hCollecting funcy>=1.14\n",
" Downloading funcy-2.0-py2.py3-none-any.whl (30 kB)\n",
"Collecting voluptuous>=0.11.7\n",
" Using cached voluptuous-0.13.1-py3-none-any.whl (29 kB)\n",
"Collecting dvc-http>=2.29.0\n",
" Downloading dvc_http-2.30.2-py3-none-any.whl (12 kB)\n",
"Requirement already satisfied: colorama>=0.3.9 in /home/tomek/miniconda3/lib/python3.9/site-packages (from dvc) (0.4.6)\n",
"Collecting pathspec>=0.10.3\n",
" Downloading pathspec-0.11.1-py3-none-any.whl (29 kB)\n",
"Collecting pygtrie>=2.3.2\n",
" Downloading pygtrie-2.5.0-py3-none-any.whl (25 kB)\n",
"Requirement already satisfied: ruamel.yaml>=0.17.11 in /home/tomek/miniconda3/lib/python3.9/site-packages (from dvc) (0.17.21)\n",
"Requirement already satisfied: tabulate>=0.8.7 in /home/tomek/miniconda3/lib/python3.9/site-packages (from dvc) (0.9.0)\n",
"Collecting zc.lockfile>=1.2.1\n",
" Downloading zc.lockfile-3.0.post1-py3-none-any.whl (9.8 kB)\n",
"Collecting dpath<3,>=2.1.0\n",
" Downloading dpath-2.1.5-py3-none-any.whl (17 kB)\n",
"Collecting shtab<2,>=1.3.4\n",
" Downloading shtab-1.6.1-py3-none-any.whl (13 kB)\n",
"Requirement already satisfied: tqdm<5,>=4.63.1 in /home/tomek/miniconda3/lib/python3.9/site-packages (from dvc) (4.64.0)\n",
"Collecting pydot>=1.2.4\n",
" Using cached pydot-1.4.2-py2.py3-none-any.whl (21 kB)\n",
"Collecting scmrepo<2,>=1.0.0\n",
" Downloading scmrepo-1.0.2-py3-none-any.whl (54 kB)\n",
"\u001b[K |████████████████████████████████| 54 kB 1.8 MB/s eta 0:00:01\n",
"\u001b[?25hCollecting flatten-dict<1,>=0.4.1\n",
" Using cached flatten_dict-0.4.2-py2.py3-none-any.whl (9.7 kB)\n",
"Collecting psutil>=5.8\n",
" Downloading psutil-5.9.5-cp36-abi3-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (282 kB)\n",
"\u001b[K |████████████████████████████████| 282 kB 21.9 MB/s eta 0:00:01\n",
"\u001b[?25hCollecting dvc-data<0.48,>=0.47.1\n",
" Downloading dvc_data-0.47.2-py3-none-any.whl (59 kB)\n",
"\u001b[K |████████████████████████████████| 59 kB 4.1 MB/s eta 0:00:01\n",
"\u001b[?25hCollecting dvc-render<0.4.0,>=0.3.1\n",
" Downloading dvc_render-0.3.1-py3-none-any.whl (18 kB)\n",
"Collecting dvc-studio-client<1,>=0.6.1\n",
" Downloading dvc_studio_client-0.8.0-py3-none-any.whl (10 kB)\n",
"Collecting flufl.lock>=5\n",
" Downloading flufl.lock-7.1.1-py3-none-any.whl (11 kB)\n",
"Requirement already satisfied: platformdirs<4,>=3.1.1 in /home/tomek/miniconda3/lib/python3.9/site-packages (from dvc) (3.1.1)\n",
"Collecting networkx>=2.5\n",
" Downloading networkx-3.1-py3-none-any.whl (2.1 MB)\n",
"\u001b[K |████████████████████████████████| 2.1 MB 14.1 MB/s eta 0:00:01\n",
"\u001b[?25hCollecting grandalf<1,>=0.7\n",
" Downloading grandalf-0.8-py3-none-any.whl (41 kB)\n",
"\u001b[K |████████████████████████████████| 41 kB 304 kB/s eta 0:00:01\n",
"\u001b[?25hCollecting hydra-core>=1.1\n",
" Downloading hydra_core-1.3.2-py3-none-any.whl (154 kB)\n",
"\u001b[K |████████████████████████████████| 154 kB 14.3 MB/s eta 0:00:01\n",
"\u001b[?25hRequirement already satisfied: pyparsing>=2.4.7 in /home/tomek/.local/lib/python3.9/site-packages (from dvc) (3.0.9)\n",
"Collecting tomlkit>=0.11.1\n",
" Downloading tomlkit-0.11.7-py3-none-any.whl (35 kB)\n",
"Requirement already satisfied: requests>=2.22 in /home/tomek/miniconda3/lib/python3.9/site-packages (from dvc) (2.27.1)\n",
"Requirement already satisfied: packaging>=19 in /home/tomek/miniconda3/lib/python3.9/site-packages (from dvc) (23.0)\n",
"Collecting distro>=1.3\n",
" Downloading distro-1.8.0-py3-none-any.whl (20 kB)\n",
"Collecting shortuuid>=0.5\n",
" Downloading shortuuid-1.0.11-py3-none-any.whl (10 kB)\n",
"Collecting rich>=12\n",
" Downloading rich-13.3.4-py3-none-any.whl (238 kB)\n",
"\u001b[K |████████████████████████████████| 238 kB 11.6 MB/s eta 0:00:01\n",
"\u001b[?25hCollecting dvc-task<1,>=0.2.0\n",
" Downloading dvc_task-0.2.0-py3-none-any.whl (23 kB)\n",
"Collecting configobj>=5.0.6\n",
" Downloading configobj-5.0.8-py2.py3-none-any.whl (36 kB)\n",
"Collecting iterative-telemetry>=0.0.7\n",
" Downloading iterative_telemetry-0.0.8-py3-none-any.whl (10 kB)\n",
"Requirement already satisfied: six in /home/tomek/miniconda3/lib/python3.9/site-packages (from configobj>=5.0.6->dvc) (1.16.0)\n",
"Collecting dvc-objects<1,>=0.21.1\n",
" Downloading dvc_objects-0.21.2-py3-none-any.whl (37 kB)\n",
"Requirement already satisfied: attrs>=21.3.0 in /home/tomek/miniconda3/lib/python3.9/site-packages (from dvc-data<0.48,>=0.47.1->dvc) (22.2.0)\n",
"Collecting dictdiffer>=0.8.1\n",
" Using cached dictdiffer-0.9.0-py2.py3-none-any.whl (16 kB)\n",
"Collecting nanotime>=0.5.2\n",
" Using cached nanotime-0.5.2.tar.gz (3.2 kB)\n",
"Collecting diskcache>=5.2.1\n",
" Downloading diskcache-5.6.1-py3-none-any.whl (45 kB)\n",
"\u001b[K |████████████████████████████████| 45 kB 905 kB/s eta 0:00:01\n",
"\u001b[?25hCollecting sqltrie<1,>=0.3.1\n",
" Downloading sqltrie-0.3.1-py3-none-any.whl (16 kB)\n",
"Requirement already satisfied: fsspec[http] in /home/tomek/miniconda3/lib/python3.9/site-packages (from dvc-http>=2.29.0->dvc) (2023.3.0)\n",
"Collecting aiohttp-retry>=2.5.0\n",
" Downloading aiohttp_retry-2.8.3-py3-none-any.whl (9.8 kB)\n",
"Requirement already satisfied: aiohttp in /home/tomek/miniconda3/lib/python3.9/site-packages (from aiohttp-retry>=2.5.0->dvc-http>=2.29.0->dvc) (3.8.4)\n",
"Requirement already satisfied: typing-extensions>=3.7.4 in /home/tomek/miniconda3/lib/python3.9/site-packages (from dvc-objects<1,>=0.21.1->dvc-data<0.48,>=0.47.1->dvc) (4.5.0)\n",
"Collecting dulwich\n",
" Downloading dulwich-0.21.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (505 kB)\n",
"\u001b[K |████████████████████████████████| 505 kB 16.6 MB/s eta 0:00:01\n",
"\u001b[?25hCollecting celery<6,>=5.2.0\n",
" Downloading celery-5.2.7-py3-none-any.whl (405 kB)\n",
"\u001b[K |████████████████████████████████| 405 kB 19.2 MB/s eta 0:00:01\n",
"\u001b[?25hCollecting kombu<6,>=5.2.0\n",
" Downloading kombu-5.2.4-py3-none-any.whl (189 kB)\n",
"\u001b[K |████████████████████████████████| 189 kB 14.8 MB/s eta 0:00:01\n",
"\u001b[?25hCollecting click-didyoumean>=0.0.3\n",
" Downloading click_didyoumean-0.3.0-py3-none-any.whl (2.7 kB)\n",
"Collecting billiard<4.0,>=3.6.4.0\n",
" Downloading billiard-3.6.4.0-py3-none-any.whl (89 kB)\n",
"\u001b[K |████████████████████████████████| 89 kB 3.8 MB/s eta 0:00:01\n",
"\u001b[?25hCollecting vine<6.0,>=5.0.0\n",
" Downloading vine-5.0.0-py2.py3-none-any.whl (9.4 kB)\n",
"Collecting click-repl>=0.2.0\n",
" Downloading click_repl-0.2.0-py3-none-any.whl (5.2 kB)\n",
"Requirement already satisfied: click<9.0,>=8.0.3 in /home/tomek/miniconda3/lib/python3.9/site-packages (from celery<6,>=5.2.0->dvc-task<1,>=0.2.0->dvc) (8.1.3)\n",
"Collecting click-plugins>=1.1.1\n",
" Downloading click_plugins-1.1.1-py2.py3-none-any.whl (7.5 kB)\n",
"Requirement already satisfied: pytz>=2021.3 in /home/tomek/miniconda3/lib/python3.9/site-packages (from celery<6,>=5.2.0->dvc-task<1,>=0.2.0->dvc) (2022.7.1)\n",
"Requirement already satisfied: prompt-toolkit in /home/tomek/miniconda3/lib/python3.9/site-packages (from click-repl>=0.2.0->celery<6,>=5.2.0->dvc-task<1,>=0.2.0->dvc) (3.0.38)\n",
"Collecting atpublic>=2.3\n",
" Downloading atpublic-3.1.1-py3-none-any.whl (4.8 kB)\n",
"Collecting antlr4-python3-runtime==4.9.*\n",
" Downloading antlr4-python3-runtime-4.9.3.tar.gz (117 kB)\n",
"\u001b[K |████████████████████████████████| 117 kB 17.4 MB/s eta 0:00:01\n",
"\u001b[?25hCollecting omegaconf<2.4,>=2.2\n",
" Downloading omegaconf-2.3.0-py3-none-any.whl (79 kB)\n",
"\u001b[K |████████████████████████████████| 79 kB 3.6 MB/s eta 0:00:01\n",
"\u001b[?25hCollecting appdirs\n",
" Using cached appdirs-1.4.4-py2.py3-none-any.whl (9.6 kB)\n",
"Requirement already satisfied: filelock in /home/tomek/miniconda3/lib/python3.9/site-packages (from iterative-telemetry>=0.0.7->dvc) (3.9.1)\n",
"Collecting amqp<6.0.0,>=5.0.9\n",
" Downloading amqp-5.1.1-py3-none-any.whl (50 kB)\n",
"\u001b[K |████████████████████████████████| 50 kB 2.7 MB/s eta 0:00:01\n",
"\u001b[?25hRequirement already satisfied: PyYAML>=5.1.0 in /home/tomek/miniconda3/lib/python3.9/site-packages (from omegaconf<2.4,>=2.2->hydra-core>=1.1->dvc) (6.0)\n",
"Requirement already satisfied: urllib3<1.27,>=1.21.1 in /home/tomek/miniconda3/lib/python3.9/site-packages (from requests>=2.22->dvc) (1.26.9)\n",
"Requirement already satisfied: charset-normalizer~=2.0.0 in /home/tomek/miniconda3/lib/python3.9/site-packages (from requests>=2.22->dvc) (2.0.4)\n",
"Requirement already satisfied: certifi>=2017.4.17 in /home/tomek/miniconda3/lib/python3.9/site-packages (from requests>=2.22->dvc) (2022.12.7)\n",
"Requirement already satisfied: idna<4,>=2.5 in /home/tomek/miniconda3/lib/python3.9/site-packages (from requests>=2.22->dvc) (3.3)\n"
2022-05-23 09:57:46 +02:00
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
2023-04-26 13:44:55 +02:00
"Collecting markdown-it-py<3.0.0,>=2.2.0\n",
" Downloading markdown_it_py-2.2.0-py3-none-any.whl (84 kB)\n",
"\u001b[K |████████████████████████████████| 84 kB 1.9 MB/s eta 0:00:01\n",
"\u001b[?25hRequirement already satisfied: pygments<3.0.0,>=2.13.0 in /home/tomek/miniconda3/lib/python3.9/site-packages (from rich>=12->dvc) (2.14.0)\n",
"Collecting mdurl~=0.1\n",
" Downloading mdurl-0.1.2-py3-none-any.whl (10.0 kB)\n",
"Requirement already satisfied: ruamel.yaml.clib>=0.2.6 in /home/tomek/miniconda3/lib/python3.9/site-packages (from ruamel.yaml>=0.17.11->dvc) (0.2.6)\n",
"Collecting pygit2>=1.10.0\n",
" Downloading pygit2-1.12.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.9 MB)\n",
"\u001b[K |████████████████████████████████| 4.9 MB 13.6 MB/s eta 0:00:01\n",
"\u001b[?25hCollecting asyncssh<3,>=2.13.1\n",
" Downloading asyncssh-2.13.1-py3-none-any.whl (348 kB)\n",
"\u001b[K |████████████████████████████████| 348 kB 38.4 MB/s eta 0:00:01\n",
"\u001b[?25hRequirement already satisfied: gitpython>3 in /home/tomek/miniconda3/lib/python3.9/site-packages (from scmrepo<2,>=1.0.0->dvc) (3.1.31)\n",
"Requirement already satisfied: cryptography>=3.1 in /home/tomek/miniconda3/lib/python3.9/site-packages (from asyncssh<3,>=2.13.1->scmrepo<2,>=1.0.0->dvc) (37.0.1)\n",
"Requirement already satisfied: cffi>=1.12 in /home/tomek/miniconda3/lib/python3.9/site-packages (from cryptography>=3.1->asyncssh<3,>=2.13.1->scmrepo<2,>=1.0.0->dvc) (1.15.0)\n",
"Requirement already satisfied: pycparser in /home/tomek/miniconda3/lib/python3.9/site-packages (from cffi>=1.12->cryptography>=3.1->asyncssh<3,>=2.13.1->scmrepo<2,>=1.0.0->dvc) (2.21)\n",
"Requirement already satisfied: gitdb<5,>=4.0.1 in /home/tomek/miniconda3/lib/python3.9/site-packages (from gitpython>3->scmrepo<2,>=1.0.0->dvc) (4.0.10)\n",
"Requirement already satisfied: smmap<6,>=3.0.1 in /home/tomek/miniconda3/lib/python3.9/site-packages (from gitdb<5,>=4.0.1->gitpython>3->scmrepo<2,>=1.0.0->dvc) (5.0.0)\n",
"Collecting orjson\n",
" Downloading orjson-3.8.10-cp39-cp39-manylinux_2_28_x86_64.whl (140 kB)\n",
"\u001b[K |████████████████████████████████| 140 kB 39.5 MB/s eta 0:00:01\n",
"\u001b[?25hRequirement already satisfied: setuptools in /home/tomek/miniconda3/lib/python3.9/site-packages (from zc.lockfile>=1.2.1->dvc) (61.2.0)\n",
"Requirement already satisfied: async-timeout<5.0,>=4.0.0a3 in /home/tomek/miniconda3/lib/python3.9/site-packages (from aiohttp->aiohttp-retry>=2.5.0->dvc-http>=2.29.0->dvc) (4.0.2)\n",
"Requirement already satisfied: multidict<7.0,>=4.5 in /home/tomek/miniconda3/lib/python3.9/site-packages (from aiohttp->aiohttp-retry>=2.5.0->dvc-http>=2.29.0->dvc) (6.0.4)\n",
"Requirement already satisfied: yarl<2.0,>=1.0 in /home/tomek/miniconda3/lib/python3.9/site-packages (from aiohttp->aiohttp-retry>=2.5.0->dvc-http>=2.29.0->dvc) (1.8.2)\n",
"Requirement already satisfied: aiosignal>=1.1.2 in /home/tomek/miniconda3/lib/python3.9/site-packages (from aiohttp->aiohttp-retry>=2.5.0->dvc-http>=2.29.0->dvc) (1.3.1)\n",
"Requirement already satisfied: frozenlist>=1.1.1 in /home/tomek/miniconda3/lib/python3.9/site-packages (from aiohttp->aiohttp-retry>=2.5.0->dvc-http>=2.29.0->dvc) (1.3.3)\n",
"Requirement already satisfied: wcwidth in /home/tomek/miniconda3/lib/python3.9/site-packages (from prompt-toolkit->click-repl>=0.2.0->celery<6,>=5.2.0->dvc-task<1,>=0.2.0->dvc) (0.2.6)\n",
"Building wheels for collected packages: antlr4-python3-runtime, nanotime\n",
" Building wheel for antlr4-python3-runtime (setup.py) ... \u001b[?25ldone\n",
"\u001b[?25h Created wheel for antlr4-python3-runtime: filename=antlr4_python3_runtime-4.9.3-py3-none-any.whl size=144575 sha256=94691fc7a4109d606872ddee3ae9575c3c9f9f945643a27b5514fce3176c552a\n",
" Stored in directory: /home/tomek/.cache/pip/wheels/23/cf/80/f3efa822e6ab23277902ee9165fe772eeb1dfb8014f359020a\n",
" Building wheel for nanotime (setup.py) ... \u001b[?25ldone\n",
"\u001b[?25h Created wheel for nanotime: filename=nanotime-0.5.2-py3-none-any.whl size=2441 sha256=42933d16d8f6362832282dea6b0b44f2bdd41b0eb0d68de121660a8a0db1f96c\n",
" Stored in directory: /home/tomek/.cache/pip/wheels/ee/1f/7c/610bdb7d5541b98d9743c5953e32681ef35dd54fadddd347e8\n",
"Successfully built antlr4-python3-runtime nanotime\n",
"Installing collected packages: vine, amqp, shortuuid, pygtrie, orjson, mdurl, kombu, funcy, click-repl, click-plugins, click-didyoumean, billiard, antlr4-python3-runtime, voluptuous, sqltrie, pygit2, psutil, pathspec, omegaconf, nanotime, markdown-it-py, dvc-objects, dulwich, distro, diskcache, dictdiffer, celery, atpublic, asyncssh, appdirs, aiohttp-retry, zc.lockfile, tomlkit, shtab, scmrepo, rich, pydot, networkx, iterative-telemetry, hydra-core, grandalf, flufl.lock, flatten-dict, dvc-task, dvc-studio-client, dvc-render, dvc-http, dvc-data, dpath, configobj, dvc\n",
"Successfully installed aiohttp-retry-2.8.3 amqp-5.1.1 antlr4-python3-runtime-4.9.3 appdirs-1.4.4 asyncssh-2.13.1 atpublic-3.1.1 billiard-3.6.4.0 celery-5.2.7 click-didyoumean-0.3.0 click-plugins-1.1.1 click-repl-0.2.0 configobj-5.0.8 dictdiffer-0.9.0 diskcache-5.6.1 distro-1.8.0 dpath-2.1.5 dulwich-0.21.3 dvc-2.55.0 dvc-data-0.47.2 dvc-http-2.30.2 dvc-objects-0.21.2 dvc-render-0.3.1 dvc-studio-client-0.8.0 dvc-task-0.2.0 flatten-dict-0.4.2 flufl.lock-7.1.1 funcy-2.0 grandalf-0.8 hydra-core-1.3.2 iterative-telemetry-0.0.8 kombu-5.2.4 markdown-it-py-2.2.0 mdurl-0.1.2 nanotime-0.5.2 networkx-3.1 omegaconf-2.3.0 orjson-3.8.10 pathspec-0.11.1 psutil-5.9.5 pydot-1.4.2 pygit2-1.12.0 pygtrie-2.5.0 rich-13.3.4 scmrepo-1.0.2 shortuuid-1.0.11 shtab-1.6.1 sqltrie-0.3.1 tomlkit-0.11.7 vine-5.0.0 voluptuous-0.13.1 zc.lockfile-3.0.post1\n"
2021-05-31 11:55:27 +02:00
]
}
],
"source": [
2022-05-23 09:57:46 +02:00
"!pip3 install dvc"
2021-05-31 11:55:27 +02:00
]
},
{
"cell_type": "markdown",
"id": "20975d62",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"Stwórzmy katalog, w którym będziemy przechowywać nasz projekt:"
]
},
{
"cell_type": "code",
2023-04-26 13:44:55 +02:00
"execution_count": 7,
"id": "4d94e912",
2021-05-31 11:55:27 +02:00
"metadata": {
"slideshow": {
2023-04-26 13:44:55 +02:00
"slide_type": "fragment"
2021-05-31 11:55:27 +02:00
}
},
"outputs": [],
"source": [
2023-04-26 13:44:55 +02:00
"!rm -r -f IUM_10/sample-ml-project-2023\n",
"!mkdir -p IUM_10/sample-ml-project-2023"
2021-05-31 11:55:27 +02:00
]
},
{
"cell_type": "code",
2023-04-26 13:44:55 +02:00
"execution_count": 8,
"id": "aae59ec2",
2021-05-31 11:55:27 +02:00
"metadata": {
"slideshow": {
2023-04-26 13:44:55 +02:00
"slide_type": "fragment"
2021-05-31 11:55:27 +02:00
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
2023-04-26 13:44:55 +02:00
"/home/tomek/repos/aitech-ium/IUM_10/sample-ml-project-2023/IUM_10/sample-ml-project-2023\n"
2021-05-31 11:55:27 +02:00
]
}
],
"source": [
"#Jupyter notebook magic https://ipython.readthedocs.io/en/stable/interactive/magics.html#magic-cd\n",
2023-04-26 13:44:55 +02:00
"%cd \"IUM_10/sample-ml-project-2023\""
2021-05-31 11:55:27 +02:00
]
},
{
"cell_type": "markdown",
"id": "199c0d92",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"Inicjalizujemy puste repozytorium Git (możemy też pominąć ten krok i działać w istniejącym już repozytorium)"
]
},
{
"cell_type": "code",
2023-04-26 13:44:55 +02:00
"execution_count": 9,
2021-05-31 11:55:27 +02:00
"id": "c13c525b",
"metadata": {
"slideshow": {
2023-04-26 13:44:55 +02:00
"slide_type": "fragment"
2021-05-31 11:55:27 +02:00
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
2023-04-26 13:44:55 +02:00
"Initialized empty Git repository in /home/tomek/repos/aitech-ium/IUM_10/sample-ml-project-2023/IUM_10/sample-ml-project-2023/.git/\r\n"
2021-05-31 11:55:27 +02:00
]
}
],
"source": [
"!git init"
]
},
{
"cell_type": "markdown",
"id": "c7155369",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"Teraz inicjalizujemy repozytorium DVC:"
]
},
{
"cell_type": "code",
2023-04-26 13:44:55 +02:00
"execution_count": 10,
2021-05-31 11:55:27 +02:00
"id": "44f28226",
"metadata": {
"slideshow": {
2023-04-26 13:44:55 +02:00
"slide_type": "fragment"
2021-05-31 11:55:27 +02:00
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
2023-04-26 13:44:55 +02:00
"Initialized DVC repository.\n",
"\n",
"You can now commit the changes to git.\n",
"\n",
"\u001b[31m+---------------------------------------------------------------------+\n",
"\u001b[0m\u001b[31m|\u001b[0m \u001b[31m|\u001b[0m\n",
"\u001b[31m|\u001b[0m DVC has enabled anonymous aggregate usage analytics. \u001b[31m|\u001b[0m\n",
"\u001b[31m|\u001b[0m Read the analytics documentation (and how to opt-out) here: \u001b[31m|\u001b[0m\n",
"\u001b[31m|\u001b[0m <\u001b[36mhttps://dvc.org/doc/user-guide/analytics\u001b[39m> \u001b[31m|\u001b[0m\n",
"\u001b[31m|\u001b[0m \u001b[31m|\u001b[0m\n",
"\u001b[31m+---------------------------------------------------------------------+\n",
"\u001b[0m\n",
"\u001b[33mWhat's next?\u001b[39m\n",
"\u001b[33m------------\u001b[39m\n",
"- Check out the documentation: <\u001b[36mhttps://dvc.org/doc\u001b[39m>\n",
"- Get help and share ideas: <\u001b[36mhttps://dvc.org/chat\u001b[39m>\n",
"- Star us on GitHub: <\u001b[36mhttps://github.com/iterative/dvc\u001b[39m>\n",
2021-05-31 11:55:27 +02:00
"\u001b[0m"
]
}
],
"source": [
"!dvc init"
]
},
{
"cell_type": "markdown",
"id": "00bc72ed",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"Zobaczmy jakie pliki dodał (również do repozytorium git) DVC.\n",
"Ich opis znajdziemy tutaj: https://dvc.org/doc/user-guide/project-structure/internal-files"
]
},
{
"cell_type": "code",
2023-04-26 13:44:55 +02:00
"execution_count": 11,
2021-05-31 11:55:27 +02:00
"id": "d1aefe16",
"metadata": {
"slideshow": {
2023-04-26 13:44:55 +02:00
"slide_type": "fragment"
2021-05-31 11:55:27 +02:00
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
2023-04-26 13:44:55 +02:00
"On branch main\r\n",
"\r\n",
"No commits yet\r\n",
"\r\n",
2021-05-31 11:55:27 +02:00
"Changes to be committed:\r\n",
2023-04-26 13:44:55 +02:00
" (use \"git rm --cached <file>...\" to unstage)\r\n",
"\t\u001b[32mnew file: .dvc/.gitignore\u001b[m\r\n",
"\t\u001b[32mnew file: .dvc/config\u001b[m\r\n",
"\t\u001b[32mnew file: .dvcignore\u001b[m\r\n",
2021-05-31 11:55:27 +02:00
"\r\n"
]
}
],
"source": [
"!git status"
]
},
2023-04-26 13:44:55 +02:00
{
"cell_type": "markdown",
"id": "b16a62e6",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"- `.dvc/config` - główny plik konfiguracyjny dvc\n",
"- `.dvc/config.local` - nadpisuje wartości z `config`, do lokalnych zmian nie commitowanych do repo\n",
"- `.dvc/.gitignore` - pliki dvc, które nie mają znaleźć się w repo\n",
"- `.dvcignore` - dvc pomija pliki zdefiniowane w tym pliku (np. aby poprawić wydajność)"
]
},
2021-05-31 11:55:27 +02:00
{
"cell_type": "markdown",
"id": "72e0a272",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"Możemy teraz zacommitować zmiany w git:"
]
},
{
"cell_type": "code",
2023-04-26 13:44:55 +02:00
"execution_count": 12,
2021-05-31 11:55:27 +02:00
"id": "59780e99",
"metadata": {
2022-05-29 09:51:07 +02:00
"scrolled": true,
2021-05-31 11:55:27 +02:00
"slideshow": {
2023-04-26 13:44:55 +02:00
"slide_type": "fragment"
2021-05-31 11:55:27 +02:00
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
2023-04-26 13:44:55 +02:00
"[main (root-commit) 6b03a40] Initial commit\r\n",
2022-05-29 09:51:07 +02:00
" 3 files changed, 6 insertions(+)\r\n",
" create mode 100644 .dvc/.gitignore\r\n",
" create mode 100644 .dvc/config\r\n",
" create mode 100644 .dvcignore\r\n"
2021-05-31 11:55:27 +02:00
]
}
],
"source": [
"!git commit -m \"Initial commit\""
]
},
{
"cell_type": "markdown",
"id": "a8861abe",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"Przygotujmy przykładowe dane, pobierając je z Kaggle:"
]
},
{
"cell_type": "code",
2023-04-26 13:44:55 +02:00
"execution_count": 13,
2021-05-31 11:55:27 +02:00
"id": "f05ece1b",
"metadata": {
"slideshow": {
2023-04-26 13:44:55 +02:00
"slide_type": "fragment"
2021-05-31 11:55:27 +02:00
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
2023-04-26 13:44:55 +02:00
"Downloading iris.zip to /home/tomek/repos/aitech-ium/IUM_10/sample-ml-project-2023/IUM_10/sample-ml-project-2023\n",
2021-05-31 11:55:27 +02:00
" 0%| | 0.00/3.60k [00:00<?, ?B/s]\n",
2023-04-26 13:44:55 +02:00
"100%|██████████████████████████████████████| 3.60k/3.60k [00:00<00:00, 3.38MB/s]\n",
2021-05-31 11:55:27 +02:00
"Archive: iris.zip\n",
" inflating: Iris.csv \n",
" inflating: database.sqlite \n"
]
}
],
"source": [
"!kaggle datasets download -d uciml/iris\n",
"!unzip -o iris.zip\n",
"!rm database.sqlite iris.zip\n",
"!mkdir -p data\n",
"!mv Iris.csv data/"
]
},
{
"cell_type": "markdown",
"id": "adb9a522",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"Teraz dodamy plik(i) z danymi do DVC:"
]
},
{
"cell_type": "code",
2023-04-26 13:44:55 +02:00
"execution_count": 14,
2021-05-31 11:55:27 +02:00
"id": "74d182c7",
"metadata": {
"slideshow": {
2023-04-26 13:44:55 +02:00
"slide_type": "fragment"
2021-05-31 11:55:27 +02:00
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[2K\u001b[32m⠋\u001b[0m Checking graph \u001b[32m⠋\u001b[0m Checking graph\n",
2021-05-31 11:55:27 +02:00
"Adding... \n",
"!\u001b[A\n",
2023-04-26 13:44:55 +02:00
" 0% Checking cache in '/home/tomek/repos/aitech-ium/IUM_10/sample-ml-project-20\u001b[A\n",
2022-05-29 09:51:07 +02:00
" \u001b[A\n",
"!\u001b[A\n",
2023-04-26 13:44:55 +02:00
" 0%| |Transferring 0/? [00:00<?, ?file/s]\u001b[A\n",
2022-05-29 09:51:07 +02:00
" 0%| |Transferring 0/1 [00:00<?, ?file/s]\u001b[A\n",
2023-04-26 13:44:55 +02:00
"100% Adding...|████████████████████████████████████████|1/1 [00:00, 13.53file/s]\u001b[A\n",
2021-05-31 11:55:27 +02:00
"\n",
"To track the changes with git, run:\n",
"\n",
2023-04-26 13:44:55 +02:00
"\tgit add data/Iris.csv.dvc data/.gitignore\n",
2022-05-29 09:51:07 +02:00
"\n",
"To enable auto staging, run:\n",
"\n",
"\tdvc config core.autostage true\n",
2021-05-31 11:55:27 +02:00
"\u001b[0m"
]
}
],
"source": [
"!dvc add data/Iris.csv"
]
},
{
"cell_type": "markdown",
"id": "72c6b5d0",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
" - DVC utworzył plik `data/Iris.csv.dvc` i dadał oryginalny plik do `.gitignore`\n",
" - W repozytorium będzie obecny tylko plik `*.dvc`, zawierający odnośnik do prawdziwego pliku"
]
},
{
"cell_type": "code",
2023-04-26 13:44:55 +02:00
"execution_count": 16,
2021-05-31 11:55:27 +02:00
"id": "74d54652",
"metadata": {
"slideshow": {
2023-04-26 13:44:55 +02:00
"slide_type": "fragment"
2021-05-31 11:55:27 +02:00
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
2023-04-26 13:44:55 +02:00
"On branch main\r\n",
"Untracked files:\r\n",
" (use \"git add <file>...\" to include in what will be committed)\r\n",
"\t\u001b[31mdata/.gitignore\u001b[m\r\n",
"\t\u001b[31mdata/Iris.csv.dvc\u001b[m\r\n",
2021-05-31 11:55:27 +02:00
"\r\n",
2023-04-26 13:44:55 +02:00
"nothing added to commit but untracked files present (use \"git add\" to track)\r\n"
2021-05-31 11:55:27 +02:00
]
}
],
"source": [
"!git status -u"
]
},
{
"cell_type": "markdown",
"id": "8589fecf",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"Dodajmy pliki `data/Iris.csv.dvc data/.gitignore` do repozytorium git, zgodnie z sugestią DVC:"
]
},
{
"cell_type": "code",
2023-04-26 13:44:55 +02:00
"execution_count": 17,
2021-05-31 11:55:27 +02:00
"id": "460c4a17",
"metadata": {
"slideshow": {
2023-04-26 13:44:55 +02:00
"slide_type": "fragment"
2021-05-31 11:55:27 +02:00
}
},
"outputs": [],
"source": [
"!git add data/Iris.csv.dvc data/.gitignore"
]
},
{
"cell_type": "code",
2023-04-26 13:44:55 +02:00
"execution_count": 18,
2021-05-31 11:55:27 +02:00
"id": "80644077",
"metadata": {
"slideshow": {
2023-04-26 13:44:55 +02:00
"slide_type": "fragment"
2021-05-31 11:55:27 +02:00
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
2023-04-26 13:44:55 +02:00
"[main 812cb53] Dodano dane IRIS (DVC)\r\n",
" 2 files changed, 5 insertions(+)\r\n",
" create mode 100644 data/.gitignore\r\n",
" create mode 100644 data/Iris.csv.dvc\r\n"
2021-05-31 11:55:27 +02:00
]
}
],
"source": [
"!git commit -m \"Dodano dane IRIS (DVC)\""
]
},
{
"cell_type": "markdown",
"id": "03899863",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"Plik `*.dvc` zawiera m.in. hash pliku. Więcej o plikach `*.dvc`: [link](https://dvc.org/doc/user-guide/project-structure/dvc-files)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8cb2ba7c",
"metadata": {
"slideshow": {
2023-04-26 13:44:55 +02:00
"slide_type": "fragment"
2021-05-31 11:55:27 +02:00
}
},
"outputs": [],
"source": [
"# %load data/Iris.csv.dvc\n",
"outs:\n",
"- md5: 717820ef0af287ff346c5cabfb4c612c\n",
" size: 5107\n",
" path: Iris.csv\n"
]
},
{
"cell_type": "markdown",
"id": "0b421d45",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"Oryginalny plik `Iris.csv` został przeniesiony do katalogu ./dvc/cache/{wartość hash pliku) i podlinkowany z powrotem do oryginalnej lokalizacji. Sposób tworzenia linków może być [różny w zależności od systemu plików](https://dvc.org/doc/user-guide/large-dataset-optimization)."
]
},
{
"cell_type": "code",
2023-04-26 13:44:55 +02:00
"execution_count": 25,
2021-05-31 11:55:27 +02:00
"id": "1d471f3a",
"metadata": {
"slideshow": {
2023-04-26 13:44:55 +02:00
"slide_type": "fragment"
2021-05-31 11:55:27 +02:00
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"total 8\r\n",
2022-05-29 09:51:07 +02:00
"-r--r--r-- 1 tomek tomek 5107 Sep 19 2019 7820ef0af287ff346c5cabfb4c612c\r\n"
2021-05-31 11:55:27 +02:00
]
}
],
"source": [
"!ls -l .dvc/cache/71"
]
},
2022-05-23 09:57:46 +02:00
{
"cell_type": "code",
2023-04-26 13:44:55 +02:00
"execution_count": 33,
"id": "32531aa8",
2022-05-23 09:57:46 +02:00
"metadata": {
"slideshow": {
2023-04-26 13:44:55 +02:00
"slide_type": "fragment"
2022-05-23 09:57:46 +02:00
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
2023-04-26 13:44:55 +02:00
"Id,SepalLengthCm,SepalWidthCm,PetalLengthCm,PetalWidthCm,Species\r\n",
"1,5.1,3.5,1.4,0.2,Iris-setosa\r\n",
"2,4.9,3.0,1.4,0.2,Iris-setosa\r\n"
2022-05-23 09:57:46 +02:00
]
}
],
"source": [
2023-04-26 13:44:55 +02:00
"!head -n 3 .dvc/cache/71/7820ef0af287ff346c5cabfb4c612c"
]
},
{
"cell_type": "code",
"execution_count": 35,
"id": "2396c762",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Enumerating objects: 11, done.\n",
"Counting objects: 100% (11/11), done.\n",
"Delta compression using up to 4 threads\n",
"Compressing objects: 100% (8/8), done.\n",
"Writing objects: 100% (11/11), 889 bytes | 889.00 KiB/s, done.\n",
"Total 11 (delta 1), reused 0 (delta 0), pack-reused 0\n",
"remote: \n",
"remote: Create a new pull request for 'main':\u001b[K\n",
"remote: https://git.wmi.amu.edu.pl/tzietkiewicz/sample-ml-project/compare/master...main\u001b[K\n",
"remote: \n",
"remote: . Processing 1 references\u001b[K\n",
"remote: Processed 1 references in total\u001b[K\n",
"To git.wmi.amu.edu.pl:tzietkiewicz/sample-ml-project.git\n",
" * [new branch] main -> main\n",
"Branch 'main' set up to track remote branch 'main' from 'origin'.\n"
]
}
],
"source": [
"!git remote add origin git@git.wmi.amu.edu.pl:tzietkiewicz/sample-ml-project.git\n",
"!git push --set-upstream origin main"
2022-05-23 09:57:46 +02:00
]
},
2021-05-31 11:55:27 +02:00
{
"cell_type": "markdown",
"id": "901e8e90",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## dvc remote\n",
" - żeby wysłać właściwe pliki śledzone przez DVC do zdalnej lokalizacji (z której będą mogłby być pobrane np. przez system CI albo innych użytkowników) musimy mieć skonfigurowaną taką lokazliację\n",
" - służy do tego polecenie [`dvc remote add`](https://dvc.org/doc/command-reference/remote/add)\n",
" - użyjemy lokalnego \"remote\". Tutaj będzie to po prostu utworzony wcześniej katalog `/dvcstore`. Taki katalog istnieje też na naszym Jenkinsie, oczywiście należy go podmontować w Dockerze\n",
" - w realnych zastosowaniach podalibyśmy tutaj ścieżkę do jakiegoś zasobu dostępnego przez inernet jak np. serwer SFTP, ścieżka do AWS S3 itp."
]
},
2022-05-23 09:57:46 +02:00
{
"cell_type": "markdown",
2022-05-29 09:51:07 +02:00
"id": "53429521",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
2022-05-23 09:57:46 +02:00
"source": [
"Obsługiwane typy zdalnych lokalizacji (remotes): https://dvc.org/doc/command-reference/remote/add#supported-storage-types\n",
" - Amazon S3\n",
" - S3-compatible storage\n",
" - Microsoft Azure Blob Storage\n",
" - Google Drive\n",
" - Google Cloud Storage\n",
" - Aliyun OSS\n",
" - SSH\n",
" - HDFS\n",
" - WebHDFS\n",
" - HTTP\n",
" - WebDAV\n",
" - local remote"
]
},
2023-04-26 13:44:55 +02:00
{
"cell_type": "markdown",
"id": "507e3a09",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"#### Dodawanie remote typu local"
]
},
2021-05-31 11:55:27 +02:00
{
"cell_type": "code",
2022-05-29 09:51:07 +02:00
"execution_count": 71,
"id": "a16f2bfa",
2021-05-31 11:55:27 +02:00
"metadata": {
"slideshow": {
2023-04-26 13:44:55 +02:00
"slide_type": "fragment"
2021-05-31 11:55:27 +02:00
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
2022-05-29 09:51:07 +02:00
"Setting 'my_local_remote' as a default remote.\n",
2021-05-31 11:55:27 +02:00
"\u001b[0m"
]
}
],
"source": [
"!dvc remote add -d my_local_remote /dvcstore"
]
},
{
"cell_type": "code",
2022-05-29 09:51:07 +02:00
"execution_count": 25,
2021-05-31 11:55:27 +02:00
"id": "9c3deeaf",
"metadata": {
"slideshow": {
2023-04-26 13:44:55 +02:00
"slide_type": "fragment"
2021-05-31 11:55:27 +02:00
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"On branch master\r\n",
2022-05-29 09:51:07 +02:00
"nothing to commit, working tree clean\r\n"
2021-05-31 11:55:27 +02:00
]
}
],
"source": [
"!git status"
]
},
{
"cell_type": "code",
2023-04-26 13:44:55 +02:00
"execution_count": 34,
2021-05-31 11:55:27 +02:00
"id": "899eac7d",
"metadata": {
"slideshow": {
2023-04-26 13:44:55 +02:00
"slide_type": "fragment"
2021-05-31 11:55:27 +02:00
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
2023-04-26 13:44:55 +02:00
"On branch main\r\n",
2022-05-29 09:51:07 +02:00
"nothing to commit, working tree clean\r\n"
2021-05-31 11:55:27 +02:00
]
}
],
"source": [
"!git add .dvc/config\n",
"!git commit -m \"Added DVC remote\""
]
},
{
"cell_type": "markdown",
"id": "8c556c96",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## dvc push\n",
"Kiedy mamy już skonfigurowany \"remote\" możemy wypchnąć do niego pliki korzystając z polecenia `dvc push`:"
]
},
{
"cell_type": "code",
2022-05-29 09:51:07 +02:00
"execution_count": 28,
2021-06-04 15:52:21 +02:00
"id": "c7f24f75",
2021-09-28 10:56:21 +02:00
"metadata": {
"slideshow": {
2023-04-26 13:44:55 +02:00
"slide_type": "fragment"
2021-09-28 10:56:21 +02:00
}
},
2022-05-29 09:51:07 +02:00
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" 0% Transferring| |0/1 [00:00<?, ?file/s]\n",
"!\u001b[A\n",
" 0%| |7820ef0af287ff346c5cabfb4c612c 0.00/? [00:00<?, ?B/s]\u001b[A\n",
" 0%| |7820ef0af287ff346c5cabfb4c612c 0.00/4.99k [00:00<?, ?B/s]\u001b[A\n",
"1 file pushed \u001b[A\n",
"\u001b[0m"
]
}
],
2021-05-31 11:55:27 +02:00
"source": [
"!dvc push"
]
},
{
"cell_type": "code",
2022-05-29 09:51:07 +02:00
"execution_count": 31,
2021-05-31 11:55:27 +02:00
"id": "8a355575",
"metadata": {
"slideshow": {
2023-04-26 13:44:55 +02:00
"slide_type": "fragment"
2021-05-31 11:55:27 +02:00
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
2022-05-29 09:51:07 +02:00
"\u001b[34;42m/dvcstore\u001b[0m\r\n",
"└── \u001b[01;34m71\u001b[0m\r\n",
2021-05-31 11:55:27 +02:00
" └── 7820ef0af287ff346c5cabfb4c612c\r\n",
"\r\n",
"1 directory, 1 file\r\n"
]
}
],
"source": [
"!tree /dvcstore"
]
},
{
"cell_type": "markdown",
"id": "af59ecb3",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## dvc pull\n",
"Żeby pobrać dane z DVC (np. w innej lokalizacji, przez innego użytkownika), musimy:\n",
" - sklonować repozytorium git (żeby m.in. pobrać pliki `*.dvc`\n",
" - wykonać `dvc pull`"
]
},
{
"cell_type": "markdown",
"id": "9fa914a7",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
2022-05-23 09:57:46 +02:00
"Dodawanie nowych plików i modyfikacja istniejących wygląda podobnie jak przy zwykłych plikach śledzonych przez git, tylko zamiast `git` używamy polecenia `dvc` a dodatkowo pamiętamy o zarządzaniu plikami `*.dvc` za pomocą gita:"
2021-05-31 11:55:27 +02:00
]
},
{
"cell_type": "code",
"execution_count": 12,
2021-05-31 11:55:27 +02:00
"id": "dde39796",
"metadata": {
"slideshow": {
2023-04-26 13:44:55 +02:00
"slide_type": "fragment"
2021-05-31 11:55:27 +02:00
}
},
"outputs": [],
"source": [
"!head -n -1 data/Iris.csv | sponge data/Iris.csv"
]
},
{
"cell_type": "code",
"execution_count": 13,
2021-05-31 11:55:27 +02:00
"id": "7f14ec60",
"metadata": {
"slideshow": {
2023-04-26 13:44:55 +02:00
"slide_type": "fragment"
2021-05-31 11:55:27 +02:00
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"On branch master\r\n",
"nothing to commit, working tree clean\r\n"
]
}
],
"source": [
"!git status"
]
},
{
"cell_type": "code",
"execution_count": 14,
2021-05-31 11:55:27 +02:00
"id": "8a841039",
"metadata": {
"slideshow": {
2023-04-26 13:44:55 +02:00
"slide_type": "fragment"
2021-05-31 11:55:27 +02:00
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"data/Iris.csv.dvc: core\u001b[39m>\n",
"\tchanged outs:\n",
"\t\tmodified: data/Iris.csv\n",
"\u001b[0m"
]
}
],
"source": [
"!dvc status"
]
},
{
"cell_type": "code",
"execution_count": 15,
2021-05-31 11:55:27 +02:00
"id": "bf6c1067",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
2022-05-29 09:51:07 +02:00
"\u001b[2K\u001b[32m⠹\u001b[0m Checking graph \u001b[32m⠋\u001b[0m Checking graph\n",
2021-05-31 11:55:27 +02:00
"Adding... \n",
"!\u001b[A\n",
2022-05-29 09:51:07 +02:00
" 0% Checking cache in '/home/tomek/repos/aitech-ium/IUM_10/sample-ml-project/.d\u001b[A\n",
" \u001b[A\n",
"!\u001b[A\n",
" 0%| |Transferring 0/1 [00:00<?, ?file/s]\u001b[A\n",
" \u001b[A\n",
"!\u001b[A\n",
" 0%| |.AquCc93WCb2aAJ98voTeFG.tmp 0.00/? [00:00<?, ?B/s]\u001b[A\n",
" 0%| |.AquCc93WCb2aAJ98voTeFG.tmp 0.00/4.00 [00:00<?, ?B/s]\u001b[A\n",
2022-05-29 09:51:07 +02:00
" \u001b[A\n",
"!\u001b[A\n",
" 0%| |4705c4d470a4d9dd152808e5e9f56f 0.00/? [00:00<?, ?B/s]\u001b[A\n",
" 0%| |4705c4d470a4d9dd152808e5e9f56f 0.00/4.92k [00:00<?, ?B/s]\u001b[A\n",
"100% Adding...|████████████████████████████████████████|1/1 [00:00, 11.09file/s]\u001b[A\n",
2021-05-31 11:55:27 +02:00
"\n",
"To track the changes with git, run:\n",
"\n",
2022-05-29 09:51:07 +02:00
" git add data/Iris.csv.dvc\n",
"\n",
"To enable auto staging, run:\n",
"\n",
"\tdvc config core.autostage true\n",
2021-05-31 11:55:27 +02:00
"\u001b[0m"
]
}
],
"source": [
"!dvc add data/Iris.csv"
]
},
{
"cell_type": "code",
"execution_count": 16,
2021-05-31 11:55:27 +02:00
"id": "4a4865c9",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[master 5379e3b] Removed last line from Iris dataset\r\n",
2021-05-31 11:55:27 +02:00
" 1 file changed, 2 insertions(+), 2 deletions(-)\r\n"
]
}
],
"source": [
"!git add data/Iris.csv.dvc\n",
"!git commit -m \"Removed last line from Iris dataset\"\n"
]
},
{
"cell_type": "markdown",
"id": "d710977c",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"### dvc checkout\n",
" - Polecenia `dvc checkout` używamy razem z `git checkout`, żeby zmienić branch, na którym pracujemy.\n",
" - DVC podmieni wersje plików śledzonych przez siebie na pochodzące z innego brancha (o ile pliki te się różnią i różnią się pliki `*.dvc` w odpowiednich branchach\n",
" - zmiana brancha przez git powoduje (ewentualną) zmianę plików `*.dvc` a `dvc checkout` kopiuje/linkuje pliki z katalogu `.dvc/cache` o wartościach hash odpowiadających tym z plików `*.dvc`"
]
},
{
"cell_type": "markdown",
"id": "5897e8eb",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## Wymiana danych między projektami\n",
" - za pomocą poleceń `dvc import` i `dvc update` możemy dodać i później aktualizować pliki śledzone przez DVC w innym repozytorium"
]
},
{
"cell_type": "code",
"execution_count": 48,
"id": "9b018146",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Importing 'get-started/data.xml (https://github.com/iterative/dataset-registry)' -> 'data/data.xml'\n",
" 0% Downloading| |0/1 [00:00<?, ?file/s]\n",
"!\u001b[A\n",
" 0%| |get-started/data.xml 0.00/37.9M [00:00<?, ?it/s]\u001b[A\n",
" 0%| |get-started/data.xml 64.0k/36.1M [00:00<02:12, 286kB/s]\u001b[A\n",
" 0%| |get-started/data.xml 128k/36.1M [00:00<01:33, 403kB/s]\u001b[A\n",
" 1%| |get-started/data.xml 256k/36.1M [00:00<00:57, 658kB/s]\u001b[A\n",
" 1%| |get-started/data.xml 384k/36.1M [00:00<00:45, 818kB/s]\u001b[A\n",
" 1%|▏ |get-started/data.xml 512k/36.1M [00:00<00:53, 693kB/s]\u001b[A\n",
" 2%|▏ |get-started/data.xml 640k/36.1M [00:01<00:57, 644kB/s]\u001b[A\n",
" 2%|▏ |get-started/data.xml 768k/36.1M [00:01<00:59, 619kB/s]\u001b[A\n",
" 2%|▏ |get-started/data.xml 896k/36.1M [00:01<00:51, 718kB/s]\u001b[A\n",
" 3%|▎ |get-started/data.xml 1.00M/36.1M [00:01<00:55, 666kB/s]\u001b[A\n",
" 3%|▎ |get-started/data.xml 1.12M/36.1M [00:01<00:57, 633kB/s]\u001b[A\n",
" 3%|▎ |get-started/data.xml 1.25M/36.1M [00:02<00:57, 638kB/s]\u001b[A\n",
" 4%|▍ |get-started/data.xml 1.38M/36.1M [00:02<00:52, 698kB/s]\u001b[A\n",
" 4%|▍ |get-started/data.xml 1.50M/36.1M [00:02<00:55, 656kB/s]\u001b[A\n",
" 4%|▍ |get-started/data.xml 1.62M/36.1M [00:02<00:57, 628kB/s]\u001b[A\n",
" 5%|▍ |get-started/data.xml 1.69M/36.1M [00:02<00:58, 618kB/s]\u001b[A\n",
" 5%|▌ |get-started/data.xml 1.81M/36.1M [00:02<00:53, 675kB/s]\u001b[A\n",
" 5%|▌ |get-started/data.xml 1.94M/36.1M [00:03<00:53, 672kB/s]\u001b[A\n",
" 6%|▌ |get-started/data.xml 2.06M/36.1M [00:03<00:55, 642kB/s]\u001b[A\n",
" 6%|▌ |get-started/data.xml 2.12M/36.1M [00:03<00:56, 628kB/s]\u001b[A\n",
" 6%|▌ |get-started/data.xml 2.19M/36.1M [00:03<00:57, 616kB/s]\u001b[A\n",
" 6%|▌ |get-started/data.xml 2.25M/36.1M [00:03<00:58, 606kB/s]\u001b[A\n",
" 7%|▋ |get-started/data.xml 2.38M/36.1M [00:03<00:48, 732kB/s]\u001b[A\n",
" 7%|▋ |get-started/data.xml 2.50M/36.1M [00:04<00:52, 666kB/s]\u001b[A\n",
" 7%|▋ |get-started/data.xml 2.62M/36.1M [00:04<00:55, 636kB/s]\u001b[A\n",
" 8%|▊ |get-started/data.xml 2.75M/36.1M [00:04<00:56, 614kB/s]\u001b[A\n",
" 8%|▊ |get-started/data.xml 2.88M/36.1M [00:04<00:49, 711kB/s]\u001b[A\n",
" 8%|▊ |get-started/data.xml 3.00M/36.1M [00:04<00:52, 663kB/s]\u001b[A\n",
" 9%|▊ |get-started/data.xml 3.12M/36.1M [00:05<00:54, 637kB/s]\u001b[A\n",
" 9%|▉ |get-started/data.xml 3.25M/36.1M [00:05<00:55, 623kB/s]\u001b[A\n",
" 9%|▉ |get-started/data.xml 3.38M/36.1M [00:05<00:48, 710kB/s]\u001b[A\n",
" 10%|▉ |get-started/data.xml 3.50M/36.1M [00:05<00:51, 664kB/s]\u001b[A\n",
" 10%|█ |get-started/data.xml 3.62M/36.1M [00:05<00:45, 751kB/s]\u001b[A\n",
" 10%|█ |get-started/data.xml 3.75M/36.1M [00:05<00:49, 691kB/s]\u001b[A\n",
" 11%|█ |get-started/data.xml 3.88M/36.1M [00:06<00:43, 777kB/s]\u001b[A\n",
" 11%|█ |get-started/data.xml 4.00M/36.1M [00:06<00:47, 705kB/s]\u001b[A\n",
" 11%|█▏ |get-started/data.xml 4.12M/36.1M [00:06<00:42, 790kB/s]\u001b[A\n",
" 12%|█▏ |get-started/data.xml 4.25M/36.1M [00:06<00:46, 716kB/s]\u001b[A\n",
" 12%|█▏ |get-started/data.xml 4.38M/36.1M [00:06<00:44, 749kB/s]\u001b[A\n",
" 12%|█▏ |get-started/data.xml 4.50M/36.1M [00:07<00:45, 734kB/s]\u001b[A\n",
" 13%|█▎ |get-started/data.xml 4.62M/36.1M [00:07<00:40, 810kB/s]\u001b[A\n",
" 13%|█▎ |get-started/data.xml 4.75M/36.1M [00:07<00:42, 773kB/s]\u001b[A\n",
" 13%|█▎ |get-started/data.xml 4.88M/36.1M [00:07<00:41, 795kB/s]\u001b[A\n",
" 14%|█▍ |get-started/data.xml 5.00M/36.1M [00:07<00:37, 870kB/s]\u001b[A\n",
" 14%|█▍ |get-started/data.xml 5.12M/36.1M [00:07<00:34, 932kB/s]\u001b[A\n",
" 15%|█▍ |get-started/data.xml 5.25M/36.1M [00:07<00:35, 916kB/s]\u001b[A\n",
" 15%|█▍ |get-started/data.xml 5.38M/36.1M [00:08<00:35, 898kB/s]\u001b[A\n",
" 15%|█▌ |get-started/data.xml 5.50M/36.1M [00:08<00:33, 962kB/s]\u001b[A\n",
" 16%|█▌ |get-started/data.xml 5.62M/36.1M [00:08<00:33, 949kB/s]\u001b[A\n",
" 16%|█▌ |get-started/data.xml 5.75M/36.1M [00:08<00:31, 1.00MB/s]\u001b[A\n",
" 16%|█▋ |get-started/data.xml 5.88M/36.1M [00:08<00:30, 1.04MB/s]\u001b[A\n",
" 17%|█▋ |get-started/data.xml 6.06M/36.1M [00:08<00:26, 1.19MB/s]\u001b[A\n",
" 17%|█▋ |get-started/data.xml 6.19M/36.1M [00:08<00:26, 1.19MB/s]\u001b[A\n",
" 17%|█▋ |get-started/data.xml 6.31M/36.1M [00:08<00:26, 1.19MB/s]\u001b[A\n",
" 18%|█▊ |get-started/data.xml 6.50M/36.1M [00:08<00:23, 1.31MB/s]\u001b[A\n",
" 18%|█▊ |get-started/data.xml 6.62M/36.1M [00:09<00:23, 1.30MB/s]\u001b[A\n",
" 19%|█▉ |get-started/data.xml 6.81M/36.1M [00:09<00:21, 1.41MB/s]\u001b[A\n",
" 19%|█▉ |get-started/data.xml 7.00M/36.1M [00:09<00:20, 1.48MB/s]\u001b[A\n",
" 20%|█▉ |get-started/data.xml 7.19M/36.1M [00:09<00:19, 1.54MB/s]\u001b[A\n",
" 20%|██ |get-started/data.xml 7.38M/36.1M [00:09<00:18, 1.60MB/s]\u001b[A\n",
" 21%|██ |get-started/data.xml 7.56M/36.1M [00:09<00:18, 1.62MB/s]\u001b[A\n",
" 21%|██▏ |get-started/data.xml 7.75M/36.1M [00:09<00:17, 1.68MB/s]\u001b[A\n",
" 22%|██▏ |get-started/data.xml 7.94M/36.1M [00:09<00:17, 1.70MB/s]\u001b[A\n",
" 22%|██▏ |get-started/data.xml 8.12M/36.1M [00:10<00:17, 1.72MB/s]\u001b[A\n",
" 23%|██▎ |get-started/data.xml 8.38M/36.1M [00:10<00:15, 1.88MB/s]\u001b[A\n",
" 24%|██▎ |get-started/data.xml 8.56M/36.1M [00:10<00:15, 1.84MB/s]\u001b[A\n",
" 24%|██▍ |get-started/data.xml 8.81M/36.1M [00:10<00:14, 1.96MB/s]\u001b[A\n",
" 25%|██▌ |get-started/data.xml 9.06M/36.1M [00:10<00:13, 2.06MB/s]\u001b[A\n",
" 26%|██▌ |get-started/data.xml 9.31M/36.1M [00:10<00:13, 2.14MB/s]\u001b[A\n",
" 27%|██▋ |get-started/data.xml 9.62M/36.1M [00:10<00:11, 2.32MB/s]\u001b[A\n",
" 27%|██▋ |get-started/data.xml 9.88M/36.1M [00:10<00:11, 2.33MB/s]\u001b[A\n",
" 28%|██▊ |get-started/data.xml 10.2M/36.1M [00:10<00:11, 2.46MB/s]\u001b[A\n",
" 29%|██▉ |get-started/data.xml 10.4M/36.1M [00:11<00:10, 2.45MB/s]\u001b[A\n",
" 30%|██▉ |get-started/data.xml 10.8M/36.1M [00:11<00:10, 2.57MB/s]\u001b[A\n",
" 31%|███ |get-started/data.xml 11.1M/36.1M [00:11<00:09, 2.67MB/s]\u001b[A\n",
" 32%|███▏ |get-started/data.xml 11.4M/36.1M [00:11<00:09, 2.84MB/s]\u001b[A\n",
" 33%|███▎ |get-started/data.xml 11.8M/36.1M [00:11<00:08, 2.85MB/s]\u001b[A\n",
" 34%|███▎ |get-started/data.xml 12.1M/36.1M [00:11<00:08, 3.01MB/s]\u001b[A\n",
" 35%|███▍ |get-started/data.xml 12.5M/36.1M [00:11<00:07, 3.12MB/s]\u001b[A\n",
" 36%|███▌ |get-started/data.xml 12.9M/36.1M [00:11<00:07, 3.22MB/s]\u001b[A\n",
" 37%|███▋ |get-started/data.xml 13.2M/36.1M [00:11<00:07, 3.31MB/s]\u001b[A\n",
" 38%|███▊ |get-started/data.xml 13.7M/36.1M [00:12<00:06, 3.49MB/s]\u001b[A\n",
" 39%|███▉ |get-started/data.xml 14.1M/36.1M [00:12<00:06, 3.62MB/s]\u001b[A\n",
" 40%|████ |get-started/data.xml 14.6M/36.1M [00:12<00:06, 3.74MB/s]\u001b[A\n",
" 42%|████▏ |get-started/data.xml 15.0M/36.1M [00:12<00:05, 3.82MB/s]\u001b[A\n",
" 43%|████▎ |get-started/data.xml 15.4M/36.1M [00:12<00:05, 3.97MB/s]\u001b[A\n",
" 44%|████▍ |get-started/data.xml 15.9M/36.1M [00:12<00:05, 4.08MB/s]\u001b[A\n",
" 45%|████▌ |get-started/data.xml 16.4M/36.1M [00:12<00:04, 4.23MB/s]\u001b[A\n",
" 47%|████▋ |get-started/data.xml 17.0M/36.1M [00:12<00:04, 4.44MB/s]\u001b[A\n",
" 48%|████▊ |get-started/data.xml 17.5M/36.1M [00:12<00:04, 4.52MB/s]\u001b[A\n",
" 50%|████▉ |get-started/data.xml 18.1M/36.1M [00:13<00:04, 4.69MB/s]\u001b[A\n",
" 52%|█████▏ |get-started/data.xml 18.6M/36.1M [00:13<00:03, 4.84MB/s]\u001b[A\n",
" 53%|█████▎ |get-started/data.xml 19.2M/36.1M [00:13<00:03, 5.05MB/s]\u001b[A\n",
" 55%|█████▍ |get-started/data.xml 19.8M/36.1M [00:13<00:03, 5.16MB/s]\u001b[A\n",
2021-06-04 15:52:21 +02:00
" 57%|█████▋ |get-started/data.xml 20.4M/36.1M [00:13<00:03, 5.35MB/s]\u001b[A\n",
2021-05-31 11:55:27 +02:00
" 58%|█████▊ |get-started/data.xml 21.1M/36.1M [00:13<00:02, 5.49MB/s]\u001b[A\n",
" 60%|██████ |get-started/data.xml 21.8M/36.1M [00:13<00:02, 5.66MB/s]\u001b[A\n",
" 62%|██████▏ |get-started/data.xml 22.4M/36.1M [00:13<00:02, 5.83MB/s]\u001b[A\n",
" 64%|██████▍ |get-started/data.xml 23.2M/36.1M [00:14<00:02, 6.05MB/s]\u001b[A\n",
" 66%|██████▌ |get-started/data.xml 23.9M/36.1M [00:14<00:02, 6.20MB/s]\u001b[A\n",
" 68%|██████▊ |get-started/data.xml 24.6M/36.1M [00:14<00:01, 6.40MB/s]\u001b[A\n",
" 70%|███████ |get-started/data.xml 25.4M/36.1M [00:14<00:01, 6.51MB/s]\u001b[A\n",
" 72%|███████▏ |get-started/data.xml 26.0M/36.1M [00:14<00:01, 5.75MB/s]\u001b[A\n",
" 74%|███████▎ |get-started/data.xml 26.6M/36.1M [00:14<00:02, 4.26MB/s]\u001b[A\n",
" 75%|███████▍ |get-started/data.xml 27.1M/36.1M [00:14<00:02, 3.53MB/s]\u001b[A\n",
" 76%|███████▌ |get-started/data.xml 27.5M/36.1M [00:15<00:02, 3.26MB/s]\u001b[A\n",
" 77%|███████▋ |get-started/data.xml 27.9M/36.1M [00:15<00:02, 3.00MB/s]\u001b[A\n",
" 78%|███████▊ |get-started/data.xml 28.2M/36.1M [00:15<00:02, 2.95MB/s]\u001b[A\n",
" 79%|███████▉ |get-started/data.xml 28.5M/36.1M [00:15<00:02, 2.91MB/s]\u001b[A\n",
" 80%|███████▉ |get-started/data.xml 28.8M/36.1M [00:15<00:02, 2.88MB/s]\u001b[A\n",
" 81%|████████ |get-started/data.xml 29.1M/36.1M [00:15<00:02, 2.86MB/s]\u001b[A\n",
" 81%|████████▏ |get-started/data.xml 29.4M/36.1M [00:15<00:02, 2.84MB/s]\u001b[A\n",
" 82%|████████▏ |get-started/data.xml 29.8M/36.1M [00:16<00:02, 2.83MB/s]\u001b[A\n",
" 83%|████████▎ |get-started/data.xml 30.1M/36.1M [00:16<00:02, 2.83MB/s]\u001b[A\n",
" 84%|████████▍ |get-started/data.xml 30.4M/36.1M [00:16<00:02, 2.83MB/s]\u001b[A\n",
" 85%|████████▍ |get-started/data.xml 30.7M/36.1M [00:16<00:02, 2.83MB/s]\u001b[A\n",
" 86%|████████▌ |get-started/data.xml 31.0M/36.1M [00:16<00:01, 2.83MB/s]\u001b[A\n",
" 87%|████████▋ |get-started/data.xml 31.3M/36.1M [00:16<00:01, 2.83MB/s]\u001b[A\n",
" 88%|████████▊ |get-started/data.xml 31.6M/36.1M [00:16<00:01, 2.83MB/s]\u001b[A\n",
" 88%|████████▊ |get-started/data.xml 31.9M/36.1M [00:16<00:01, 2.84MB/s]\u001b[A\n",
" 89%|████████▉ |get-started/data.xml 32.2M/36.1M [00:16<00:01, 2.85MB/s]\u001b[A\n",
" 90%|█████████ |get-started/data.xml 32.6M/36.1M [00:17<00:01, 2.85MB/s]\u001b[A\n",
" 91%|█████████ |get-started/data.xml 32.9M/36.1M [00:17<00:01, 2.86MB/s]\u001b[A\n",
" 92%|█████████▏|get-started/data.xml 33.2M/36.1M [00:17<00:01, 2.86MB/s]\u001b[A\n",
" 93%|█████████▎|get-started/data.xml 33.5M/36.1M [00:17<00:00, 2.87MB/s]\u001b[A\n",
" 94%|█████████▎|get-started/data.xml 33.8M/36.1M [00:17<00:00, 2.87MB/s]\u001b[A\n",
" 94%|█████████▍|get-started/data.xml 34.1M/36.1M [00:17<00:00, 2.87MB/s]\u001b[A\n",
" 95%|█████████▌|get-started/data.xml 34.4M/36.1M [00:17<00:00, 2.87MB/s]\u001b[A\n",
" 96%|█████████▌|get-started/data.xml 34.8M/36.1M [00:17<00:00, 2.87MB/s]\u001b[A\n",
" 97%|█████████▋|get-started/data.xml 35.1M/36.1M [00:17<00:00, 2.87MB/s]\u001b[A\n",
" 98%|█████████▊|get-started/data.xml 35.4M/36.1M [00:18<00:00, 2.87MB/s]\u001b[A\n",
" 99%|█████████▉|get-started/data.xml 35.7M/36.1M [00:18<00:00, 2.88MB/s]\u001b[A\n",
"100%|█████████▉|get-started/data.xml 36.0M/36.1M [00:18<00:00, 2.87MB/s]\u001b[A\n",
" \u001b[A\n",
"To track the changes with git, run:\n",
"\n",
"\tgit add data/.gitignore data/data.xml.dvc\n",
"\u001b[0m"
]
}
],
"source": [
"!dvc import https://github.com/iterative/dataset-registry \\\n",
" get-started/data.xml -o data/data.xml"
]
},
{
"cell_type": "code",
"execution_count": 49,
"id": "be2c1a37",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Data and pipelines are up to date. \n",
"\u001b[0m"
]
}
],
"source": [
"!dvc status"
]
},
{
"cell_type": "code",
"execution_count": 50,
"id": "3306c5b7",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"total 37020\r\n",
"-rw-rw-r-- 1 tomek tomek 37891850 maj 31 11:10 data.xml\r\n",
"-rw-rw-r-- 1 tomek tomek 284 maj 31 11:10 data.xml.dvc\r\n",
"-rw-rw-r-- 1 tomek tomek 5072 maj 31 11:01 Iris.csv\r\n",
"-rw-rw-r-- 1 tomek tomek 76 maj 31 11:01 Iris.csv.dvc\r\n"
]
}
],
"source": [
"ls -l data"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b73c56ea",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"outputs": [],
"source": [
"# %load data/data.xml.dvc\n",
"md5: a7cd139231cc35ed63541ce3829b96db\n",
"frozen: true\n",
"deps:\n",
"- path: get-started/data.xml\n",
" repo:\n",
" url: https://github.com/iterative/dataset-registry\n",
" rev_lock: ba014f40e29670421a67cb1c47543f402348aa13\n",
"outs:\n",
"- md5: a304afb96060aad90176268345e10355\n",
" size: 37891850\n",
" path: data.xml\n"
]
},
{
"cell_type": "markdown",
"id": "db1063ac",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## DVC pipelines\n",
" - wprowadzenie: https://youtu.be/71IGzyH95UY\n",
" - Getting started: https://dvc.org/doc/start/data-pipelines\n",
" - dvc pipelines pozwala nam zbudować (za pomocą polecenie `dvc run`) lub zdefiniować (edytując plik `dvc.yaml`) graf zależności między krokami wykonywanymi w naszym projekcie (takimi jak \"przygotowanie danych\", \"trenowanie\", \"ewaluacja\")\n",
" - tak zdefiniowany pipeline można potem uruchomić za pomocą polecenia `dvc reproduce`"
]
},
{
"cell_type": "markdown",
"id": "e2939867",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
2023-04-26 13:44:55 +02:00
"## Zadania [10+5 pkt]\n",
2021-05-31 11:55:27 +02:00
"1. Zainicjalizuj repozytorium DVC wewnątrz Twojego repozytorium z projektem [1pkt]\n",
"2. Dodaj plik(i) z danymi w Twoim projekcie do DVC [1pkt]\n",
2022-05-23 10:01:41 +02:00
"3. Skonfiguruj remote (dane do konfiguracji podane poniżej) [3pkt]\n",
2021-06-04 16:11:54 +02:00
"4. Stwórz/zdefiniuj i dodaj do repozytorium plik `dvc.yaml` opisujący kroki wykonywane w Twoim projekcie. Wydziel przynajmniej 2 kroki (np. przygotowanie danych/trenowanie) powiązane ze sobą za pomocą zależności (skorzystaj z \n",
2023-04-26 13:44:55 +02:00
"materiałów \"Getting started\", link powyżej) [5pkt (opcjonalne)]\n",
"5. Stwórz projekt na Jenkinsie (`s1233456-dvc`), w którym sklonujesz repozytorium, ściągniesz pliki dvc (za pomocą `dvc pull`) i uruchomisz pipeline (za pomocą `dvc reproduce`) [5pkt]"
2021-05-31 11:55:27 +02:00
]
2021-06-04 15:52:21 +02:00
},
{
"cell_type": "markdown",
"id": "2f5a8590",
2021-09-28 10:56:21 +02:00
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
2021-06-04 15:52:21 +02:00
"source": [
2021-06-04 16:11:54 +02:00
"## SSH remote\n",
"Jednym z remote obsługiwanych przez DVC jest SFTP/SSH.\n",
"W celu jego wykorzystania na serwerze tzietkiewicz.vm.wmi.amu.edu.pl utworzony został użytkownik `ium-sftp` i skonfigurowany serwer SFTP.\n",
"Został też dla niego wygenerowany klucz ssh, który został dodany jako \"Jenkins credential\" (patrz opis konfiguracji na Jenkins poniżej)"
2021-06-04 15:52:21 +02:00
]
},
{
"cell_type": "markdown",
"id": "82a61107",
2021-09-28 10:56:21 +02:00
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
2021-06-04 15:52:21 +02:00
"source": [
2021-06-04 16:11:54 +02:00
"### Lokalnie\n",
2022-05-29 09:51:07 +02:00
"Będziemy potrzebować zależności ([szczegóły](https://dvc.org/doc/command-reference/remote/add))\n",
2021-06-04 15:52:21 +02:00
" \n",
" `conda install dvc-ssh` \n",
"\n",
"albo\n",
"\n",
"`pip install dvc[ssh] paramiko`"
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "c48c5b8e",
2021-09-28 10:56:21 +02:00
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
2021-06-04 15:52:21 +02:00
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Collecting package metadata (current_repodata.json): done\n",
"Solving environment: done\n",
"\n",
"## Package Plan ##\n",
"\n",
" environment location: /home/tomek/miniconda3\n",
"\n",
" added / updated specs:\n",
" - dvc-ssh\n",
"\n",
"\n",
"The following packages will be downloaded:\n",
"\n",
" package | build\n",
" ---------------------------|-----------------\n",
" bcrypt-3.2.0 | py39h3811e60_1 44 KB conda-forge\n",
" ca-certificates-2021.5.30 | ha878542_0 136 KB conda-forge\n",
" certifi-2021.5.30 | py39hf3d152e_0 141 KB conda-forge\n",
" dvc-2.3.0 | py39hf3d152e_0 542 KB conda-forge\n",
" dvc-ssh-2.3.0 | py39hf3d152e_0 9 KB conda-forge\n",
" fsspec-2021.5.0 | pyhd8ed1ab_0 77 KB conda-forge\n",
" invoke-1.5.0 | pyhd3deb0d_0 137 KB conda-forge\n",
" paramiko-2.7.2 | pyh9f0ad1d_0 135 KB conda-forge\n",
" pynacl-1.4.0 | py39h3811e60_2 1.3 MB conda-forge\n",
" ------------------------------------------------------------\n",
" Total: 2.5 MB\n",
"\n",
"The following NEW packages will be INSTALLED:\n",
"\n",
" bcrypt conda-forge/linux-64::bcrypt-3.2.0-py39h3811e60_1\n",
" dvc-ssh conda-forge/linux-64::dvc-ssh-2.3.0-py39hf3d152e_0\n",
" invoke conda-forge/noarch::invoke-1.5.0-pyhd3deb0d_0\n",
" paramiko conda-forge/noarch::paramiko-2.7.2-pyh9f0ad1d_0\n",
" pynacl conda-forge/linux-64::pynacl-1.4.0-py39h3811e60_2\n",
"\n",
"The following packages will be UPDATED:\n",
"\n",
" ca-certificates 2020.12.5-ha878542_0 --> 2021.5.30-ha878542_0\n",
" certifi 2020.12.5-py39hf3d152e_1 --> 2021.5.30-py39hf3d152e_0\n",
" dvc 2.1.0-py39hf3d152e_0 --> 2.3.0-py39hf3d152e_0\n",
" fsspec 0.9.0-pyhd8ed1ab_2 --> 2021.5.0-pyhd8ed1ab_0\n",
"\n",
"\n",
"\n",
"Downloading and Extracting Packages\n",
"certifi-2021.5.30 | 141 KB | ##################################### | 100% \n",
"fsspec-2021.5.0 | 77 KB | ##################################### | 100% \n",
"dvc-2.3.0 | 542 KB | ##################################### | 100% \n",
"invoke-1.5.0 | 137 KB | ##################################### | 100% \n",
"paramiko-2.7.2 | 135 KB | ##################################### | 100% \n",
"bcrypt-3.2.0 | 44 KB | ##################################### | 100% \n",
"pynacl-1.4.0 | 1.3 MB | ##################################### | 100% \n",
"dvc-ssh-2.3.0 | 9 KB | ##################################### | 100% \n",
"ca-certificates-2021 | 136 KB | ##################################### | 100% \n",
"Preparing transaction: done\n",
"Verifying transaction: done\n",
"Executing transaction: done\n",
"\n",
"Note: you may need to restart the kernel to use updated packages.\n"
]
}
],
"source": [
"conda install -c conda-forge dvc-ssh"
]
},
2023-04-26 13:44:55 +02:00
{
"cell_type": "markdown",
"id": "04c41da0",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"Dodajemy remote:"
]
},
2021-06-04 15:52:21 +02:00
{
"cell_type": "code",
"execution_count": 17,
2021-06-04 15:52:21 +02:00
"id": "e9a04876",
2021-09-28 10:56:21 +02:00
"metadata": {
"slideshow": {
2023-04-26 13:44:55 +02:00
"slide_type": "fragment"
2021-09-28 10:56:21 +02:00
}
},
2021-06-04 15:52:21 +02:00
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Setting 'ium_ssh_remote' as a default remote.\n",
"\u001b[0m"
]
}
],
"source": [
2022-05-29 09:51:07 +02:00
"!dvc remote add -f -d ium_ssh_remote ssh://ium-sftp@tzietkiewicz.vm.wmi.amu.edu.pl"
2021-06-04 15:52:21 +02:00
]
},
{
"cell_type": "code",
"execution_count": 18,
2021-06-04 15:52:21 +02:00
"id": "e3f27bbb",
2021-09-28 10:56:21 +02:00
"metadata": {
"slideshow": {
2023-04-26 13:44:55 +02:00
"slide_type": "fragment"
2021-09-28 10:56:21 +02:00
}
},
2021-06-04 15:52:21 +02:00
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
2022-05-29 09:51:07 +02:00
"ium_ssh_remote\tssh://ium-sftp@tzietkiewicz.vm.wmi.amu.edu.pl\n",
2021-06-04 15:52:21 +02:00
"\u001b[0m"
]
}
],
"source": [
"!dvc remote list"
]
},
2022-05-29 09:51:07 +02:00
{
"cell_type": "markdown",
"id": "c92edd7b",
2023-04-26 13:44:55 +02:00
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
2022-05-29 09:51:07 +02:00
"source": [
"Zapisujemy hasło:"
]
},
2021-06-04 15:52:21 +02:00
{
"cell_type": "code",
"execution_count": 19,
2021-06-04 15:52:21 +02:00
"id": "5b2fa175",
2021-09-28 10:56:21 +02:00
"metadata": {
"slideshow": {
2023-04-26 13:44:55 +02:00
"slide_type": "fragment"
2021-09-28 10:56:21 +02:00
}
},
2021-06-04 15:52:21 +02:00
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
2022-05-29 09:51:07 +02:00
"\u001b[0m"
2021-06-04 15:52:21 +02:00
]
}
],
"source": [
2022-05-29 09:51:07 +02:00
"!dvc remote modify --local ium_ssh_remote password IUM@2021"
2021-06-04 15:52:21 +02:00
]
},
2023-04-26 13:44:55 +02:00
{
"cell_type": "markdown",
"id": "8b83049b",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"Pushujemy do skonfigurowanego remote:"
]
},
2021-06-04 15:52:21 +02:00
{
"cell_type": "code",
"execution_count": 20,
2021-06-04 15:52:21 +02:00
"id": "ea6e16fa",
"metadata": {
"slideshow": {
2023-04-26 13:44:55 +02:00
"slide_type": "fragment"
2021-06-04 15:52:21 +02:00
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" 0% Transferring| |0/1 [00:00<?, ?file/s]\n",
"!\u001b[A\n",
" 0%| |4705c4d470a4d9dd152808e5e9f56f 0.00/? [00:00<?, ?B/s]\u001b[A\n",
" 0%| |4705c4d470a4d9dd152808e5e9f56f 0.00/4.92k [00:00<?, ?B/s]\u001b[A\n",
"1 file pushed \u001b[A\n",
2021-06-04 15:52:21 +02:00
"\u001b[0m"
]
}
],
"source": [
"!dvc push"
]
},
{
"cell_type": "markdown",
"id": "1468c44c",
2021-09-28 10:56:21 +02:00
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
2021-06-04 15:52:21 +02:00
"source": [
"### Jenkins\n",
"\n",
"W Jenkins można użyć mechanizmu \"Credentials\", żeby w bezpieczny sposób przekazać hasło albo klucz prywatny.\n",
"\n",
"Takie dane dla użytkownika ium-sftp zostały stworzone na Jenkinsie:\n",
"\n",
2023-04-26 13:44:55 +02:00
" - typu ssh key: https://tzietkiewicz.vm.wmi.amu.edu.pl:8081/credentials/store/system/domain/_/credential/48ac7004-216e-4260-abba-1fe5db753e18/\n",
" - typu \"secret text\" - zawierający hasło użytkownika ium-shftp: https://tzietkiewicz.vm.wmi.amu.edu.pl:8081/credentials/store/system/domain/_/credential/ium-sftp-password/\n",
2021-06-04 15:52:21 +02:00
"\n",
"Opis używania \"Credentials\" w Jenkinsfile: https://www.jenkins.io/doc/book/pipeline/jenkinsfile/#for-other-credential-types\n",
"\n",
"Klucza ssh można użyć tak: \n",
"\n",
"```Jenkinsfile\n",
"withCredentials(\n",
" [sshUserPrivateKey(credentialsId: '48ac7004-216e-4260-abba-1fe5db753e18', keyFileVariable: 'IUM_SFTP_KEY', passphraseVariable: '', usernameVariable: '')]) {\n",
2021-06-14 11:44:01 +02:00
" sh 'dvc remote add -d ium_ssh_remote ssh://ium-sftp@tzietkiewicz.vm.wmi.amu.edu.pl/ium-sftp'\n",
" sh 'dvc remote modify --local ium_ssh_remote keyfile $IUM_SFTP_KEY'\n",
" sh 'dvc pull'}\n",
2021-06-04 15:52:21 +02:00
"```\n",
"\n",
"Secret text tak:\n",
"\n",
"```Jenkinsfile\n",
" withCredentials([string(credentialsId: 'ium-sftp-password', variable: 'IUM_SFTP_PASS')]) {\n",
2021-06-14 11:44:01 +02:00
" sh 'dvc remote add -d ium_ssh_remote ssh://ium-sftp@tzietkiewicz.vm.wmi.amu.edu.pl/ium-sftp'\n",
" sh 'dvc remote modify --local ium_ssh_remote password $IUM_SFTP_KEY'\n",
" sh 'dvc pull'\n",
2021-06-04 15:52:21 +02:00
" }\n",
"```\n",
"\n",
2023-04-26 13:44:55 +02:00
"Przykład konfiguracji: \n",
" - https://tzietkiewicz.vm.wmi.amu.edu.pl:8081/job/docker-test-mount/ \n",
" - https://git.wmi.amu.edu.pl/tzietkiewicz/ium-helloworld"
2021-06-04 15:52:21 +02:00
]
2021-05-31 11:55:27 +02:00
}
],
"metadata": {
2021-09-28 10:56:21 +02:00
"author": "Tomasz Ziętkiewicz",
2021-05-31 11:55:27 +02:00
"celltoolbar": "Slideshow",
2021-09-28 10:56:21 +02:00
"email": "tomasz.zietkiewicz@amu.edu.pl",
2021-05-31 11:55:27 +02:00
"kernelspec": {
2023-04-26 13:44:55 +02:00
"display_name": "Python 3",
2021-05-31 11:55:27 +02:00
"language": "python",
"name": "python3"
},
2021-09-28 10:56:21 +02:00
"lang": "pl",
2021-05-31 11:55:27 +02:00
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
2023-04-26 13:44:55 +02:00
"version": "3.9.12"
2021-09-28 10:56:21 +02:00
},
"slideshow": {
"slide_type": "slide"
},
"subtitle": "10.DVC[laboratoria]",
"title": "Inżynieria uczenia maszynowego",
"year": "2021"
2021-05-31 11:55:27 +02:00
},
"nbformat": 4,
"nbformat_minor": 5
}