File size: 3,366 Bytes
fe3440b
0ea9934
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fe3440b
0ea9934
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fe3440b
 
0ea9934
 
 
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
{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "id": "437b5656-e96f-4d3c-a1cf-463f1c8b5370",
      "metadata": {
        "id": "437b5656-e96f-4d3c-a1cf-463f1c8b5370"
      },
      "outputs": [],
      "source": [
        "# https://colab.research.google.com/drive/1ot8pODgystx1D6_zvsALDSvjACBF1cj6#scrollTo=RF1bMqhBOpSZ"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "id": "a70a098b-abd1-4aaf-96bc-1f42c1eb0f95",
      "metadata": {
        "tags": [],
        "id": "a70a098b-abd1-4aaf-96bc-1f42c1eb0f95",
        "outputId": "8943f538-1e92-4397-cfc8-78681109f41c"
      },
      "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": null,
      "id": "c6e7af58-76c3-4da7-88f7-f8f0f27f2165",
      "metadata": {
        "tags": [],
        "id": "c6e7af58-76c3-4da7-88f7-f8f0f27f2165"
      },
      "outputs": [],
      "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": {
        "id": "609c22d2-3a15-4831-b5eb-5741b0ca1910"
      },
      "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"
    },
    "colab": {
      "provenance": []
    }
  },
  "nbformat": 4,
  "nbformat_minor": 5
}