# Programatic access to experiments

**URL:** <https://discuss.dvc.org/t/programatic-access-to-experiments/1464>\
**Category:** Questions\
**Created:** [January 18, 2023, 12:38am UTC](https://discuss.dvc.org/t/programatic-access-to-experiments/1464 "2023-01-18T00:38:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gregstarr](https://avatars.discourse-cdn.com/v4/letter/g/c77e96/32.png) [@gregstarr](https://discuss.dvc.org/u/gregstarr)\
**Post date:** [January 18, 2023, 12:38am UTC](https://discuss.dvc.org/t/programatic-access-to-experiments/1464/1 "2023-01-18T00:38:21Z")

</div>

Hello,

What is the best way to programatically access experiments? I want to write a script which goes through all of the experiments on a particular ref e.g. HEAD, and collects some data / information from the files there. The files could be git or dvc tracked. I have lots of output from my pipeline, so it is more than I would want to put in a metrics json. It seems like DVCFileSystem ([DVCFileSystem](https://dvc.org/doc/api-reference/dvcfilesystem)) might do this? Would I just need to get a list of all the experiment revs, then loop over them and create a DVCFileSystem for each one?

Thanks,  
Greg

---

<div class="post-metadata">

**Author:** ![kupruser](https://avatars.discourse-cdn.com/v4/letter/k/e95f7d/32.png) [@kupruser](https://discuss.dvc.org/u/kupruser)\
**Post date:** [January 18, 2023, 5:06pm UTC](https://discuss.dvc.org/t/programatic-access-to-experiments/1464/2 "2023-01-18T17:06:46Z")

</div>

Hey Greg,

Currently there is no exp-specific api like that, but if all you need is an fs-like interface to experiments then yes, creating a DVCFileSystem for each rev would do the trick. Please let us know how it goes for you or if you’ll run into any problems.

---

<div class="post-metadata">

**Author:** ![gregstarr](https://avatars.discourse-cdn.com/v4/letter/g/c77e96/32.png) [@gregstarr](https://discuss.dvc.org/u/gregstarr)\
**Post date:** [February 1, 2023, 7:31pm UTC](https://discuss.dvc.org/t/programatic-access-to-experiments/1464/3 "2023-02-01T19:31:22Z")

</div>

Thanks for the advice.

This is what I ended up doing:

```auto
repo = Repo(".")
# determine current branch
branch = repo.scm.active_branch()
# get experiments on this commit
experiments = repo.experiments.ls()[branch]
for exp_name in experiments:
    print(f"collecting data for {exp_name}")
    # make dvc file system for this experiment
    fs = DVCFileSystem(rev=exp_name)

```

then accessing files, e.g. `pandas.read_csv` through the dvc fs.
