Last active
July 31, 2025 02:12
-
-
Save oeway/d23f2f91cd2ab47179a81a4fc182d1a0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# import micropip | |
# await micropip.install("hypha-artifact>=0.0.14") | |
# Make sure you add "hypha-artifact" to your requirements | |
import asyncio | |
import os | |
import sys | |
from hypha_artifact import AsyncHyphaArtifact | |
# Change your app_id below | |
# In future version, hypha will expose the current app_id as env variable | |
APP_ID = "ws-user-github|478667/interpreted-tights-forced-extremely" | |
SERVER_URL = os.environ["HYPHA_SERVER_URL"] | |
WORKSPACE = os.environ["HYPHA_WORKSPACE"] # this will be available automatically | |
TOKEN = os.environ["HYPHA_TOKEN"] # this will be available automatically | |
source_dir = "/" | |
target_dir="/tmp/custom_modules" | |
# Initialize and use as context manager | |
artifact = AsyncHyphaArtifact( | |
service_url=SERVER_URL, | |
artifact_id=APP_ID, | |
workspace=WORKSPACE, | |
token=TOKEN | |
) | |
print("π Listing files in the artifact...") | |
files = await artifact.ls(source_dir) | |
print(f"π Found {len(files)} files in root directory:") | |
for f in files: | |
print(f" - {f['name']}") | |
print(f"β¬οΈ Downloading files to {target_dir}...") | |
n_downloaded = await artifact.get(source_dir, target_dir, recursive=True) | |
print(f"β Downloaded {n_downloaded if isinstance(n_downloaded, int) else 'all'} files to {target_dir}") | |
if target_dir not in sys.path: | |
sys.path.insert(0, target_dir) | |
print(f"π€οΈ Added {target_dir} to sys.path") | |
print("π Ready to import your custom modules!") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment