dev-mode compile: purge .web dir at last min to reduce downtime window (#1430)
This commit is contained in:
parent
d0fc965c7f
commit
7a09554cfa
3
.gitignore
vendored
3
.gitignore
vendored
@ -4,4 +4,5 @@ dist/*
|
|||||||
examples/
|
examples/
|
||||||
.idea
|
.idea
|
||||||
.vscode
|
.vscode
|
||||||
.coverage
|
.coverage
|
||||||
|
venv
|
@ -3,6 +3,7 @@ repos:
|
|||||||
rev: v0.0.244
|
rev: v0.0.244
|
||||||
hooks:
|
hooks:
|
||||||
- id: ruff
|
- id: ruff
|
||||||
|
args: [--fix, --exit-non-zero-on-fix]
|
||||||
|
|
||||||
- repo: https://github.com/RobertCraigie/pyright-python
|
- repo: https://github.com/RobertCraigie/pyright-python
|
||||||
rev: v1.1.313
|
rev: v1.1.313
|
||||||
|
@ -467,23 +467,23 @@ class App(Base):
|
|||||||
)
|
)
|
||||||
task = progress.add_task("Compiling: ", total=len(self.pages))
|
task = progress.add_task("Compiling: ", total=len(self.pages))
|
||||||
|
|
||||||
|
# TODO: include all work done in progress indicator, not just self.pages
|
||||||
for render, kwargs in DECORATED_ROUTES:
|
for render, kwargs in DECORATED_ROUTES:
|
||||||
self.add_page(render, **kwargs)
|
self.add_page(render, **kwargs)
|
||||||
|
|
||||||
# Get the env mode.
|
# Get the env mode.
|
||||||
config = get_config()
|
config = get_config()
|
||||||
|
|
||||||
# Empty the .web pages directory
|
|
||||||
compiler.purge_web_pages_dir()
|
|
||||||
|
|
||||||
# Store the compile results.
|
# Store the compile results.
|
||||||
compile_results = []
|
compile_results = []
|
||||||
|
|
||||||
# Compile the pages in parallel.
|
# Compile the pages in parallel.
|
||||||
custom_components = set()
|
custom_components = set()
|
||||||
|
# TODO Anecdotally, processes=2 works 10% faster (cpu_count=12)
|
||||||
thread_pool = ThreadPool()
|
thread_pool = ThreadPool()
|
||||||
with progress:
|
with progress:
|
||||||
for route, component in self.pages.items():
|
for route, component in self.pages.items():
|
||||||
|
# TODO: this progress does not reflect actual threaded task completion
|
||||||
progress.advance(task)
|
progress.advance(task)
|
||||||
component.add_style(self.style)
|
component.add_style(self.style)
|
||||||
compile_results.append(
|
compile_results.append(
|
||||||
@ -505,6 +505,8 @@ class App(Base):
|
|||||||
# Get the results.
|
# Get the results.
|
||||||
compile_results = [result.get() for result in compile_results]
|
compile_results = [result.get() for result in compile_results]
|
||||||
|
|
||||||
|
# TODO the compile tasks below may also benefit from parallelization too
|
||||||
|
|
||||||
# Compile the custom components.
|
# Compile the custom components.
|
||||||
compile_results.append(compiler.compile_components(custom_components))
|
compile_results.append(compiler.compile_components(custom_components))
|
||||||
|
|
||||||
@ -521,10 +523,12 @@ class App(Base):
|
|||||||
)
|
)
|
||||||
compile_results.append(compiler.compile_tailwind(config.tailwind))
|
compile_results.append(compiler.compile_tailwind(config.tailwind))
|
||||||
|
|
||||||
|
# Empty the .web pages directory
|
||||||
|
compiler.purge_web_pages_dir()
|
||||||
|
|
||||||
# Write the pages at the end to trigger the NextJS hot reload only once.
|
# Write the pages at the end to trigger the NextJS hot reload only once.
|
||||||
thread_pool = ThreadPool()
|
thread_pool = ThreadPool()
|
||||||
for output_path, code in compile_results:
|
for output_path, code in compile_results:
|
||||||
compiler_utils.write_page(output_path, code)
|
|
||||||
thread_pool.apply_async(compiler_utils.write_page, args=(output_path, code))
|
thread_pool.apply_async(compiler_utils.write_page, args=(output_path, code))
|
||||||
thread_pool.close()
|
thread_pool.close()
|
||||||
thread_pool.join()
|
thread_pool.join()
|
||||||
|
@ -9,7 +9,7 @@ ImportDict = Dict[str, Set[ImportVar]]
|
|||||||
|
|
||||||
|
|
||||||
def merge_imports(*imports) -> ImportDict:
|
def merge_imports(*imports) -> ImportDict:
|
||||||
"""Merge two import dicts together.
|
"""Merge multiple import dicts together.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
*imports: The list of import dicts to merge.
|
*imports: The list of import dicts to merge.
|
||||||
|
Loading…
Reference in New Issue
Block a user