mrcuddle commited on
Commit
ff86828
·
verified ·
1 Parent(s): 3d7aa14

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -6
app.py CHANGED
@@ -1,21 +1,24 @@
1
  import gradio as gr
2
  import pandas as pd
3
  import requests
4
- import spaces
5
 
6
- @spaces.GPU
7
  def convert_parquet_to_jsonl(parquet_file=None, parquet_url=None):
8
  if parquet_file is not None:
9
  df = pd.read_parquet(parquet_file.name)
10
  elif parquet_url is not None:
11
  response = requests.get(parquet_url)
12
- df = pd.read_parquet(response.content)
 
13
  else:
14
  raise ValueError("Either parquet_file or parquet_url must be provided")
 
15
  jsonl_data = df.to_json(orient='records', lines=True)
16
- with open("output.jsonl", "w") as f:
 
17
  f.write(jsonl_data)
18
- return "output.jsonl"
 
19
 
20
  demo = gr.Interface(
21
  fn=convert_parquet_to_jsonl,
@@ -26,4 +29,4 @@ demo = gr.Interface(
26
  )
27
 
28
  if __name__ == "__main__":
29
- demo.launch()
 
1
  import gradio as gr
2
  import pandas as pd
3
  import requests
4
+ from io import BytesIO
5
 
 
6
  def convert_parquet_to_jsonl(parquet_file=None, parquet_url=None):
7
  if parquet_file is not None:
8
  df = pd.read_parquet(parquet_file.name)
9
  elif parquet_url is not None:
10
  response = requests.get(parquet_url)
11
+ response.raise_for_status() # Ensure the request was successful
12
+ df = pd.read_parquet(BytesIO(response.content))
13
  else:
14
  raise ValueError("Either parquet_file or parquet_url must be provided")
15
+
16
  jsonl_data = df.to_json(orient='records', lines=True)
17
+ output_file_path = "output.jsonl"
18
+ with open(output_file_path, "w") as f:
19
  f.write(jsonl_data)
20
+
21
+ return output_file_path
22
 
23
  demo = gr.Interface(
24
  fn=convert_parquet_to_jsonl,
 
29
  )
30
 
31
  if __name__ == "__main__":
32
+ demo.launch()