{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from huggingface_hub import create_repo, HfApi\n", "\n", "import com_const as cc" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "repo_id = \"treizh/oiv_ld_phenotyping\"" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "RepoUrl('https://huggingface.co/treizh/oiv_ld_phenotyping', endpoint='https://huggingface.co', repo_type='model', repo_id='treizh/oiv_ld_phenotyping')" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "create_repo(repo_id, exist_ok=True)" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "api = HfApi()" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "CommitInfo(commit_url='https://huggingface.co/treizh/oiv_ld_phenotyping/commit/ac0c4c71a2b6842d45cd5fa99ca15429f647027c', commit_message='Upload .gitignore with huggingface_hub', commit_description='', oid='ac0c4c71a2b6842d45cd5fa99ca15429f647027c', pr_url=None, pr_revision=None, pr_num=None)" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "api.upload_file(path_or_fileobj=cc.path_to_root.joinpath(\".gitignore\"), path_in_repo=\".gitignore\", repo_id=repo_id)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "def upload_folder(fld):\n", " api.upload_folder(folder_path=fld, repo_id=repo_id, path_in_repo=fld.name)" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "CommitInfo(commit_url='https://huggingface.co/treizh/oiv_ld_phenotyping/commit/fc262e75f2db77ba4440372fe5e564be596968bb', commit_message='Upload folder using huggingface_hub', commit_description='', oid='fc262e75f2db77ba4440372fe5e564be596968bb', pr_url=None, pr_revision=None, pr_num=None)" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "api.upload_folder(folder_path=cc.path_to_src, repo_id=repo_id, path_in_repo=cc.path_to_src.name)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# for file in cc.path_to_src.rglob(\"*\"):\n", "# if api.file_exists(repo_id=repo_name, filename=file.name) is True:\n", "# api.delete_file(path_in_repo=file.name, repo_id=repo_name)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "env", "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.9.2" } }, "nbformat": 4, "nbformat_minor": 2 }