Skip to content

Commit 1f7613a

Browse files
committed
Refactor static file paths in HTML templates and update tests
- Updated paths for CSS and JS files in input_builder.html and pipeline_builder.html to reflect new directory structure. - Adjusted image source paths in pipeline_builder.html. - Modified test assertions in test_agentdriver_pipeline_ops.py to verify the correct static directory structure for both input_builder and pipeline_builder apps.
1 parent 57c1004 commit 1f7613a

9 files changed

Lines changed: 30 additions & 24 deletions

File tree

AFL/double_agent/AgentWebAppMixin.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ class AgentWebAppMixin:
4747
"""Reusable web app endpoints and static asset bindings for agent drivers."""
4848

4949
static_dirs = {
50-
"js": pathlib.Path(__file__).parent / "apps" / "pipeline_builder" / "js",
51-
"img": pathlib.Path(__file__).parent / "apps" / "pipeline_builder" / "img",
52-
"css": pathlib.Path(__file__).parent / "apps" / "pipeline_builder" / "css",
53-
"input_builder_js": pathlib.Path(__file__).parent / "apps" / "input_builder" / "js",
54-
"input_builder_css": pathlib.Path(__file__).parent / "apps" / "input_builder" / "css",
50+
"apps/pipeline_builder/js": pathlib.Path(__file__).parent / "apps" / "pipeline_builder" / "js",
51+
"apps/pipeline_builder/img": pathlib.Path(__file__).parent / "apps" / "pipeline_builder" / "img",
52+
"apps/pipeline_builder/css": pathlib.Path(__file__).parent / "apps" / "pipeline_builder" / "css",
53+
"apps/input_builder/js": pathlib.Path(__file__).parent / "apps" / "input_builder" / "js",
54+
"apps/input_builder/css": pathlib.Path(__file__).parent / "apps" / "input_builder" / "css",
5555
}
5656

5757
@staticmethod

AFL/double_agent/AutoSASWebAppMixin.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ class AutoSASWebAppMixin:
3131
"""Web-app endpoints and helper logic for AutoSAS model building and fitting."""
3232

3333
static_dirs = {
34-
"autosas_webapp_js": pathlib.Path(__file__).parent / "driver_templates" / "autosas_webapp" / "js",
35-
"autosas_webapp_css": pathlib.Path(__file__).parent / "driver_templates" / "autosas_webapp" / "css",
36-
"autosas_webapp_vendor": pathlib.Path(__file__).parent / "driver_templates" / "autosas_webapp" / "vendor",
34+
"apps/autosas_webapp/js": pathlib.Path(__file__).parent / "apps" / "autosas_webapp" / "js",
35+
"apps/autosas_webapp/css": pathlib.Path(__file__).parent / "apps" / "autosas_webapp" / "css",
36+
"apps/common/plotly": pathlib.Path(__file__).parent / "apps" / "common" / "plotly",
3737
}
3838

3939
_DEFAULT_Q_MIN = 1e-3
@@ -283,7 +283,7 @@ def _parse_entry_ids(entry_ids: Any) -> list[str]:
283283
def autosas_webapp(self, **kwargs):
284284
"""Serve AutoSAS web application HTML."""
285285
template_path = (
286-
files("AFL.double_agent.driver_templates")
286+
files("AFL.double_agent.apps")
287287
.joinpath("autosas_webapp")
288288
.joinpath("autosas_webapp.html")
289289
)

AFL/double_agent/driver_templates/autosas_webapp/autosas_webapp.html renamed to AFL/double_agent/apps/autosas_webapp/autosas_webapp.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<meta charset="UTF-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
66
<title>AutoSAS Web App</title>
7-
<link rel="stylesheet" href="static/autosas_webapp_css/style.css" />
7+
<link rel="stylesheet" href="/static/apps/autosas_webapp/css/style.css" />
88
</head>
99
<body>
1010
<div id="app">
@@ -127,7 +127,7 @@ <h2>Fit Method JSON</h2>
127127
</div>
128128
</div>
129129

130-
<script src="static/autosas_webapp_vendor/plotly.min.js"></script>
131-
<script type="module" src="static/autosas_webapp_js/main.js"></script>
130+
<script src="/static/apps/common/plotly/plotly.min.js"></script>
131+
<script type="module" src="/static/apps/autosas_webapp/js/main.js"></script>
132132
</body>
133133
</html>

AFL/double_agent/driver_templates/autosas_webapp/css/style.css renamed to AFL/double_agent/apps/autosas_webapp/css/style.css

File renamed without changes.
File renamed without changes.

AFL/double_agent/driver_templates/autosas_webapp/vendor/plotly.min.js renamed to AFL/double_agent/apps/common/plotly/plotly.min.js

File renamed without changes.

AFL/double_agent/apps/input_builder/input_builder.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta charset='UTF-8'>
55
<title>Input Builder</title>
6-
<link rel='stylesheet' href='static/input_builder_css/style.css'>
6+
<link rel='stylesheet' href='/static/apps/input_builder/css/style.css'>
77
</head>
88
<body>
99
<div id='app-container'>
@@ -130,6 +130,6 @@ <h3>Return Value</h3>
130130
<div class='loading-text'>Processing...</div>
131131
</div>
132132

133-
<script type="module" src="static/input_builder_js/main.js"></script>
133+
<script type="module" src="/static/apps/input_builder/js/main.js"></script>
134134
</body>
135135
</html>

AFL/double_agent/apps/pipeline_builder/pipeline_builder.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
<head>
44
<meta charset='UTF-8'>
55
<title>Pipeline Builder</title>
6-
<script src='static/js/d3.v7.min.js'></script>
7-
<script src='static/js/dagre.min.js'></script>
8-
<link rel='stylesheet' href='static/css/style.css'>
6+
<script src='/static/apps/pipeline_builder/js/d3.v7.min.js'></script>
7+
<script src='/static/apps/pipeline_builder/js/dagre.min.js'></script>
8+
<link rel='stylesheet' href='/static/apps/pipeline_builder/css/style.css'>
99
</head>
1010
<body>
1111
<div id='sidebar'>
1212
<div id='logo-container' style='text-align: center; margin-bottom: 20px;'>
13-
<img src='static/img/logo_text_large_light.svg' alt='Logo' style='max-width: 100%; height: auto; max-height: 60px;'>
13+
<img src='/static/apps/pipeline_builder/img/logo_text_large_light.svg' alt='Logo' style='max-width: 100%; height: auto; max-height: 60px;'>
1414
</div>
1515
<h3>Pipeline Operations</h3>
1616
<div id='search-container'>
@@ -191,6 +191,6 @@ <h3 id='list-editor-title' style='margin-top: 0;'>Edit List Parameter</h3>
191191
</div>
192192
</div>
193193
</div>
194-
<script type="module" src="static/js/main.js"></script>
194+
<script type="module" src="/static/apps/pipeline_builder/js/main.js"></script>
195195
</body>
196196
</html>

tests/test_agentdriver_pipeline_ops.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,17 @@ def fake_collect(module_files, strict=False):
9797
def test_double_agent_driver_static_dirs_point_to_apps():
9898
static_dirs = agent_driver.DoubleAgentDriver.static_dirs
9999

100-
assert "apps/pipeline_builder/js" in str(static_dirs["js"])
101-
assert "apps/pipeline_builder/img" in str(static_dirs["img"])
102-
assert "apps/pipeline_builder/css" in str(static_dirs["css"])
103-
assert "apps/input_builder/js" in str(static_dirs["input_builder_js"])
104-
assert "apps/input_builder/css" in str(static_dirs["input_builder_css"])
100+
assert "apps/pipeline_builder/js" in static_dirs
101+
assert "apps/pipeline_builder/img" in static_dirs
102+
assert "apps/pipeline_builder/css" in static_dirs
103+
assert "apps/input_builder/js" in static_dirs
104+
assert "apps/input_builder/css" in static_dirs
105+
106+
assert "apps/pipeline_builder/js" in str(static_dirs["apps/pipeline_builder/js"])
107+
assert "apps/pipeline_builder/img" in str(static_dirs["apps/pipeline_builder/img"])
108+
assert "apps/pipeline_builder/css" in str(static_dirs["apps/pipeline_builder/css"])
109+
assert "apps/input_builder/js" in str(static_dirs["apps/input_builder/js"])
110+
assert "apps/input_builder/css" in str(static_dirs["apps/input_builder/css"])
105111

106112

107113
def test_web_app_mixin_renders_builder_html():

0 commit comments

Comments
 (0)