Skip to content

Commit

Permalink
ci(docker): Add custom www module + app.html
Browse files Browse the repository at this point in the history
  • Loading branch information
jourdain committed Jun 3, 2022
1 parent f748dd6 commit 95d1ef9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
33 changes: 14 additions & 19 deletions docker/scripts/generate_www.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,27 @@
import subprocess


def run(apps_path, out_path, *modules):
# generate www content
cmd = ["python", "-m", "trame.tools.www", "--output", f"{out_path}", *modules]
def run(apps_path, out_path):
# Generate www content
cmd = ["python", "-m", "trame.tools.www", "--output", out_path]
subprocess.run(cmd)

# FIXME need to generate index.html => {app_name}.html
# Generate app files index.html => {app_name}.html
with open(apps_path, "r") as rf:
apps_dict = json.load(rf) # noqa

# for app_name, config in apps_dict.items():
# name = config['app']
# => cp out_path/index.html out_path/{name}.html
# => replace data-app-name="trame" => data-app-name="{name}"
for app_name, config in apps_dict.items():
name = config['app']
web_modules = config.get("www_modules")
if web_modules is not None:
cmd = ["python", "-m", "trame.tools.www", "--output", out_path, *web_modules]
subprocess.run(cmd)
print(" => create app: ", app_name, name)
cmd = ["python", "-m", "trame.tools.app", "--input", out_path, "--name", name]
subprocess.run(cmd)


if __name__ == "__main__":
apps_path = "/opt/trame/apps.json"
out_path = "/deploy/server/www"
modules = [
"client",
"trame",
"vtk",
"vuetify",
"plotly",
"router",
"vega",
"markdown",
]
run(apps_path, out_path, *modules)
run(apps_path, out_path)
5 changes: 5 additions & 0 deletions trame/tools/www.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,15 @@ def enable_modules(self, *names):
module = importlib.import_module(f"trame.modules.{module_name}")
except ModuleNotFoundError:
try:
print("module_name:", module_name)
module = importlib.import_module(module_name)
except ModuleNotFoundError:
print(f" - Error: Skipping module {module_name}")

if module is None:
print(f"Skipping module: {module_name}")
continue

if "serve" in module.__dict__:
self.serve.update(module.serve)

Expand Down

0 comments on commit 95d1ef9

Please sign in to comment.