Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Setup Requirements for specific apps #1265

Merged
merged 5 commits into from
Feb 18, 2022

Conversation

DaizyModi
Copy link
Contributor

@DaizyModi DaizyModi commented Feb 12, 2022

Added apps argument to run setup requirements for a specific app(s)

Usage

Specify multiple space-separated apps. Similar to how bench switch-to-branch works.
CAVEAT: apps must be specified in the end.

bench setup requirements [OPTIONS] [APPS]

Other Changes

  • Don't restart bench or build assets while setting up dependencies (original behavior). Restart and build should be separately executed. Restart fails for developer setups anyway:
ERROR: Command 'supervisorctl status' returned non-zero exit status 127.
Traceback (most recent call last):
  File "/usr/local/bin/bench", line 33, in <module>
    sys.exit(load_entry_point('frappe-bench', 'console_scripts', 'bench')())
  File "/home/snv/Work/.bench/bench/cli.py", line 121, in cli
    raise e
  File "/home/snv/Work/.bench/bench/cli.py", line 111, in cli
    bench_command()
  File "/home/snv/.local/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/snv/.local/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/snv/.local/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/snv/.local/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/snv/.local/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/snv/.local/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/snv/Work/.bench/bench/commands/setup.py", line 150, in setup_requirements
    bench.setup.requirements(apps=apps)
  File "/home/snv/Work/.bench/bench/utils/render.py", line 95, in wrapper_fn
    return fn(*args, **kwargs)
  File "/home/snv/Work/.bench/bench/bench.py", line 342, in requirements
    App(app, bench=self.bench, to_clone=False).install()
  File "/home/snv/Work/.bench/bench/utils/render.py", line 110, in wrapper_fn
    return fn(*args, **kwargs)
  File "/home/snv/Work/.bench/bench/app.py", line 192, in install
    install_app(
  File "/home/snv/Work/.bench/bench/app.py", line 426, in install_app
    bench.reload()
  File "/home/snv/Work/.bench/bench/utils/render.py", line 110, in wrapper_fn
    return fn(*args, **kwargs)
  File "/home/snv/Work/.bench/bench/bench.py", line 142, in reload
    restart_supervisor_processes(bench_path=self.name, web_workers=web)
  File "/home/snv/Work/.bench/bench/utils/bench.py", line 257, in restart_supervisor_processes
    supervisor_status = get_cmd_output("supervisorctl status", cwd=bench_path)
  File "/home/snv/Work/.bench/bench/utils/__init__.py", line 185, in get_cmd_output
    output = subprocess.check_output(
  File "/usr/lib/python3.8/subprocess.py", line 415, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/usr/lib/python3.8/subprocess.py", line 516, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command 'supervisorctl status' returned non-zero exit status 127.

Screenshots

Help

image

One App

image

Multiple Apps

image

No Apps (truncated)

image

Multiple apps, node

image

@DaizyModi DaizyModi changed the title feat: --app flag for Setup Requirements feat: --app flag for Setup Requirements Feb 12, 2022
bench/commands/setup.py Outdated Show resolved Hide resolved
Co-authored-by: gavin <gavin18d@gmail.com>
@sagarvora sagarvora changed the title feat: --app flag for Setup Requirements feat: Setup Requirements for specific apps Feb 18, 2022
@sonarcloud
Copy link

sonarcloud bot commented Feb 18, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

No Coverage information No Coverage information
0.1% 0.1% Duplication

@gavindsouza
Copy link
Collaborator

Ignoring broken PY37 test for install-app:

Installing frappe_docs...
An error occurred while installing frappe_docs:
Module import failed for Company History (frappe.core.doctype.company_history.company_history Error: No module named 'frappe.core.doctype.company_history')

Perhaps the test should handle error and success states without actually relying on external apps etc 🤔

@gavindsouza gavindsouza merged commit 28e6816 into frappe:develop Feb 18, 2022
@sagarvora sagarvora deleted the setup-requirements-app branch February 18, 2022 16:18
github-actions bot pushed a commit that referenced this pull request Mar 22, 2022
# [5.8.0](v5.7.6...v5.8.0) (2022-03-22)

### Bug Fixes

* Allow sudo restart for supervisor (backwards compatibility) ([fc7c047](fc7c047))
* clearer docstrings ([3c59446](3c59446))
* file-uri while app initialisation ([2fed369](2fed369))
* **find:** Handle OS' PermissionError ([ea94752](ea94752))
* mkdir -p to ignore `OSError`s ([d38b63a](d38b63a))
* Respect bench config during restart ([25f49c2](25f49c2))
* **restart:** Setup restarts vars with fallback ([af14baf](af14baf))
* Show better user messages when failed to update supervisord ([d89f19e](d89f19e))
* Try setting supervisord conditionally ([7a4ade9](7a4ade9))

### Features

* Setup Requirements for specific apps ([#1265](#1265)) ([28e6816](28e6816))
github-actions bot pushed a commit to abcgitalbadia/bench that referenced this pull request Mar 27, 2023
# [5.7.0](v5.6.0...v5.7.0) (2023-03-27)

### Bug Fixes

* (re)Install every Frappe app even if not installed to env ([ffae670](ffae670))
* add code removed via erroneous commit ([b28cfab](b28cfab))
* Add support for options on bench main group ([8a0b784](8a0b784))
* added code removed via erroneous commit ([5b64175](5b64175))
* added code removed via erroneous commit ([7e28a3d](7e28a3d))
* allow bench init with git tags ([c943b30](c943b30))
* Allow git url with custom username ([frappe#1200](https://github.com/abcgitalbadia/bench/issues/1200)) ([6411812](6411812))
* Allow sudo restart for supervisor (backwards compatibility) ([fc7c047](fc7c047))
* Archived app naming, apps.txt sync ([79980c3](79980c3))
* bad URL in raw.githubusercontent.com ([frappe#1363](https://github.com/abcgitalbadia/bench/issues/1363)) ([589f7a4](589f7a4))
* Bump Nodejs v12 => v14 ([cd0fccf](cd0fccf))
* case-insensitive matching ([3f57616](3f57616))
* check current branch ([2287f3f](2287f3f))
* Check for unauthorized status code in response ([e9b0112](e9b0112))
* check for valid branch in resolve ([79765e6](79765e6))
* Check if app is installed in env via initialize_apps ([a192240](a192240))
* Check if archived_sites directory exists before running ([b11f5b0](b11f5b0))
* checking status code to determine rate limit ([dbb1904](dbb1904))
* Cleanup import hell ([e2fd9de](e2fd9de))
* Cleanup import hell (contd) ([d2fba5f](d2fba5f))
* Clear Bench instance cache on every chdir ([ec369a1](ec369a1))
* clearer docstrings ([3c59446](3c59446))
* Command picking & execution ([2fa25d8](2fa25d8))
* **config:** Fix fail2ban filter ([frappe#1308](https://github.com/abcgitalbadia/bench/issues/1308)) ([94a25d3](94a25d3))
* correct patches.txt ([a28a0d0](a28a0d0))
* correct python path for migrate_env ([61e0f4a](61e0f4a))
* Delete folder if --no-backup is passed ([f7f7459](f7f7459))
* Don't fetch meta for rm app ([17edb47](17edb47))
* Don't handle `BaseException`s ([ad000f1](ad000f1))
* Don't recompute URLs when name passed in App ([0898e2d](0898e2d))
* dont attempt migrating to active virtualenv ([0e59159](0e59159))
* dont use glob pattern for `python` exec ([dc047a5](dc047a5))
* Drop support for Frappe v4-5-6 ;) ([616dff8](616dff8))
* **DX:** make warnings go to stderr ([b6b9481](b6b9481))
* empty states json condition ([67df07b](67df07b))
* Fetch env python if exists before returning fallback ([e5fa4df](e5fa4df))
* file-uri while app initialisation ([2fed369](2fed369))
* FileNotFound bug ([frappe#1383](https://github.com/abcgitalbadia/bench/issues/1383)) ([965e178](965e178))
* **find:** Handle OS' PermissionError ([ea94752](ea94752))
* fixed app states and checking/updating frappe version on install ([30a4ec3](30a4ec3))
* fixed app states and checking/updating frappe version on install ([42f4d74](42f4d74))
* fixed args to sync-states ([c667be9](c667be9))
* fixed frappe branch check ([6c15327](6c15327))
* fixed init in get-app and frappe versions ([88c2367](88c2367))
* fixed init in get-app and frappe versions ([e3bd34c](e3bd34c))
* Fixed order of install ([281d96a](281d96a))
* fixed org, branch for apps mounted on disk ([frappe#1293](https://github.com/abcgitalbadia/bench/issues/1293)) ([c8ef822](c8ef822))
* fixed states sync ([7f37488](7f37488))
* fixed update_app_states call ([frappe#1326](https://github.com/abcgitalbadia/bench/issues/1326)) ([45267fc](45267fc))
* frappe app can exist without public folder ([13ed9be](13ed9be))
* get-app on existing apps ([e03f597](e03f597))
* Handle collisions while moving apps ([3709682](3709682))
* Handle supervisor escalation better ([frappe#1438](https://github.com/abcgitalbadia/bench/issues/1438)) ([c690e8e](c690e8e))
* Handle tag fetching failures of disk mounted App inits ([117d456](117d456))
* ignore supervisor restart failures where possible ([frappe#1400](https://github.com/abcgitalbadia/bench/issues/1400)) ([7a63f4f](7a63f4f))
* Import bench.cli ([27128c7](27128c7))
* import path for util ([ee6a967](ee6a967))
* Initialize bench in get-app with --init-bench ([a2ccc30](a2ccc30))
* install one app at a time, frappe first ([4f0193c](4f0193c))
* install wheel in venv ([4996afb](4996afb))
* logging when in init-bench ([a26f3ce](a26f3ce))
* logging when in init-bench ([de315f2](de315f2))
* merge conflicts ([61a864d](61a864d))
* merge conflicts ([ca45305](ca45305))
* migrate_env silent failures ([7f1c5ad](7f1c5ad))
* minor fixes ([94105c0](94105c0))
* minor fixes ([e629ca6](e629ca6))
* Misc fixes ([frappe#1294](https://github.com/abcgitalbadia/bench/issues/1294)) ([eb71573](eb71573))
* missing installed branch ([af3c871](af3c871))
* mkdir -p to ignore `OSError`s ([d38b63a](d38b63a))
* Move logging to lower level App.get API ([4ba5422](4ba5422))
* **nginx:** Allow specifying log_format setting ([bbf0169](bbf0169))
* **nginx:** set `proxy_http_version` to `1.1` ([7da62f9](7da62f9))
* no-git support for dependency resolver ([frappe#1368](https://github.com/abcgitalbadia/bench/issues/1368)) ([fcbc2ea](fcbc2ea))
* parsing error ([frappe#1364](https://github.com/abcgitalbadia/bench/issues/1364)) ([4bc3a08](4bc3a08))
* Pass `skip_assets` while resolving dependant apps ([8275d67](8275d67))
* Pass abs path from get_env_cmd ([10473b6](10473b6))
* Pass cwd for cmd subprocess execution ([01b7759](01b7759))
* Patch to move archived_sites to archived/sites ([877e812](877e812))
* **patch:** Rename parent dir instead of moving individual dirs ([0bd0717](0bd0717))
* PosixPath object has no attribute 'rstrip' ([aaf4856](aaf4856))
* print help when no args passed ([228aeaf](228aeaf))
* print required by in output ([5bb3b52](5bb3b52))
* process SSH git URLs ([c8494cf](c8494cf))
* process SSH git URLs ([660287a](660287a))
* raise (by default) when exec_cmd fails ([3995b92](3995b92))
* Raise and handle Exception class ([c4b8391](c4b8391))
* Remove backup command ([frappe#1345](https://github.com/abcgitalbadia/bench/issues/1345)) ([0cd5fca](0cd5fca))
* Remove broken import path ([2c5c28b](2c5c28b))
* Remove frappe cmd caching in .bench.cmd ([f773529](f773529))
* remove unwanted `patches.txt` ([85500b7](85500b7))
* Remove virtualenv dependency ([e0f6b17](e0f6b17))
* **remove-app:** Use App.name instead of App.repo for consistent App name ([a3b859b](a3b859b))
* removed erroneous file push ([f2fe569](f2fe569))
* removed erroneous file push ([b7e46aa](b7e46aa))
* removed unnecessary requests while removing apps ([49900ce](49900ce))
* rename key ([75f8462](75f8462))
* replace certbot-auto with certbot ([frappe#1303](https://github.com/abcgitalbadia/bench/issues/1303)) ([a889325](a889325))
* replace shutil.move with Path.rename ([a648590](a648590))
* Respect bench config during restart ([25f49c2](25f49c2))
* restart proc manager if set in config ([frappe#1391](https://github.com/abcgitalbadia/bench/issues/1391)) ([c59d1ed](c59d1ed))
* **restart:** Setup restarts vars with fallback ([af14baf](af14baf))
* reverted changes made by erroneous commit ([b8aa008](b8aa008))
* reverted erroneous commits ([ff98aaf](ff98aaf))
* Set correct remote_server for cloning ([9802fea](9802fea))
* Set proper branch to clone ([217f27f](217f27f))
* Set remote_server attr "better" ([e3b9c2a](e3b9c2a))
* Set verbosity if --verbose is passed anywhere period ([2caf7e7](2caf7e7))
* setup all apps is empty list is supplied ([7ab469a](7ab469a))
* Setup chdir patch earlier ([db165d1](db165d1))
* Show bench init job via bench get-app (conditional) ([225fce5](225fce5))
* Show better user messages when failed to update supervisord ([d89f19e](d89f19e))
* Show pip's help menu when --help is passed in pip command ([6d10d75](6d10d75))
* Show traceback if error occurs during init, get outside bench dir ([806d543](806d543))
* Show traceback in dev mode and set exit code on errors ([e074a1d](e074a1d))
* Show traceback on bench init failure ([30e3e72](30e3e72))
* Show warning while using experimental features ([b7994e2](b7994e2))
* support for local and remote apps when looking for dependencies ([2f17da1](2f17da1))
* support single required app ([c8205e4](c8205e4))
* sync apps file in init, imports and no warn in CI ([71d178d](71d178d))
* Trailing slash not setting app name properly ([357fcc0](357fcc0))
* trigger release ([f374e80](f374e80))
* Try setting supervisord conditionally ([7a4ade9](7a4ade9))
* update check condition ([3e749ba](3e749ba))
* Update Click requirement ([3b0bcb7](3b0bcb7))
* updated apps.sync to support new app_name parameter ([7980709](7980709))
* Use == to define had pinned requirement ([beac865](beac865))
* use frappe13 in py 3.7 ([5b1b84b](5b1b84b))
* Use hardcoded python3 env cmd for Bench.python ([c9c6bf4](c9c6bf4))
* use os.remove instead of shutil.rmtree for symlinks ([frappe#1372](https://github.com/abcgitalbadia/bench/issues/1372)) ([9fd15f6](9fd15f6))
* Use python* to match any pattern in env ([24b9af6](24b9af6))
* use ref param instead of branch for get_required_deps (GitHub contents API) ([frappe#1362](https://github.com/abcgitalbadia/bench/issues/1362)) ([9131ba0](9131ba0))
* use specified python for venv ([df84c27](df84c27))
* Use subscript instead of method for regex ([e126ff2](e126ff2))
* Use test frappe app - frappe_docs instead of wiki or chat ([c636c7c](c636c7c))
* Use venv module instead of virtualenv ([f60c2d0](f60c2d0))
* User messages on get-app actions ([d33d987](d33d987))
* using local clones if path is passed in get-app ([5f37135](5f37135))
* **utils:** Strip * from cmd via get_env_cmd ([6ae1997](6ae1997))
* version check backward compatibility ([frappe#1409](https://github.com/abcgitalbadia/bench/issues/1409)) ([23eede5](23eede5))

### Features

* add `live_reload` to default_config ([9f74ec0](9f74ec0))
* add `max_requests` to gunicorn args ([b57838f](b57838f))
* Add alias for remove-app: rm, remove ([6890d98](6890d98))
* add commit hash and branch in `states.json` ([9004e1d](9004e1d))
* Add custom workers in Procfile ([frappe#1201](https://github.com/abcgitalbadia/bench/issues/1201)) ([593b80e](593b80e))
* add GHA tests ([e76c7dc](e76c7dc))
* add no-git option to new-app command ([2a25a6d](2a25a6d))
* Add pre-commit checks ([b1b8d70](b1b8d70))
* add required and order of install ([9ac091b](9ac091b))
* Added app states ([fdab757](fdab757))
* Added app states ([549e8e2](549e8e2))
* Added app_name attribute to App class ([35504f8](35504f8))
* Added bench command for resolve and install ([cdaeea1](cdaeea1))
* Added bench command for resolve and install ([7a311a2](7a311a2))
* Added exception for invalid version ([ddd498e](ddd498e))
* added option to provide custom queues ([e12f53d](e12f53d))
* Added support for backward compatibility in states ([a1a35ee](a1a35ee))
* added support for fetching dependencies from hooks.py ([58319a2](58319a2))
* added support for fetching dependencies from hooks.py ([7f678a3](7f678a3))
* Added support for mounted app in get_dependencies ([0b862c0](0b862c0))
* Aliased Commands ([b75d352](b75d352))
* Allow skipping supervisord config check in setup supervisor ([a3af905](a3af905))
* alternative request to validate branch ([8dd92c3](8dd92c3))
* App Meta Base Class ([ce00798](ce00798))
* bench drop {bench_path} ([906ad5a](906ad5a))
* **config:** Add IPv6 listener to nginx site configuration ([frappe#1312](https://github.com/abcgitalbadia/bench/issues/1312)) ([593c7b7](593c7b7))
* Dynamic Output rendering ([f117959](f117959))
* Exiting when app does not exist ([fc0be25](fc0be25))
* get-app ln -s ([e69b612](e69b612))
* Initialize bench on bench get(-app) if not created ([38382b8](38382b8))
* introduced simple resolver ([bfd69c3](bfd69c3))
* introduced simple resolver ([d41e05e](d41e05e))
* Made dynamic mount path if bench attr is passed to App class ([b36c072](b36c072))
* mimicking get-app behaviour when app is already installed ([bbca3e9](bbca3e9))
* **minor:** --install-app option in init ([8480eb5](8480eb5))
* **minor:** Any procman in bench start ([bae338a](bae338a))
* **minor:** App Meta handling on disk repos ([1865eee](1865eee))
* **minor:** Bench.python property that points to env python ([d63a988](d63a988))
* New easy-install.py ([044e01b](044e01b))
* New methods in Bench class ([53e811f](53e811f))
* New methods in the App Class ([54f9741](54f9741))
* **nginx:** Allow logging settings as site/combined/none ([5370129](5370129))
* Pass --use-feature='dynamic-feed' for new CLI ([b92fb14](b92fb14))
* printing resolved dependencies when using resolve-deps flag wih get-app ([95b0834](95b0834))
* printing resolved dependencies when using resolve-deps flag wih get-app ([bba4019](bba4019))
* **remove-app:** Options for no backup of app & force removal ([69e14e5](69e14e5))
* Restart process manager for develop mode ([6123cd5](6123cd5))
* Setup dev-dependencies defined via pyproject ([75957a5](75957a5))
* Setup Requirements for specific apps ([frappe#1265](https://github.com/abcgitalbadia/bench/issues/1265)) ([28e6816](28e6816))
* Skip warnings if envvar BENCH_DEVELOPER set ([20560c9](20560c9))
* slower alternative for get_required_deps ([d0bd294](d0bd294))
* Support Frappe app distributions with pyproject.toml ([800394c](800394c))
* using gitpython for branch validation ([cb2b0b0](cb2b0b0))
* verbose env setup & checking for compatible versions ([d178b08](d178b08))
* verbose error messages ([19f9325](19f9325))

### Performance Improvements

* Cache Bench and App instantiation ([cd1f526](cd1f526))
* caching deps and orgs, repos to avoid time taking checks & added slower version to check org and repo ([bd105a6](bd105a6))
* single worker in development install ([frappe#1392](https://github.com/abcgitalbadia/bench/issues/1392)) ([9c80f5d](9c80f5d))
* Using github API ([b0ae3ae](b0ae3ae))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants