rosemariafontana commited on
Commit
bfefbe8
·
verified ·
1 Parent(s): 86d64eb

Create script_for_automation.py

Browse files
Files changed (1) hide show
  1. script_for_automation.py +71 -0
script_for_automation.py ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import requests
2
+
3
+ # The purpose of this script is to automate running a bunch of tests
4
+ # This script will take an input folder
5
+ # The input folder should contain:
6
+ # 1. A file containing a list of the recipe parameters
7
+ # 2. A file containing the input data for each of the schemas
8
+ # 3. ....
9
+
10
+ # Steps to do this that we will outline then perform
11
+ # First, get the gold standard JSONs from baserow
12
+ # Next, get the recipe parameter list from the input folder
13
+ # Iterate through the recipe parameter list one at a time
14
+ # In the iteration, first fill out a surveystack submission
15
+ # Next, save the surveystack submission ID
16
+ # Use the iteration parameters to then get the three JSONs back from chatgpt
17
+ # Compare the JSONs to the gold standard JSONs
18
+ # Print out the differences in a .csv
19
+ # Print out a side by side of the yaml
20
+ # store all these together
21
+ # continue through iterations
22
+ # create downloadables of the results
23
+
24
+ BASEROW_API_KEY = os.getenv("BASEROW_API_KEY")
25
+
26
+ def get_baserow_data():
27
+ BASEROW_API_BASE = "https://baserow.f11804a1.federatedcomputer.net/api"
28
+ TABLE_ID = "560"
29
+ baserow_url = f"{BASEROW_API_BASE}/database/rows/table/{TABLE_ID}/?user_field_names=true"
30
+
31
+ headers = {
32
+ "Authorization": f"Token {os.environ["BASEROW_API_KEY"]}",
33
+ "Content-Type": "application/json"
34
+ }
35
+
36
+ try:
37
+ response = requests.get(baserow_url, headers=headers)
38
+ response.raise_for_status()
39
+ rows = response.json()
40
+ results = rows.get("results", [])
41
+
42
+ for row in results:
43
+ print(f"Row ID: {row.get('id')}, Data: {row}")
44
+
45
+ if row.get("id") == 2:
46
+ liz_carrot_plantings_gold_standard = row.get("Plantings and Fields - Gold Standard")
47
+ liz_carrot_interactions_gold_standard = row.get("Interactions - Gold Standard")
48
+ liz_carrot_trials_gold_standard = row.get("Trials - Gold Standard")
49
+ elif row.get("id") == 3:
50
+ ben_soybean_plantings_gold_standard = row.get("Plantings and Fields - Gold Standard")
51
+ ben_soybean_interactions_gold_standard = row.get("Interactions - Gold Standard")
52
+ ben_soybean_trials_gold_standard = row.get("Trials - Gold Standard")
53
+ elif row.get("id") == 5:
54
+ wally_squash_plantings_gold_standard = row.get("Plantings and Fields - Gold Standard")
55
+ wally_squash_interactions_gold_standard = row.get("Interactions - Gold Standard")
56
+ wally_squash_trials_gold_standard = row.get("Trials - Gold Standard")
57
+
58
+ result_list = [
59
+ liz_carrot_plantings_gold_standard, liz_carrot_interactions_gold_standard, liz_carrot_trials_gold_standard,
60
+ ben_soybean_plantings_gold_standard, ben_soybean_interactions_gold_standard, ben_soybean_trials_gold_standard,
61
+ wally_squash_plantings_gold_standard, wally_squash_interactions_gold_standard, wally_squash_trials_gold_standard
62
+ ]
63
+
64
+ return result_list
65
+
66
+ except requests.exceptions.RequestException as e:
67
+ print(f"Failed to fetch rows: {e}")
68
+
69
+
70
+
71
+