Skip to content

Instantly share code, notes, and snippets.

@oeway
Last active July 31, 2025 02:12
Show Gist options
  • Save oeway/d23f2f91cd2ab47179a81a4fc182d1a0 to your computer and use it in GitHub Desktop.
Save oeway/d23f2f91cd2ab47179a81a4fc182d1a0 to your computer and use it in GitHub Desktop.
# 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