File size: 3,437 Bytes
fe3440b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "437b5656-e96f-4d3c-a1cf-463f1c8b5370",
   "metadata": {},
   "outputs": [],
   "source": [
    "# https://colab.research.google.com/drive/1ot8pODgystx1D6_zvsALDSvjACBF1cj6#scrollTo=RF1bMqhBOpSZ"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "a70a098b-abd1-4aaf-96bc-1f42c1eb0f95",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Архив 'outputs_archive_20231108-113718.zip' успешно создан.\n"
     ]
    }
   ],
   "source": [
    "import os\n",
    "import subprocess\n",
    "from datetime import datetime\n",
    "from IPython.display import clear_output\n",
    "\n",
    "# Путь к папке, которую необходимо архивировать\n",
    "folder_to_zip = '/workspace/sd/stable-diffusion-webui/outputs/'\n",
    "\n",
    "# Создаем имя архива с меткой времени\n",
    "timestamp = datetime.now().strftime('%Y%m%d-%H%M%S')\n",
    "archive_name = f'outputs_archive_{timestamp}.zip'\n",
    "\n",
    "# Создаем архив\n",
    "subprocess.run(['zip', '-r', archive_name, folder_to_zip], check=True)\n",
    "\n",
    "# Очищаем вывод в ячейке\n",
    "clear_output(wait=True)\n",
    "\n",
    "# Выводим сообщение об успешной операции\n",
    "print(f\"Архив '{archive_name}' успешно создан.\")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "c6e7af58-76c3-4da7-88f7-f8f0f27f2165",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Sending 'outputs_archive_20231108-113718.zip' (61.1 MB)\n",
      "Code is: 2010-lagoon-exit-husband-0\n",
      "On the other computer run\n",
      "\n",
      "runpodctl receive 2010-lagoon-exit-husband-0\n",
      "\n",
      "Sending (->35.233.165.219:42774)\n",
      "outputs_archive_20231108-113718.zip 100% |████████████████████| (61/61 MB, 3.640 MB/s)          \n",
      "                                                                                                \r"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    }
   ],
   "source": [
    "# Отправляем архив с использованием команды runpodctl send\n",
    "send_command = f\"runpodctl send {archive_name}\"\n",
    "send_result = subprocess.run(send_command, shell=True, stdout=subprocess.PIPE, text=True)\n",
    "\n",
    "# Выводим результат отправки\n",
    "print(send_result.stdout)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "609c22d2-3a15-4831-b5eb-5741b0ca1910",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}