Skip to content

Commit

Permalink
feat: flag to setup bench with developer mode enabled
Browse files Browse the repository at this point in the history
Dev dependencies are not installed if developer_mode is not enabled.
When creating a new bench it's not possible to modify this config
upfront, so offer a flag to do it instead.

Note:
- Disabled by default.
- Very few people need this, those who write and run tests locally primarily.
- You mostly should not do this in CI, do `bench setup requirements --dev` explicitly instead.
  • Loading branch information
ankush committed Nov 2, 2023
1 parent 53a8fed commit f29e25a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
4 changes: 2 additions & 2 deletions bench/bench.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,12 +371,12 @@ def env(self, python="python3"):
)

@step(title="Setting Up Bench Config", success="Bench Config Set Up")
def config(self, redis=True, procfile=True):
def config(self, redis=True, procfile=True, additional_config=None):
"""Setup config folder
- create pids folder
- generate sites/common_site_config.json
"""
setup_config(self.bench.name)
setup_config(self.bench.name, additional_config=additional_config)

if redis:
from bench.config.redis import generate_config
Expand Down
8 changes: 8 additions & 0 deletions bench/commands/make.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@
@click.option("--skip-assets", is_flag=True, default=False, help="Do not build assets")
@click.option("--install-app", help="Install particular app after initialization")
@click.option("--verbose", is_flag=True, help="Verbose output during install")
@click.option(
"--dev",
is_flag=True,
default=False,
help="Enable developer mode and install development dependencies.",
)
def init(
path,
apps_path,
Expand All @@ -54,6 +60,7 @@ def init(
skip_assets=False,
python="python3",
install_app=None,
dev=False,
):
import os

Expand All @@ -79,6 +86,7 @@ def init(
skip_assets=skip_assets,
python=python,
verbose=verbose,
dev=dev,
)
log(f"Bench {path} initialized", level=1)
except SystemExit:
Expand Down
4 changes: 3 additions & 1 deletion bench/config/common_site_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@
DEFAULT_MAX_REQUESTS = 5000


def setup_config(bench_path):
def setup_config(bench_path, additional_config=None):
make_pid_folder(bench_path)
bench_config = get_config(bench_path)
bench_config.update(default_config)
bench_config.update(get_gunicorn_workers())
update_config_for_frappe(bench_config, bench_path)
if additional_config:
bench_config.update(additional_config)

put_config(bench_config, bench_path)

Expand Down
10 changes: 9 additions & 1 deletion bench/utils/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def init(
skip_assets=False,
python="python3",
install_app=None,
dev=False,
):
"""Initialize a new bench directory
Expand Down Expand Up @@ -63,7 +64,14 @@ def init(
bench.setup.dirs()
bench.setup.logging()
bench.setup.env(python=python)
bench.setup.config(redis=not skip_redis_config_generation, procfile=not no_procfile)
config = {}
if dev:
config["developer_mode"] = 1
bench.setup.config(
redis=not skip_redis_config_generation,
procfile=not no_procfile,
additional_config=config,
)
bench.setup.patches()

# local apps
Expand Down

0 comments on commit f29e25a

Please sign in to comment.