{ "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 }