From d8a9dc6e81dc80681b62e0b6de2d2568205a0be8 Mon Sep 17 00:00:00 2001 From: Komal Thareja Date: Mon, 23 Sep 2024 22:49:32 -0500 Subject: [PATCH 1/2] add notebook depicting artifact manager usage via FABlib --- .../manage_artifacts/artifact_publisher.ipynb | 269 ++++++++++++++++++ .../manage_artifacts/hello_fabric.tgz | Bin 0 -> 2211 bytes requirements.txt | 2 +- start_here.ipynb | 3 +- 4 files changed, 272 insertions(+), 2 deletions(-) create mode 100644 fabric_examples/fablib_api/manage_artifacts/artifact_publisher.ipynb create mode 100644 fabric_examples/fablib_api/manage_artifacts/hello_fabric.tgz diff --git a/fabric_examples/fablib_api/manage_artifacts/artifact_publisher.ipynb b/fabric_examples/fablib_api/manage_artifacts/artifact_publisher.ipynb new file mode 100644 index 00000000..f41cab34 --- /dev/null +++ b/fabric_examples/fablib_api/manage_artifacts/artifact_publisher.ipynb @@ -0,0 +1,269 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "d95f0b2d-df12-4956-b049-19ede4d10f7e", + "metadata": {}, + "source": [ + "# FABRIC Artifact Manager:\n", + "\n", + "The FABRIC [Artifacts Manager](https://artifacts.fabric-testbed.net) is an invaluable tool for researchers and developers working with the FABRIC testbed. It facilitates the packaging, sharing, and reuse of complete, repeatable FABRIC experiments. By leveraging the FABRIC fablib, users can efficiently manage and interact with experimental artifacts in a streamlined, user-friendly manner. This not only ensures reproducibility but also enhances collaboration by making experiments easily accessible to others.\n", + "\n", + "## Accessing and Sharing Artifacts\n", + "Artifacts managed through the FABRIC Artifacts Manager can be easily accessed by anyone with the appropriate permissions. Whether you're looking to share your experiment with collaborators or make your work publicly available, the Artifact Manager simplifies this process.\n", + "\n", + "- **Public Artifacts**: Any user can read and download public artifacts directly.\n", + "\n", + "- **Project-Specific Artifacts**: Artifacts that are tied to specific projects can also be accessed by project members, ensuring that all collaborators have easy access to the data and resources they need.\n", + "- **Private**: Only artfiact owner/creator has access to the artifact.\n", + "\n", + "This setup ensures that your experiments are not only repeatable but also sharable, fostering collaboration and innovation within the research community.\n" + ] + }, + { + "cell_type": "markdown", + "id": "9cb8171b-6b07-4d82-98fb-4d397602995a", + "metadata": {}, + "source": [ + "## Import the FABlib Library" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "7375a04e-91bf-4c03-8093-f9b3d2de8900", + "metadata": {}, + "outputs": [], + "source": [ + "from fabrictestbed_extensions.fablib.fablib import FablibManager as fablib_manager\n", + "\n", + "fablib = fablib_manager()\n", + "\n", + "fablib.show_config();" + ] + }, + { + "cell_type": "markdown", + "id": "e01d15e4-b3fb-47f1-92e7-8077fe96dc35", + "metadata": {}, + "source": [ + "## List Artifacts\n", + "\n", + "Enables you to access and view all artifacts, including those you've created, public artifacts, as well as artifacts associated with your project.." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "25866392-ecf4-4bce-910f-40693b7cd1f5", + "metadata": {}, + "outputs": [], + "source": [ + "fablib.list_artifacts();" + ] + }, + { + "cell_type": "markdown", + "id": "c5e9ce2c-2caf-4dc4-baa8-eb0e5ff0f3f9", + "metadata": {}, + "source": [ + "## Create a new Artifact\n", + "\n", + "To create a new artifact, you need to provide several key details to define and manage it effectively:\n", + "\n", + "- **Title**: Set the artifact_title to give your artifact a clear and descriptive name. For example, \"Test-Artifact\".\n", + "\n", + "- **Descriptions**:\n", + " - **Short Description**: Provide a brief summary of the artifact's purpose or content. For instance, \"Short Description\".\n", + " - **Long Description**: Include a more detailed explanation of the artifact, outlining its significance and use. For example, \"Long Description\".\n", + "\n", + "- **Tags**: Use tags to categorize and make the artifact easily searchable. An example tag could be [\"example\"].\n", + "\n", + "- **Visibility**: Determine who can access the artifact by setting visibility. Options include:\n", + " - **author**: Only accessible to you.\n", + " - **project**: Accessible to others involved in the project.\n", + " - **public**: Accessible to anyone.\n", + "\n", + "- **Authors**: Specify authors as a list of email addresses for those who contributed to the artifact. If the list is empty, your user token will be used to determine the author." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "753f1f87-8ed7-471d-b257-3b1fd63f3837", + "metadata": {}, + "outputs": [], + "source": [ + "# Define the artifact details\n", + "artifact_title = \"Test-Artifact\"\n", + "description_short = \"Short Description\"\n", + "description_long = \"Long Description\"\n", + "tags = [\"example\"]\n", + "visibility = \"project\" # Options: \"author\", \"project\", \"public\"\n", + "authors = [] # List of author email addresses; if empty, use the user's token" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "fd74c787-3449-4543-b4ad-594a9192cc8e", + "metadata": {}, + "outputs": [], + "source": [ + "artifact = fablib.create_artifact(artifact_title=artifact_title,\n", + " description_short=description_short,\n", + " description_long=description_long,\n", + " tags=tags,\n", + " visibility=visibility,\n", + " authors=authors)" + ] + }, + { + "cell_type": "markdown", + "id": "a5a2b6b0-2802-469d-be9b-2cc630fdee1e", + "metadata": {}, + "source": [ + "## List the newly created artifact\n", + "\n", + "We list the newly created artifact by filtering on the title." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f75183a9-cc30-4859-8430-9ac40d430bf6", + "metadata": {}, + "outputs": [], + "source": [ + "fablib.list_artifacts(filter_function=lambda x: x['title']==artifact_title);" + ] + }, + { + "cell_type": "markdown", + "id": "39cae1c9-5801-4ea2-af8b-7e5a925b1867", + "metadata": {}, + "source": [ + "## Upload contents to the artifacts\n", + "We will now upload a tar file to the artifact." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "0d1de12e-2e70-456e-bf65-c6ebd54100c4", + "metadata": {}, + "outputs": [], + "source": [ + "file_to_upload = \"./hello_fabric.tgz\"" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "2d222c4d-ba94-417a-a5ac-5d9560a6ca9e", + "metadata": {}, + "outputs": [], + "source": [ + "artifact = fablib.get_artifacts(artifact_title=artifact_title)[0].to_dict()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e3c9067f-17f0-4681-a001-6a0c11148b5c", + "metadata": {}, + "outputs": [], + "source": [ + "upload_response = fablib.upload_file_to_artifact(artifact_id=artifact.get(\"uuid\"), \n", + " file_to_upload=file_to_upload)\n", + "\n", + "print(f\"Uploaded tar file to artifact: {upload_response}\")" + ] + }, + { + "cell_type": "markdown", + "id": "deb78c67-e249-46b0-8553-12af9811dce0", + "metadata": {}, + "source": [ + "## Verify the new contents are available on the artifact\n", + "\n", + "Artifact versions now start listing here." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "8c8839cf-a11c-4d03-b8d0-a30a14e6d9ff", + "metadata": {}, + "outputs": [], + "source": [ + "fablib.list_artifacts(filter_function=lambda x: x['title']==artifact_title);" + ] + }, + { + "cell_type": "markdown", + "id": "b5c6e0c1-44dc-468e-b36b-104c13f86570", + "metadata": {}, + "source": [ + "## Delete an artifact" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "6f0fc567-5bdc-4ce3-937e-d883a4b285c3", + "metadata": {}, + "outputs": [], + "source": [ + "fablib.delete_artifact(artifact_title=artifact_title);" + ] + }, + { + "cell_type": "markdown", + "id": "cc14e0ef-ad98-427e-bbeb-1c62ebf80413", + "metadata": {}, + "source": [ + "## Verify the deleted artifact is no longer available" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "46da6b40-b3ea-48b6-80e7-5661a284a6ce", + "metadata": {}, + "outputs": [], + "source": [ + "fablib.list_artifacts(filter_function=lambda x: x['title']==artifact_title);" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "ef5e4328-2e56-420f-897c-55c28a79d324", + "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.11.8" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/fabric_examples/fablib_api/manage_artifacts/hello_fabric.tgz b/fabric_examples/fablib_api/manage_artifacts/hello_fabric.tgz new file mode 100644 index 0000000000000000000000000000000000000000..72e3f7c63a56d7c4aebf4dbebec12a04aa4241c8 GIT binary patch literal 2211 zcmV;U2we9ciwFP!000001MOM;ZX3A~_uqbs!5W2az+PFlY!~X~04KfRT-3cZP7563 zKu7IT5^FBGM{=z!ihGtmOkb=s;l{hBL#N-%J)+3v6M@Pr!r>FEDo}V7k`)D{C`FHhf4M%6^qtWnebbh{dG(0{#JKloRucXh)Q&`6g zz*aE9=jgbxn^0)8&!X%9?vGgHrJDXGGRVPa!QVapAD*3~vm5`PV4MukPDbeequ)gO zJH^%t=wiNrghU86r;i3^T_L;?62rR%hnr|c zy_={*0ghW|kt>HptC^S=2H9!_dKNfybtjBgfmY*BTNv&&Ntg;+a9}D0mL%L-Fg#et z0x}5#V}R?NCt@ZNCS`fxrFB$Dc`kKnfq|7G;Uv1{vJ`GXD|l4N0d;W&laR4wAyg3T z^){Jpl#+T5LZPxGXMIOOoJg@hiz%SH7do|ZpEGuLc8E+O*~Obnc*|$paD^)M5g)>P zykkfk+l5|Ef+;`jEu72kcrXa}@3104o295)suLRvJ>Y5}8M$FltuI_AcfuC>Jmu+x ze{^Vh^oxxvqU!b9zpj{Kb8foA_xqHS!n%nS$aV9&wX%CvQ+zq`?%%v-jp$Xy{HK_u z=|t)D@oI(b57H`-Ua!dO)5R9kOt?*H5~TI%G3US(AzB=UW$ zK}Y(By*M6(e+`!jmb%FulLFxh5BPPz5g)@F$(iL~oz7u_h3Wuw&Xuo^s4&W6uA?l9 zR#;0GQz&}c~1fN03~mgUP_+M`5`jn14OlRlzvFa_OK$qqeFBqEJXCCR>gNJU#;J% zQt0s*F0)*l#zO>_5my^#%6m0Quyj;fgaU%*LhM>7hpVcP@-Z5sgYfo-&;2^jjLzU; z@DM~e)Cx)jW+5z3vhbxZb}9xh)=2kyYtpA3!`}WMaCxIXJb}F*a`(yZP!A0NV2?PqT{CwbH(g*1mk!gA&!?DrXNB}S(iXaq)E;8~4Xt9cJ7GCXge&7G7mDl67`lD4P9HTR z3Xgl*R@~#LewR}El2{?g;GyleZC_4cFxVe+l}O0vXoTQ{sgS}6aw1jqX(6aSR;~WD zYzG+(Yss?u?gt8~cWyfhs5<(9_~2qjQ=3q_o;wFj*m_h8|+Iz$U^IXkuA{2@s8`qDI zes>dn`_0sRyTa&+U5=ePGOG}2bq%JeQ)}C`?-3Bg^Ier8dZXTCy8{;~#T_}N{pwxx z0#;l7njzV6_^a%$LkKj{w5Dj)KL6Jl{hphAI))#nlt#l<_7>Q+aN(R0h|~I~RW#bV z#;Vh~3ar_1KZe+FM6^Bi2J_?&;u!0iYiyt1MOhzyY`ln^jp40tE%`lT?JLBk;4Hu1~wWovhn&7}f7k zR@K@*jQ??G3qIDRsKf!ixiKiHI~d#B<;g;?{=W_Q9>KH!i45r*{6qWG?*3*k*7+El za++kdDZMXbtC3F_dUesmlBPTLC?VCVLS}1i>ywLz?!<8Kev^NJb`Ma+OWX$fzJ9Ri zmK(*T&3RHEHL9@OghGXsdQ-XuUPElEL|z8^{Ypv6)V#oEkjQdRRxQ+f!^e}TK6A5U zLc@qgB%M1G#%MFi$OMhmYd)gO9ilsKsK>>Xla4!PLh`l&rfqRv*3pacQCry|&EVtV zXB4hKPBDF>EQegFd*q#|fljZWg>F#dfMyg@pnfH0B4)lv8N lBoj$@5+yCqTaejWDpXcZKd48V4^B=l$5#j(S004<=NZbGb literal 0 HcmV?d00001 diff --git a/requirements.txt b/requirements.txt index 220d14cb..49c92f04 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -fabrictestbed-extensions==1.7.3 +fabrictestbed-extensions>=1.7.3 python-dotenv ipython==8.12.0 fabrictestbed-mflib>=1.0.4 diff --git a/start_here.ipynb b/start_here.ipynb index fc8726a6..2f4f4f85 100644 --- a/start_here.ipynb +++ b/start_here.ipynb @@ -28,7 +28,8 @@ "- First Experiment\n", " - [Hello, FABRIC](./fabric_examples/fablib_api/hello_fabric/hello_fabric.ipynb): Simple First Slice Example.\n", "- Artifact Manager\n", - " - [Explore FABRIC Artifacts](./artifact_manager.ipynb): Managing and Sharing Reproducible Experiments with FABRIC Artifacts Manager.\n", + " - [Explore FABRIC Artifacts](./artifact_manager.ipynb): Download Reproducible Experiments with FABRIC Artifacts Manager.\n", + " - [Manage Artifacts via API](./fabric_examples/fablib_api/manage_artifacts/manage_artifacts.ipynb): Manage Artifacts using FablibManager.\n", "\n", "## Basic Examples\n", "\n", From 8cfcf40e9a99abcd56f39451e93651374b7a1acb Mon Sep 17 00:00:00 2001 From: Komal Thareja Date: Mon, 23 Sep 2024 22:53:33 -0500 Subject: [PATCH 2/2] rename to manage_artifacts --- .../{artifact_publisher.ipynb => manage_artifacts.ipynb} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename fabric_examples/fablib_api/manage_artifacts/{artifact_publisher.ipynb => manage_artifacts.ipynb} (100%) diff --git a/fabric_examples/fablib_api/manage_artifacts/artifact_publisher.ipynb b/fabric_examples/fablib_api/manage_artifacts/manage_artifacts.ipynb similarity index 100% rename from fabric_examples/fablib_api/manage_artifacts/artifact_publisher.ipynb rename to fabric_examples/fablib_api/manage_artifacts/manage_artifacts.ipynb