derek-thomas HF staff commited on
Commit
826ed51
1 Parent(s): bcf2055

Updating function name

Browse files
Files changed (1) hide show
  1. main.py +15 -2
main.py CHANGED
@@ -29,7 +29,20 @@ login(auth_token, add_to_git_credential=True)
29
  logger = setup_logger(__name__)
30
 
31
 
32
- def get_dataset():
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  # Load the existing dataset from the Hugging Face hub or create a new one
34
  try:
35
  dataset = load_dataset(dataset_name)
@@ -53,7 +66,7 @@ def get_dataset():
53
  def main():
54
  date = datetime.now().strftime('%Y-%m-%d')
55
  logger.warning(f"Running main function for date: {date}")
56
- dataset = get_dataset()
57
 
58
  # Get Latest Data and merge with historic data
59
  new_df = get_latest_data()
 
29
  logger = setup_logger(__name__)
30
 
31
 
32
+ def load_or_create_dataset():
33
+ """
34
+ Loads an existing dataset from the Hugging Face hub or creates a new one if it doesn't exist.
35
+
36
+ This function attempts to load a dataset specified by 'dataset_name'. If the dataset is not found,
37
+ it creates a new dataset with 'dummy_data', pushes it to the Hugging Face hub, and then reloads it.
38
+ After reloading, the dummy data is removed from the dataset.
39
+
40
+ Returns:
41
+ dataset (DatasetDict): The loaded or newly created dataset.
42
+
43
+ Raises:
44
+ FileNotFoundError: If the dataset cannot be loaded or created.
45
+ """
46
  # Load the existing dataset from the Hugging Face hub or create a new one
47
  try:
48
  dataset = load_dataset(dataset_name)
 
66
  def main():
67
  date = datetime.now().strftime('%Y-%m-%d')
68
  logger.warning(f"Running main function for date: {date}")
69
+ dataset = load_dataset()
70
 
71
  # Get Latest Data and merge with historic data
72
  new_df = get_latest_data()