Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
forked fromfrappe/bench

Commit10bb5a4

Browse files
committed
fix: update install_app with using_cached flag
1 parent7bcea60 commit10bb5a4

File tree

2 files changed

+29
-20
lines changed

2 files changed

+29
-20
lines changed

‎bench/app.py

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,17 @@
2121
# imports - module imports
2222
importbench
2323
frombench.exceptionsimportNotInBenchDirectoryError
24-
frombench.utilsimport (UNSET_ARG,fetch_details_from_tag,
25-
get_available_folder_name,get_bench_cache_path,
26-
is_bench_directory,is_git_url,
27-
is_valid_frappe_branch,log,run_frappe_cmd)
24+
frombench.utilsimport (
25+
UNSET_ARG,
26+
fetch_details_from_tag,
27+
get_available_folder_name,
28+
get_bench_cache_path,
29+
is_bench_directory,
30+
is_git_url,
31+
is_valid_frappe_branch,
32+
log,
33+
run_frappe_cmd,
34+
)
2835
frombench.utils.benchimportbuild_assets,install_python_dev_dependencies
2936
frombench.utils.renderimportstep
3037

@@ -225,6 +232,7 @@ def install(
225232
resolved=False,
226233
restart_bench=True,
227234
ignore_resolution=False,
235+
using_cached=False
228236
):
229237
importbench.cli
230238
frombench.utils.appimportget_app_name
@@ -245,6 +253,7 @@ def install(
245253
skip_assets=skip_assets,
246254
restart_bench=restart_bench,
247255
resolution=self.local_resolution,
256+
using_cached=using_cached,
248257
)
249258

250259
@step(title="Cloning and installing {repo}",success="App {repo} Installed")
@@ -332,22 +341,12 @@ def get_cached(self) -> bool:
332341
ifapp_path.is_dir():
333342
shutil.rmtree(app_path)
334343

335-
click.secho(f"{self.app_name} being installed from cache",fg="yellow")
344+
click.secho(f"Getting{self.app_name} from cache",fg="yellow")
336345
withtarfile.open(cache_path,mode)astar:
337346
tar.extractall(app_path.parent)
338347

339348
returnTrue
340349

341-
definstall_cached(self)->None:
342-
"""
343-
TODO:
344-
- check if cache is being set
345-
- check if app is being set from cache
346-
- complete install_cached
347-
- check if app is being installed correctly from cache
348-
"""
349-
raiseNotImplementedError("TODO: complete this function")
350-
351350
defset_cache(self,compress_artifacts=False)->bool:
352351
ifnotself.commit_hash:
353352
returnFalse
@@ -359,6 +358,11 @@ def set_cache(self, compress_artifacts=False) -> bool:
359358
cwd=os.getcwd()
360359
cache_path=self.get_app_cache_path(compress_artifacts)
361360
mode="w:gz"ifcompress_artifactselse"w"
361+
362+
message="Caching get-app artifacts"
363+
ifcompress_artifacts:
364+
message+=" (compressed)"
365+
click.secho(message)
362366

363367
os.chdir(app_path.parent)
364368
withtarfile.open(cache_path,mode)astar:
@@ -456,7 +460,7 @@ def get_app(
456460
bench_setup=False
457461
restart_bench=notinit_bench
458462
frappe_path,frappe_branch=None,None
459-
463+
460464
ifresolve_deps:
461465
resolution=make_resolution_plan(app,bench)
462466
click.secho("Following apps will be installed",fg="bright_blue")
@@ -508,7 +512,7 @@ def get_app(
508512
return
509513

510514
ifapp.get_cached():
511-
app.install_cached()
515+
app.install(verbose=verbose,skip_assets=skip_assets,restart_bench=restart_bench,using_cached=True)
512516
return
513517

514518
dir_already_exists,cloned_path=check_existing_dir(bench_path,repo_name)
@@ -645,6 +649,7 @@ def install_app(
645649
restart_bench=True,
646650
skip_assets=False,
647651
resolution=UNSET_ARG,
652+
using_cached=False,
648653
):
649654
importbench.cliasbench_cli
650655
frombench.benchimportBench
@@ -672,14 +677,14 @@ def install_app(
672677
ifconf.get("developer_mode"):
673678
install_python_dev_dependencies(apps=app,bench_path=bench_path,verbose=verbose)
674679

675-
ifos.path.exists(os.path.join(app_path,"package.json")):
680+
ifnotusing_cachedandos.path.exists(os.path.join(app_path,"package.json")):
676681
yarn_install="yarn install --verbose"ifverboseelse"yarn install"
677682
bench.run(yarn_install,cwd=app_path)
678683

679684
bench.apps.sync(app_name=app,required=resolution,branch=tag,app_dir=app_path)
680685

681686
ifnotskip_assets:
682-
build_assets(bench_path=bench_path,app=app)
687+
build_assets(bench_path=bench_path,app=app,using_cached=using_cached)
683688

684689
ifrestart_bench:
685690
# Avoiding exceptions here as production might not be set-up

‎bench/utils/bench.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,10 +349,14 @@ def restart_process_manager(bench_path=".", web_workers=False):
349349
exec_cmd(f"overmind restart{worker}",cwd=bench_path)
350350

351351

352-
defbuild_assets(bench_path=".",app=None):
352+
defbuild_assets(bench_path=".",app=None,using_cached=False):
353353
command="bench build"
354354
ifapp:
355355
command+=f" --app{app}"
356+
357+
ifusing_cached:
358+
command+=" --using-cached"
359+
356360
exec_cmd(command,cwd=bench_path,env={"BENCH_DEVELOPER":"1"})
357361

358362

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp