Skip to content

Commit

Permalink
Don't re-login every time
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhilwoodruff committed Nov 29, 2024
1 parent 4bdebb0 commit a83fbc8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions policyengine_core/data/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,14 +461,14 @@ def upload_to_huggingface(self, owner_name: str, model_name: str):
token = os.environ.get(
"HUGGING_FACE_TOKEN",
)
login(token=token)
api = HfApi()

api.upload_file(
path_or_fileobj=self.file_path,
path_in_repo=self.file_path.name,
repo_id=f"{owner_name}/{model_name}",
repo_type="model",
token=token,
)

def download_from_huggingface(
Expand All @@ -483,11 +483,11 @@ def download_from_huggingface(
token = os.environ.get(
"HUGGING_FACE_TOKEN",
)
login(token=token)

hf_hub_download(
repo_id=f"{owner_name}/{model_name}",
repo_type="model",
path=self.file_path,
revision=version,
token=token,
)

0 comments on commit a83fbc8

Please sign in to comment.