Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

dvc_utils.py 663 B

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
  1. import os
  2. import subprocess
  3. from datetime import datetime
  4. from app.utils import load_params
  5. UPLOAD_FOLDER = load_params()["UPLOAD_FOLDER"]
  6. def save_file_and_push_to_dvc(file_bytes, filename: str):
  7. os.makedirs(UPLOAD_FOLDER, exist_ok=True)
  8. file_path = os.path.join(UPLOAD_FOLDER, filename)
  9. with open(file_path, "wb") as f:
  10. f.write(file_bytes)
  11. subprocess.run(["dvc", "add", file_path], check=True)
  12. subprocess.run(["git", "add", f"{file_path}.dvc"], check=True)
  13. subprocess.run(["git", "commit", "-m", f"Add {filename} via UI at {datetime.now()}"], check=True)
  14. subprocess.run(["dvc", "push"], check=True)
  15. return file_path
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...