Skip to content

Instantly share code, notes, and snippets.

@skshetry
Created January 4, 2022 02:02
Show Gist options
  • Save skshetry/61c91adaa5efacf13973ce29ed67fe99 to your computer and use it in GitHub Desktop.
Save skshetry/61c91adaa5efacf13973ce29ed67fe99 to your computer and use it in GitHub Desktop.
import os
from funcy import log_durations
from rich.console import Console
import dvc.api
from dvc._debug import profile
from dvc.external_repo import clean_repos
from dvc.fs.pool import close_pools
repo = "https://github.com/iterative/example-get-started"
status = Console().status
with status("old api"), log_durations(print, "old api"), profile("old_api.prof"):
dvc.api.read("model.pkl", repo=repo, mode="rb")
dvc.api.read("scores.json", repo=repo, encoding="utf-8")
dvc.api.get_url(os.path.join("data", "data.xml"), repo=repo)
dvc.api.get_url(os.path.join("data", "features", "test.pkl"), repo=repo)
dvc.api.get_url(os.path.join("data", "features", "train.pkl"), repo=repo)
clean_repos()
close_pools()
with status("files api"), log_durations(print, "files api"), profile("repo_path.prof"):
with dvc.api.files(repo=repo) as root:
pkl_file = root / "model.pkl"
pkl_file.read_bytes()
scores_file = root / "scores.json"
scores_file.read_text(encoding="utf-8")
data_dir = root / "data"
(data_dir / "data.xml").url()
features = data_dir / "features"
test_pkl = features / "test.pkl"
test_pkl.url()
train_pkl = features / "train.pkl"
train_pkl.url()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment