phyloforfun commited on
Commit
6e0a9ba
·
1 Parent(s): 8aa7838
Files changed (1) hide show
  1. vouchervision/utils_hf.py +5 -6
vouchervision/utils_hf.py CHANGED
@@ -150,27 +150,26 @@ def check_prompt_yaml_filename(fname):
150
  def report_violation(file_name, is_hf=True):
151
  # Format the current date and time
152
  current_time = datetime.datetime.now().strftime("%Y_%m_%d__%H_%M_%S")
153
- file_name = f"violation_{current_time}.yaml"
154
 
155
- # Create a temporary YAML file
156
- with tempfile.NamedTemporaryFile(delete=False, suffix='.yaml') as temp_file:
157
  # Example content - customize as needed
158
  content = {
159
  'violation_time': current_time,
160
  'notes': 'This is an autogenerated violation report.',
161
- 'name_of_file': file_name,
162
  }
163
  # Write the content to the temporary YAML file in text mode
164
  yaml.dump(content, temp_file, default_flow_style=False)
165
  temp_filepath = temp_file.name
166
 
167
  # Now upload the temporary file
168
- upload_to_drive(temp_filepath, file_name, is_hf=is_hf)
169
 
170
  # Optionally, delete the temporary file if you don't want it to remain on disk after uploading
171
  os.remove(temp_filepath)
172
 
173
-
174
  # Function to upload files to Google Drive
175
  def upload_to_drive(filepath, filename, is_hf=True, cfg_private=None, do_upload = True):
176
  if do_upload:
 
150
  def report_violation(file_name, is_hf=True):
151
  # Format the current date and time
152
  current_time = datetime.datetime.now().strftime("%Y_%m_%d__%H_%M_%S")
153
+ violation_file_name = f"violation_{current_time}.yaml" # Updated variable name to avoid confusion
154
 
155
+ # Create a temporary YAML file in text mode
156
+ with tempfile.NamedTemporaryFile(delete=False, mode='w', suffix='.yaml') as temp_file:
157
  # Example content - customize as needed
158
  content = {
159
  'violation_time': current_time,
160
  'notes': 'This is an autogenerated violation report.',
161
+ 'name_of_file': violation_file_name,
162
  }
163
  # Write the content to the temporary YAML file in text mode
164
  yaml.dump(content, temp_file, default_flow_style=False)
165
  temp_filepath = temp_file.name
166
 
167
  # Now upload the temporary file
168
+ upload_to_drive(temp_filepath, violation_file_name, is_hf=is_hf)
169
 
170
  # Optionally, delete the temporary file if you don't want it to remain on disk after uploading
171
  os.remove(temp_filepath)
172
 
 
173
  # Function to upload files to Google Drive
174
  def upload_to_drive(filepath, filename, is_hf=True, cfg_private=None, do_upload = True):
175
  if do_upload: