davidmezzetti commited on
Commit
eade6a1
1 Parent(s): 153cd47

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -3
app.py CHANGED
@@ -49,9 +49,35 @@ class Application:
49
  # Workflow run id
50
  self.runid = None
51
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  def load(self, components):
53
  """
54
- Load an existing workflow file.
55
 
56
  Args:
57
  components: list of components to load
@@ -70,8 +96,12 @@ class Application:
70
  params = st.experimental_get_query_params()
71
  index = params.get("default")
72
  index = index[0] if index else 0
73
- if index and index in names:
74
- index = names.index(index) + 1
 
 
 
 
75
 
76
  selected = st.selectbox("Load workflow", ["--"] + names, index)
77
  if selected != "--":
 
49
  # Workflow run id
50
  self.runid = None
51
 
52
+ def default():
53
+ """
54
+ Gets default workflow index.
55
+
56
+ Args:
57
+ names: list of workflow names
58
+
59
+ Returns:
60
+ default workflow index
61
+ """
62
+
63
+ # Get names as lowercase to match case-insensitive
64
+ lnames = [name.lower() for name in names]
65
+
66
+ # Get default workflow param
67
+ params = st.experimental_get_query_params()
68
+ index = params.get("default")
69
+ index = index[0].lower() if index else 0
70
+
71
+ # Lookup index of workflow name, add 1 to account for "--"
72
+ if index and index in lnames:
73
+ return lnames.index(index) + 1
74
+
75
+ # Workflow not found, default to index 0
76
+ return 0
77
+
78
  def load(self, components):
79
  """
80
+ Load an existing workflow file.
81
 
82
  Args:
83
  components: list of components to load
 
96
  params = st.experimental_get_query_params()
97
  index = params.get("default")
98
  index = index[0] if index else 0
99
+ lnames = [name.lower() for name in names]
100
+
101
+ if index and index.lower() in lnames:
102
+ index = lnames.index(index.lower()) + 1
103
+ else:
104
+ index = 0
105
 
106
  selected = st.selectbox("Load workflow", ["--"] + names, index)
107
  if selected != "--":