# How to automate dvc pull request for a single file?

**URL:** <https://discuss.dvc.org/t/how-to-automate-dvc-pull-request-for-a-single-file/666>\
**Category:** Questions\
**Created:** [February 12, 2021, 5:07am UTC](https://discuss.dvc.org/t/how-to-automate-dvc-pull-request-for-a-single-file/666 "2021-02-12T05:07:24Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Somya](https://avatars.discourse-cdn.com/v4/letter/s/e0b2c6/32.png) [@Somya](https://discuss.dvc.org/u/Somya)\
**Post date:** [February 12, 2021, 5:07am UTC](https://discuss.dvc.org/t/how-to-automate-dvc-pull-request-for-a-single-file/666/1 "2021-02-12T05:07:24Z")

</div>

We are using dvc for heavy AI-ML model files in our gitlab repository.  
Lets say, with the help of DVC, we can easily push a model file ‘X’ to cloud but while pulling same file on some other server, we have to use command “dvc pull X”.

Currently, we run this command “dvc pull X” manually everytime we update our file X. Since, we dont want to pull all the updated files on cloud therefore it is necessary for us to specify ‘X’ in our dvc pull requests.

My question is how can we automate this dvc pull request in our CI yaml file for a single file X, if this X is a variable for our file name ?

---

<div class="post-metadata">

**Author:** ![jorgeorpinel](https://yyz1.discourse-cdn.com/flex035/user_avatar/discuss.dvc.org/jorgeorpinel/32/46_2.png) [@jorgeorpinel](https://discuss.dvc.org/u/jorgeorpinel)\
**Post date:** [February 12, 2021, 7:28am UTC](https://discuss.dvc.org/t/how-to-automate-dvc-pull-request-for-a-single-file/666/2 "2021-02-12T07:28:40Z")

</div>

Hi @Somya,

Could you set the file name as an environment variable in the CI system? (Perhaps via [GitLab CI/CD environment variables | GitLab](https://docs.gitlab.com/ee/ci/variables/#custom-environment-variables) if you’re using that)

Then if the env var name is `FILE_NAME`, you can

```auto
$ dvc pull $FILE_NAME

```

(from the CI job script)

Depending on your use case though, you may want to check out the `dvc get` or `dvc import` commands: [https://dvc.org/doc/command-reference/get](https://dvc.org/doc/command-reference/get), [https://dvc.org/doc/command-reference/import](https://dvc.org/doc/command-reference/import).

---

<div class="post-metadata">

**Author:** ![Somya](https://avatars.discourse-cdn.com/v4/letter/s/e0b2c6/32.png) [@Somya](https://discuss.dvc.org/u/Somya)\
**Post date:** [February 16, 2021, 10:45am UTC](https://discuss.dvc.org/t/how-to-automate-dvc-pull-request-for-a-single-file/666/3 "2021-02-16T10:45:36Z")

</div>

Hi @jorgeorpinel,  
Thanks for your reply.  
Regarding the solution based on environment variable, the file needs to be pushed from server 1 and get pulled on server 2, and if we will set file name in an environment variable then we will be doing that on server 2 and my problem will still persist. How can I communicate this environment variable between 2 branches of my gitlab repository ?

I will definitely checkout dvc get and dvc import as suggested.

Thanks and Regards

---

<div class="post-metadata">

**Author:** ![Paffciu](https://avatars.discourse-cdn.com/v4/letter/p/d07c76/32.png) [@Paffciu](https://discuss.dvc.org/u/Paffciu)\
**Post date:** [February 16, 2021, 1:02pm UTC](https://discuss.dvc.org/t/how-to-automate-dvc-pull-request-for-a-single-file/666/4 "2021-02-16T13:02:32Z")

</div>

@Somya

> How can I communicate this environment variable between 2 branches of my gitlab repository ?

Is it about communication between branches, or rather two different builds?  
Are they run in parallel, or is one depending on another?

---

<div class="post-metadata">

**Author:** ![Somya](https://avatars.discourse-cdn.com/v4/letter/s/e0b2c6/32.png) [@Somya](https://discuss.dvc.org/u/Somya)\
**Post date:** [February 17, 2021, 4:50am UTC](https://discuss.dvc.org/t/how-to-automate-dvc-pull-request-for-a-single-file/666/5 "2021-02-17T04:50:24Z")

</div>

Hi @Paffciu,  
My use case involves one feature branch which is then merged with “master” branch.  
Feature branch is just a clone of master branch on my local machine from which I will push my dvc file. And master branch means deployment of same repository on some other server with master branch. I want to pull a dvc file from master branch.  
To answer your question, master branch is dependent on feature branch and do not run in parallel.

---

<div class="post-metadata">

**Author:** ![Paffciu](https://avatars.discourse-cdn.com/v4/letter/p/d07c76/32.png) [@Paffciu](https://discuss.dvc.org/u/Paffciu)\
**Post date:** [February 17, 2021, 11:01am UTC](https://discuss.dvc.org/t/how-to-automate-dvc-pull-request-for-a-single-file/666/6 "2021-02-17T11:01:19Z")

</div>

@Somya  
And how does your workflow look like?

1. You do some changes in feature branch
2. You push the changed data with dvc
3. You push the git changes into master branch in core repo
4. You update your master branch on server 2  
And
5. You want to update only the stage that has been updated in step 3.  
Am I right so far?

---

<div class="post-metadata">

**Author:** ![Somya](https://avatars.discourse-cdn.com/v4/letter/s/e0b2c6/32.png) [@Somya](https://discuss.dvc.org/u/Somya)\
**Post date:** [February 17, 2021, 12:03pm UTC](https://discuss.dvc.org/t/how-to-automate-dvc-pull-request-for-a-single-file/666/7 "2021-02-17T12:03:53Z")

</div>

Hi @Paffciu,  
My workflow looks like following :

1. I do some changes in feature branch
2. I push the changed data with dvc
3. I merge master branch from feature branch using merge request feature of gitlab
4. Git pull all the changes in repository deployed on server 2 with master branch (Continuous integration written in gitlab config yaml file)

But as I pushed a dvc file from my feature branch, I would like to pull that file from master branch on server 2. A simple command “dvc pull $filename” can do that trick on server 2 but how can I automate this command if $filename is not fixed.
