byte-vortex commited on
Commit
531460a
·
verified ·
1 Parent(s): 529204e

Deploy Myco from CI

Browse files
Files changed (2) hide show
  1. tests/test_myco_core.py +4 -0
  2. ui/gradio_app.py +13 -0
tests/test_myco_core.py CHANGED
@@ -95,6 +95,10 @@ class MycoCoreTests(unittest.TestCase):
95
  duplicates = {name: lines for name, lines in function_lines.items() if len(lines) > 1}
96
  self.assertEqual(duplicates, {}, f"duplicate functions in {path}")
97
  self.assertNotIn(future_import, source, f"future import in {path}")
 
 
 
 
98
  def test_gradio_app_file_has_no_duplicate_functions_or_future_import(self):
99
  source = Path("ui/gradio_app.py").read_text()
100
  tree = ast.parse(source)
 
95
  duplicates = {name: lines for name, lines in function_lines.items() if len(lines) > 1}
96
  self.assertEqual(duplicates, {}, f"duplicate functions in {path}")
97
  self.assertNotIn(future_import, source, f"future import in {path}")
98
+
99
+ def test_gradio_app_avoids_fragile_multiline_return_tuples(self):
100
+ source = Path("ui/gradio_app.py").read_text()
101
+ self.assertNotIn("return (", source)
102
  def test_gradio_app_file_has_no_duplicate_functions_or_future_import(self):
103
  source = Path("ui/gradio_app.py").read_text()
104
  tree = ast.parse(source)
ui/gradio_app.py CHANGED
@@ -30,6 +30,9 @@ def mushroom_card_from_state(current):
30
  def search_forest(collection):
31
  """Explore the forest and refresh every visible gameplay panel."""
32
  mushroom, current, history = discover_mushroom(collection)
 
 
 
33
  return (
34
  forest_scene(current, collection),
35
  game_status_markdown(current, collection),
@@ -56,6 +59,8 @@ def explore(collection: CollectionState) -> tuple[str, str, MushroomState, list[
56
  history,
57
  dex_markdown(collection),
58
  progress_markdown(collection),
 
 
59
  )
60
 
61
 
@@ -66,6 +71,8 @@ def ask_companion(message, history, current):
66
 
67
  def collect_discovery(current, collection, history):
68
  """Collect the active mushroom and refresh collection-dependent panels."""
 
 
69
  def ask_myco(message, history, current):
70
  def ask_myco(
71
  message: str,
@@ -91,11 +98,15 @@ def add_to_dex(
91
  dex_markdown(updated_collection),
92
  updated_history,
93
  progress_markdown(updated_collection),
 
 
94
  )
95
 
96
 
97
  def study_discovery(current, history, collection):
98
  """Study the active mushroom and refresh the discovery card."""
 
 
99
  def study_mushroom(current, history, collection):
100
  def study_mushroom(
101
  current: MushroomState | None,
@@ -110,6 +121,8 @@ def study_mushroom(
110
  game_status_markdown(updated_current, collection),
111
  mushroom_card_from_state(updated_current),
112
  updated_history,
 
 
113
  )
114
 
115
 
 
30
  def search_forest(collection):
31
  """Explore the forest and refresh every visible gameplay panel."""
32
  mushroom, current, history = discover_mushroom(collection)
33
+ outputs = [
34
+ forest_scene(current, collection),
35
+ game_status_markdown(current, collection),
36
  return (
37
  forest_scene(current, collection),
38
  game_status_markdown(current, collection),
 
59
  history,
60
  dex_markdown(collection),
61
  progress_markdown(collection),
62
+ ]
63
+ return tuple(outputs)
64
  )
65
 
66
 
 
71
 
72
  def collect_discovery(current, collection, history):
73
  """Collect the active mushroom and refresh collection-dependent panels."""
74
+ updated_collection, updated_history = collect_current(current, collection, history)
75
+ outputs = [
76
  def ask_myco(message, history, current):
77
  def ask_myco(
78
  message: str,
 
98
  dex_markdown(updated_collection),
99
  updated_history,
100
  progress_markdown(updated_collection),
101
+ ]
102
+ return tuple(outputs)
103
  )
104
 
105
 
106
  def study_discovery(current, history, collection):
107
  """Study the active mushroom and refresh the discovery card."""
108
+ updated_current, updated_history = study_current(current, history)
109
+ outputs = [
110
  def study_mushroom(current, history, collection):
111
  def study_mushroom(
112
  current: MushroomState | None,
 
121
  game_status_markdown(updated_current, collection),
122
  mushroom_card_from_state(updated_current),
123
  updated_history,
124
+ ]
125
+ return tuple(outputs)
126
  )
127
 
128