Is there a way to hide csv files on Spaces to prevent users from being able to download them? I’m aware you can add secrets but that doesn’t seem to cover files?
Hi @bradley6597, here’s a quick trick to get protected files on a public Space
- Create a new dataset/model
- Use the
huggingface_hublibrary to clone the dataset/model on the path you’re running the script from
- Dont forget to add the secret
HUGGING_FACE_HUB_TOKENto your Space secrets so
token=True, you can also pass the token e.g
from huggingface_hub import Repository repo = Repository( local_dir="secret-csvs", repo_type="dataset", clone_from="radames/secret-csvs", token=True ) repo.git_pull()
Now you can read you files from the
I ended up following the same principles and used this code instead
from datasets import load_dataset from huggingface_hub import login login(token = os.environ['HUB_TOKEN']) dataset = load_dataset("hugging/face/path")
I’m a new fan of HF and I had a similar problem if I wanted to import a utils.py file from private Space. How should I operate it?
Hey @freddyaboulton, how would you then call functions within the file after using hf_hub_download as it’s in the cache?