seanpedrickcase commited on
Commit
5f5c87a
1 Parent(s): 4300019

App will now check for an output folder and create it if it doesn't exist

Browse files
Files changed (3) hide show
  1. app.py +4 -5
  2. tools/aws_functions.py +1 -1
  3. tools/gradio.py +12 -0
app.py CHANGED
@@ -5,7 +5,7 @@ import gradio as gr
5
  import pandas as pd
6
 
7
  from tools.matcher_funcs import run_matcher
8
- from tools.gradio import initial_data_load
9
  from tools.aws_functions import load_data_from_aws
10
 
11
  import warnings
@@ -20,10 +20,9 @@ today_rev = datetime.now().strftime("%Y%m%d")
20
 
21
  # Base folder is where the code file is stored
22
  base_folder = Path(os.getcwd())
23
- input_folder = base_folder/"Input/"
24
- output_folder = base_folder/"Output/"
25
- diagnostics_folder = base_folder/"Diagnostics/"
26
- prep_folder = base_folder/"Helper functions/"
27
 
28
  # Create the gradio interface
29
  block = gr.Blocks(theme = gr.themes.Base())
 
5
  import pandas as pd
6
 
7
  from tools.matcher_funcs import run_matcher
8
+ from tools.gradio import initial_data_load, ensure_output_folder_exists
9
  from tools.aws_functions import load_data_from_aws
10
 
11
  import warnings
 
20
 
21
  # Base folder is where the code file is stored
22
  base_folder = Path(os.getcwd())
23
+ output_folder = "output/"
24
+
25
+ ensure_output_folder_exists(output_folder)
 
26
 
27
  # Create the gradio interface
28
  block = gr.Blocks(theme = gr.themes.Base())
tools/aws_functions.py CHANGED
@@ -7,8 +7,8 @@ import os
7
  PandasDataFrame = Type[pd.DataFrame]
8
 
9
  try:
 
10
  bucket_name = os.environ['ADDRESS_MATCHER_BUCKET']
11
- session = boto3.Session(profile_name="default")
12
  except Exception as e:
13
  bucket_name = ''
14
  print(e)
 
7
  PandasDataFrame = Type[pd.DataFrame]
8
 
9
  try:
10
+ session = boto3.Session()
11
  bucket_name = os.environ['ADDRESS_MATCHER_BUCKET']
 
12
  except Exception as e:
13
  bucket_name = ''
14
  print(e)
tools/gradio.py CHANGED
@@ -1,5 +1,6 @@
1
  import gradio as gr
2
  import pandas as pd
 
3
 
4
  def detect_file_type(filename):
5
  """Detect the file type based on its extension."""
@@ -51,6 +52,17 @@ def initial_data_load(in_file):
51
 
52
  return output_message, gr.Dropdown(choices=concat_choices), gr.Dropdown(choices=concat_choices), df, results_df
53
 
 
 
 
 
 
 
 
 
 
 
 
54
 
55
  def dummy_function(in_colnames):
56
  """
 
1
  import gradio as gr
2
  import pandas as pd
3
+ import os
4
 
5
  def detect_file_type(filename):
6
  """Detect the file type based on its extension."""
 
52
 
53
  return output_message, gr.Dropdown(choices=concat_choices), gr.Dropdown(choices=concat_choices), df, results_df
54
 
55
+ def ensure_output_folder_exists(output_folder):
56
+ """Checks if the output folder exists, creates it if not."""
57
+
58
+ folder_name = output_folder
59
+
60
+ if not os.path.exists(folder_name):
61
+ # Create the folder if it doesn't exist
62
+ os.makedirs(folder_name)
63
+ print(f"Created the output folder.")
64
+ else:
65
+ print(f"The output folder already exists.")
66
 
67
  def dummy_function(in_colnames):
68
  """