# Cache for custom data loader

**URL:** <https://discuss.huggingface.co/t/cache-for-custom-data-loader/23490>\
**Category:** Intermediate\
**Created:** [September 22, 2022, 12:31pm UTC](https://discuss.huggingface.co/t/cache-for-custom-data-loader/23490 "2022-09-22T12:31:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Emilio](https://avatars.discourse-cdn.com/v4/letter/e/f475e1/32.png) [@Emilio](https://discuss.huggingface.co/u/Emilio)\
**Post date:** [September 22, 2022, 12:31pm UTC](https://discuss.huggingface.co/t/cache-for-custom-data-loader/23490/1 "2022-09-22T12:31:04Z")

</div>

Hello Everyone,  
I have implemented a custom loader for my data and I’ve realized that HF creates a copy of my loader file (.py) into my home .cache, and that’s the file that is executed and not the one that I have in my workspace. I just wanted to ask for the reason of this behavior and most importantly how I can change the location where HF copy this file. I don’t want it to be in my home. I tried with the cache\_dir argument of the function load\_dataset and also the cache\_dir of the download\_config, but neither of them works for this. Any help will be greatly appreciated.

Thanks,  
Emilio

---

<div class="post-metadata">

**Author:** ![lhoestq](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/lhoestq/32/64813_2.png) [@lhoestq](https://discuss.huggingface.co/u/lhoestq)\
**Post date:** [September 23, 2022, 4:52pm UTC](https://discuss.huggingface.co/t/cache-for-custom-data-loader/23490/2 "2022-09-23T16:52:33Z")

</div>

For your code to be imported properly we move it to the `datasets` modules cache. Dataset scripts from the Hub or from your local machine are copied there and imported from there in python to be executed. This way we don’t need to modify `sys.path` for every script, which can sometimes lead to unexpected behaviors.

You can change this directory using the `HF_MODULES_CACHE` environment variable.
