bcbd1bdb22
Integ / changes (push) Has been skipped
Pre-commit / pre-commit (push) Failing after 1s
CLI exit codes / changes (push) Has been skipped
Test (Install) / changes (push) Has been skipped
Test (Python) / changes (push) Has been skipped
Test (TypeScript) / changes (push) Has been skipped
CLI exit codes / cli-gate (push) Has been cancelled
Test (Install) / test-install-gate (push) Has been cancelled
Integ / integ-gate (push) Has been cancelled
Test (Python) / test-python-gate (push) Has been cancelled
Test (TypeScript) / test-typescript-gate (push) Has been cancelled
Test (Install) / python-minimal (3.12) (push) Has been cancelled
Test (Install) / python-minimal (3.11) (push) Has been cancelled
Test (Install) / python-extra (agno, mirage.agents.agno) (push) Has been cancelled
Test (Install) / python-extra (chroma, mirage.resource.chroma) (push) Has been cancelled
Test (Install) / python-extra (pdf, mirage.core.filetype.pdf) (push) Has been cancelled
Integ / integ (push) Has been cancelled
Integ / integ-database (push) Has been cancelled
Integ / integ-database-ts (push) Has been cancelled
Integ / integ-data (push) Has been cancelled
Integ / integ-ssh (push) Has been cancelled
Integ / integ-ssh-ts (push) Has been cancelled
Test (Python) / audit (push) Has been cancelled
Test (TypeScript) / test (push) Has been cancelled
Test (TypeScript) / python-fs-shim (push) Has been cancelled
CLI exit codes / Python CLI (push) Has been cancelled
CLI exit codes / TypeScript CLI (push) Has been cancelled
CLI exit codes / Cross-language snapshot interop (push) Has been cancelled
Test (Python) / test (push) Has been cancelled
Test (Python) / import-isolation (deepagents, openai, mirage.agents.openai_agents) (push) Has been cancelled
Test (Python) / import-isolation (deepagents, pydantic-ai, mirage.agents.pydantic_ai) (push) Has been cancelled
Integ / integ-ts (push) Has been cancelled
Integ / integ-fuse (push) Has been cancelled
Test (Install) / python-extra (databricks, mirage.resource.databricks_volume) (push) Has been cancelled
Test (Install) / python-extra (deepagents, mirage.agents.langchain) (push) Has been cancelled
Test (Install) / python-extra (email, mirage.resource.email) (push) Has been cancelled
Test (Install) / python-extra (fuse, mirage.fuse.mount) (push) Has been cancelled
Test (Install) / python-extra (hdf5, mirage.core.filetype.hdf5) (push) Has been cancelled
Test (Install) / python-extra (hf, mirage.resource.hf_buckets) (push) Has been cancelled
Test (Install) / python-extra (lancedb, mirage.resource.lancedb) (push) Has been cancelled
Test (Install) / python-extra (langfuse, mirage.resource.langfuse) (push) Has been cancelled
Test (Install) / python-extra (mongodb, mirage.resource.mongodb) (push) Has been cancelled
Test (Install) / python-extra (nextcloud, mirage.resource.nextcloud) (push) Has been cancelled
Test (Install) / python-extra (openai, mirage.agents.openai_agents) (push) Has been cancelled
Test (Install) / python-extra (openhands, mirage.agents.openhands, 3.12) (push) Has been cancelled
Test (Install) / python-extra (parquet, mirage.core.filetype.parquet) (push) Has been cancelled
Test (Install) / python-extra (postgres, mirage.resource.postgres) (push) Has been cancelled
Test (Install) / python-extra (pydantic-ai, mirage.agents.pydantic_ai) (push) Has been cancelled
Test (Install) / python-extra (qdrant, mirage.resource.qdrant) (push) Has been cancelled
Test (Install) / python-extra (redis, mirage.resource.redis) (push) Has been cancelled
Test (Install) / python-extra (s3, mirage.resource.s3) (push) Has been cancelled
Test (Install) / python-extra (ssh, mirage.resource.ssh) (push) Has been cancelled
Test (Install) / ts-minimal (push) Has been cancelled
151 lines
5.4 KiB
Python
151 lines
5.4 KiB
Python
# ========= Copyright 2026 @ Strukto.AI All Rights Reserved. =========
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
# ========= Copyright 2026 @ Strukto.AI All Rights Reserved. =========
|
|
|
|
import asyncio
|
|
import os
|
|
|
|
from dotenv import load_dotenv
|
|
|
|
from mirage import MountMode, Workspace
|
|
from mirage.resource.gdrive import GoogleDriveConfig, GoogleDriveResource
|
|
from mirage.resource.github import GitHubConfig, GitHubResource
|
|
from mirage.resource.s3 import S3Config, S3Resource
|
|
|
|
load_dotenv(".env.development")
|
|
|
|
s3_config = S3Config(
|
|
bucket=os.environ["AWS_S3_BUCKET"],
|
|
region=os.environ.get("AWS_DEFAULT_REGION", "us-east-1"),
|
|
aws_access_key_id=os.environ["AWS_ACCESS_KEY_ID"],
|
|
aws_secret_access_key=os.environ["AWS_SECRET_ACCESS_KEY"],
|
|
)
|
|
gdrive_config = GoogleDriveConfig(
|
|
client_id=os.environ["GOOGLE_CLIENT_ID"],
|
|
client_secret=os.environ["GOOGLE_CLIENT_SECRET"],
|
|
refresh_token=os.environ["GOOGLE_REFRESH_TOKEN"],
|
|
)
|
|
github_config = GitHubConfig(token=os.environ["GITHUB_TOKEN"])
|
|
|
|
ws = Workspace(
|
|
{
|
|
"/s3/": S3Resource(s3_config),
|
|
"/gdrive/": GoogleDriveResource(gdrive_config),
|
|
"/github/": GitHubResource(
|
|
github_config, owner="strukto", repo="mirage"),
|
|
},
|
|
mode=MountMode.READ,
|
|
)
|
|
|
|
|
|
def ops_summary() -> str:
|
|
records = ws.ops.records
|
|
total = sum(r.bytes for r in records)
|
|
return f"{len(records)} ops, {total} bytes transferred"
|
|
|
|
|
|
async def main():
|
|
# ── prime gdrive cache ──
|
|
await ws.execute("ls /gdrive/")
|
|
await ws.execute("ls /gdrive/mirage/")
|
|
|
|
# ── plan: directory scans across resources ──
|
|
print("=== PLAN: DIRECTORY SCANS ===\n")
|
|
|
|
dr = await ws.execute("grep mirage /s3/data/example.jsonl", provision=True)
|
|
print(f"s3 single file: network_read={dr.network_read}")
|
|
|
|
dr = await ws.execute("grep mirage /gdrive/mirage/example.jsonl",
|
|
provision=True)
|
|
print(f"gdrive single file: network_read={dr.network_read}")
|
|
|
|
dr = await ws.execute("rg import /github/mirage/commands/registry.py",
|
|
provision=True)
|
|
print(f"github single file: network_read={dr.network_read}")
|
|
|
|
print(f"\nStats after plans (should be 0): {ops_summary()}")
|
|
|
|
# ── S3: grep on single file vs directory ──
|
|
print("\n=== S3: SINGLE FILE vs DIRECTORY ===\n")
|
|
|
|
r = await ws.execute("grep mirage /s3/data/example.jsonl | wc -l")
|
|
print(f"single file: {(await r.stdout_str()).strip()} matches")
|
|
|
|
r = await ws.execute("rg -l mirage /s3/data/")
|
|
files = (await r.stdout_str()).strip().splitlines()
|
|
print(f"directory rg -l: {len(files)} files match")
|
|
print(f"Stats: {ops_summary()}")
|
|
|
|
# ── Google Drive: grep with streaming ──
|
|
print("\n=== GDRIVE: GREP WITH STREAMING ===\n")
|
|
|
|
r = await ws.execute(
|
|
"grep queue-operation /gdrive/mirage/example.jsonl | wc -l")
|
|
print(f"grep | wc: {(await r.stdout_str()).strip()} matches")
|
|
|
|
r = await ws.execute("grep queue-operation /gdrive/mirage/example.jsonl"
|
|
" | head -n 3")
|
|
lines = (await r.stdout_str()).strip().splitlines()
|
|
print(f"grep | head -n 3: {len(lines)} lines")
|
|
|
|
print(f"Stats: {ops_summary()}")
|
|
|
|
# ── GitHub: rg with search_code optimization ──
|
|
print("\n=== GITHUB: RG (search_code optimization) ===\n")
|
|
|
|
r = await ws.execute(
|
|
"rg -l workspace /github/mirage/workspace/workspace.py")
|
|
files = (await r.stdout_str()).strip().splitlines()
|
|
print(f"rg -l workspace (single file): {len(files)} files")
|
|
if files:
|
|
print(f" {files[0]}")
|
|
|
|
r = await ws.execute("rg -l import /github/mirage/")
|
|
if r.stderr:
|
|
print(f"rg on large dir: {r.stderr.decode().strip()}")
|
|
else:
|
|
files = (await r.stdout_str()).strip().splitlines()
|
|
print(f"rg -l import (large dir): {len(files)} files")
|
|
|
|
r = await ws.execute("grep -c def /github/mirage/commands/registry.py")
|
|
print(f"grep -c def registry.py: {(await r.stdout_str()).strip()}")
|
|
|
|
print(f"Stats: {ops_summary()}")
|
|
|
|
# ── cross-resource consistency ──
|
|
print("\n=== CROSS-RESOURCE: SAME DATA ===\n")
|
|
|
|
r1 = await ws.execute("wc -l /s3/data/example.jsonl")
|
|
r2 = await ws.execute("wc -l /gdrive/mirage/example.jsonl")
|
|
print(f"s3 wc -l: {(await r1.stdout_str()).strip()}")
|
|
print(f"gdrive wc -l: {(await r2.stdout_str()).strip()}")
|
|
|
|
r1 = await ws.execute("grep -c queue-operation /s3/data/example.jsonl")
|
|
r2 = await ws.execute(
|
|
"grep -c queue-operation /gdrive/mirage/example.jsonl")
|
|
print(f"s3 grep -c queue-operation: {(await r1.stdout_str()).strip()}")
|
|
print(f"gdrive grep -c queue-operation: {(await r2.stdout_str()).strip()}")
|
|
|
|
# ── bash history ──
|
|
print("\n=== BASH HISTORY ===\n")
|
|
|
|
print(f"Total ops: {ops_summary()}")
|
|
print(f"Commands recorded: {len(await ws.history())}")
|
|
|
|
r = await ws.execute("tail -n 6 /.bash_history")
|
|
for line in (await r.stdout_str()).strip().splitlines():
|
|
print(f" {line[:120]}")
|
|
|
|
|
|
asyncio.run(main())
|