rtCamp / Frappe-Manager

A CLI tool based on Docker Compose to easily manage Frappe based projects.
MIT License
143 stars 29 forks source link

The output formatting was not smooth #28

Closed rahul286 closed 1 year ago

rahul286 commented 1 year ago

Log of my command execution.

I believe we are using rich already. Unsure how can we make improve the following.

Issues noticed (listing 3 only out of many) :

If we using a python docker module, it may be trying to format output itself. We may need to turn off rich formatting before docker output start.

❯ fm create erp

✅ Sites directory doesn't exists! Created at -> /Users/rahul286/frappe

✅ Stopped all sites !
Stopping all other sites !
[+] Pulling 17/23Images
[+] Pulling 63/23ipped - Image is already being pulled by redis-socketio                                                       0.0s
 ✔ redis-cache Skipped - Image is already being pulled by redis-socketio                                                       0.0s
 ✔ redis-queue Skipped - Image is already being pulled by redis-socketio                                                       0.0s
 ✔ nginx 12 layers [⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿]      0B/0B      Pulled                                                                      18.8s  ✔ adminer 7 layers [⣿⣿⣿⣿⣿⣿⣿]      0B/0B      Pulled                                                                           9.4s
 ✔ mariadb 8 layers [⣿⣿⣿⣿⣿⣿⣿⣿]      0B/0B      Pulled                                                                         15.8s
 ✔ frappe 20 layers [⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿]      0B/0B      Pulled                                                             44.8s
 ✔ redis-socketio 5 layers [⣿⣿⣿⣿⣿]      0B/0B      Pulled                                                                     37.9s
 ✔ mailhog 3 layers [⣿⣿⣿]      0B/0B      Pulled                                                                              36.5s

[+] Running 13/13
 ✔ Network erplocalhost_default               Created                                                                          0.0s
 ✔ Volume "erplocalhost_redis-cache-data"     Created                                                                          0.0s
 ✔ Volume "erplocalhost_redis-queue-data"     Created                                                                          0.0s
 ✔ Volume "erplocalhost_redis-socketio-data"  Created                                                                          0.0s
 ✔ Volume "erplocalhost_mariadb-data"         Created                                                                          0.0s
 ✔ Container erplocalhost-nginx-1             Started                                                                          0.9s
 ✔ Container erplocalhost-mailhog-1           Started                                                                          0.8s
 ✔ Container erplocalhost-adminer-1           Started                                                                          0.7s
 ✔ Container erplocalhost-frappe-1            Started                                                                          0.8s
 ✔ Container erplocalhost-mariadb-1           Started                                                                          0.8s
 ✔ Container erplocalhost-redis-cache-1       Started                                                                          0.8s
 ✔ Container erplocalhost-redis-socketio-1    Started                                                                          0.8s
 ✔ Container erplocalhost-redis-queue-1       Started                                                                          0.8s
Setting up user
groupadd: GID '20' already exists
Setting Up Environment
$ python3 -m venv env
$ /workspace/frappe-bench/env/bin/python -m pip install --quiet --upgrade pip
$ /workspace/frappe-bench/env/bin/python -m pip install --quiet wheel
Getting frappe
$ git clone https://github.com/frappe/frappe.git --branch version-14 --depth 1 --origin upstream
Cloning into 'frappe'...
Updating files:  81% (2515/3077)Updating files:  82% (2524/3077)Updating files:  83% (2554/3077)Updating files:  84%
(2585/3077)Updating files:  85% (2616/3077)Updating files:  86% (2647/3077)Updating files:  87% (2677/3077)Updating files:  88%
(2708/3077)Updating files:  89% (2739/3077)Updating files:  90% (2770/3077)Updating files:  91% (2801/3077)Updating files:  92%
(2831/3077)Updating files:  93% (2862/3077)Updating files:  94% (2893/3077)Updating files:  95% (2924/3077)Updating files:  96%
(2954/3077)Updating files:  97% (2985/3077)Updating files:  98% (3016/3077)Updating files:  99% (3047/3077)Updating files: 100%
(3077/3077)Updating files: 100% (3077/3077), done.
Installing frappe
$ /workspace/frappe-bench/env/bin/python -m pip install --quiet --upgrade -e /workspace/frappe-bench/apps/frappe
$ yarn install
yarn install v1.22.19
[1/5] Validating package.json...
[2/5] Resolving packages...
[3/5] Fetching packages...
[4/5] Linking dependencies...
warning " > @frappe/esbuild-plugin-postcss2@0.1.3" has unmet peer dependency "less@^4.x".
warning " > @frappe/esbuild-plugin-postcss2@0.1.3" has unmet peer dependency "stylus@^0.x".
[5/5] Building fresh packages...
$ npm run snyk-protect

> snyk-protect
> snyk-protect

Applied Snyk patches.
npm notice
npm notice New major version of npm available! 9.6.7 -> 10.1.0
npm notice Changelog: <https://github.com/npm/cli/releases/tag/v10.1.0>
npm notice Run `npm install -g npm@10.1.0` to update!
npm notice
Done in 25.30s.
Found existing apps updating states...
$ supervisorctl restart frappe:
unix:///var/run/supervisor.sock no such file
WARN: restarting supervisor failed. Use `bench restart` to retry.
SUCCESS: Bench frappe-bench initialized
unix:///opt/user/supervisor.sock no such file
wait-for-it: waiting 120 seconds for mariadb:3306
wait-for-it: mariadb:3306 is available after 0 seconds
wait-for-it: waiting 120 seconds for redis-cache:6379
wait-for-it: redis-cache:6379 is available after 0 seconds
wait-for-it: waiting 120 seconds for redis-queue:6379
wait-for-it: redis-queue:6379 is available after 0 seconds
wait-for-it: waiting 120 seconds for redis-socketio:6379
wait-for-it: redis-socketio:6379 is available after 0 seconds
unix:///opt/user/supervisor.sock no such file
unix:///opt/user/supervisor.sock no such file
unix:///opt/user/supervisor.sock no such file
unix:///opt/user/supervisor.sock no such file
unix:///opt/user/supervisor.sock no such file
unix:///opt/user/supervisor.sock no such file
unix:///opt/user/supervisor.sock no such file
unix:///opt/user/supervisor.sock no such file
unix:///opt/user/supervisor.sock no such file
unix:///opt/user/supervisor.sock no such file
unix:///opt/user/supervisor.sock no such file
unix:///opt/user/supervisor.sock no such file
unix:///opt/user/supervisor.sock no such file
Assets for Release v14.48.1 don't exist
Linking /workspace/frappe-bench/apps/frappe/frappe/public to ./assets/frappe    Linking
/workspace/frappe-bench/apps/frappe/node_modules to ./assets/frappe/node_modules
✔ Application Assets Linked

yarn run v1.22.19
$ node esbuild --run-build-command
clean: postcss.plugin was deprecated. Migration guide:
https://evilmartians.com/chronicles/postcss-8-plugin-migration
clean: postcss.plugin was deprecated. Migration guide:
https://evilmartians.com/chronicles/postcss-8-plugin-migration
Browserslist: caniuse-lite is outdated. Please run:
  npx browserslist@latest --update-db
  Why you should do it regularly: https://github.com/browserslist/browserslist#browsers-data-updating
clean: postcss.plugin was deprecated. Migration guide:
https://evilmartians.com/chronicles/postcss-8-plugin-migration
clean: postcss.plugin was deprecated. Migration guide:
https://evilmartians.com/chronicles/postcss-8-plugin-migration
File                                                        Size

frappe/dist/js/
├─ bootstrap-4-web.bundle.7VCXKZMB.js                       2.09 Kb
├─ controls.bundle.LMEKJKK4.js                              1745.47 Kb
├─ data_import_tools.bundle.HMQMLIYY.js                     237.76 Kb
├─ desk.bundle.O4HDCSEZ.js                                  2542.36 Kb
├─ dialog.bundle.NZJ567YF.js                                89.86 Kb
├─ form.bundle.66ZVMHV2.js                                  260.12 Kb
├─ frappe-web.bundle.ZTJNSQRM.js                            2242.77 Kb
├─ libs.bundle.6XLVBACU.js                                  1486.58 Kb
├─ list.bundle.LC5CR4OE.js                                  305.89 Kb
├─ logtypes.bundle.6XKFPWVQ.js                              1.13 Kb
├─ onboarding_tours.bundle.QHQ62UJI.js                      13.34 Kb
├─ recorder.bundle.OINNNE2C.js                              462.29 Kb
├─ report.bundle.QP7MO5GQ.js                                348.06 Kb
├─ telemetry.bundle.D5NSGVQ2.js                             3.26 Kb
├─ user_profile_controller.bundle.X7TOLIDE.js               18.79 Kb
├─ video_player.bundle.5NDHKKAB.js                          268.43 Kb
├─ web_form.bundle.VTB5ZZT5.js                              2238.32 Kb
├─ print_format_builder.bundle.NFXMOFMP.js                  357.62 Kb
├─ build_events.bundle.BEO64C2K.js                          20.62 Kb
└─ kanban_board.bundle.MTIU3SCA.js                          66.44 Kb

frappe/dist/css/
├─ desk.bundle.SBG5GK2Z.css                                 661.63 Kb
├─ email.bundle.KJBPGD7R.css                                5.17 Kb
├─ login.bundle.7COD4H2J.css                                30.08 Kb
├─ print.bundle.HQUGILJ3.css                                236.96 Kb
├─ print_format.bundle.RGVVWERV.css                         220.64 Kb
├─ report.bundle.KYMQYTGE.css                               6.62 Kb
├─ web_form.bundle.R2YSGLKQ.css                             17.77 Kb
└─ website.bundle.TUXTGYTG.css                              518.22 Kb

frappe/dist/css-rtl/
├─ desk.bundle.FGAVK7UW.css                                 661.93 Kb
├─ email.bundle.2M5BJZAD.css                                5.18 Kb
├─ login.bundle.RPNOWR7C.css                                30.07 Kb
├─ print.bundle.LW4L7ZCF.css                                237.10 Kb
├─ print_format.bundle.X3IDTH4C.css                         220.75 Kb
├─ report.bundle.5U6F2JUQ.css                               6.61 Kb
├─ web_form.bundle.QZLFEEHI.css                             17.76 Kb
└─ website.bundle.Z3UED3FV.css                              518.37 Kb

 DONE  Total Build Time: 6.797s

clean: postcss.plugin was deprecated. Migration guide:
https://evilmartians.com/chronicles/postcss-8-plugin-migration
Done in 7.28s.
unix:///opt/user/supervisor.sock no such file

Installing frappe...
Updating Do

Updating DocTypes for frappe        : [========================================] 100%

Up

Updating country info               : [========================================] 100%

Updating Dashboard for frappe
*** Scheduler is disabled ***
unix:///opt/user/supervisor.sock no such file
Scheduler is enabled for site erp.localhost
unix:///opt/user/supervisor.sock no such file
2023-09-11 17:08:33,795 INFO RPC interface 'supervisor' initialized
2023-09-11 17:08:33,795 CRIT Server 'unix_http_server' running without any HTTP authentication checking
2023-09-11 17:08:33,795 INFO supervisord started with pid 1237
2023-09-11 17:08:34,800 INFO spawned: 'bench-dev' with pid 1238
+-----------------+--------------------------------------+
| Site Url        | http://erp.localhost                 |
+-----------------+--------------------------------------+
| Site Root       | /Users/rahul286/frappe/erp.localhost |
+-----------------+--------------------------------------+
| Mailhog Url     | http://erp.localhost/mailhog         |
+-----------------+--------------------------------------+
| Adminer Url     | http://erp.localhost/adminer         |
+-----------------+--------------------------------------+
| Frappe Username | administrator                        |
+-----------------+--------------------------------------+
| Frappe Password | admin                                |
+-----------------+--------------------------------------+
| DB Host         | mariadb                              |
+-----------------+--------------------------------------+
| DB Name         | erp-localhost                        |
+-----------------+--------------------------------------+
| DB User         | erp-localhost                        |
+-----------------+--------------------------------------+
| DB Password     | LlJV6BTdIdn9Z8Sc                     |
+-----------------+--------------------------------------+

     Bench Apps
+--------+---------+
| App    | Version |
+--------+---------+
| frappe | 14.48.1 |
+--------+---------+
⡿ Getting site info

rahul286 ~/Developer/frappe ⌛ 4m24s
❯ fm

 Usage: fm [OPTIONS] COMMAND [ARGS]...

╭─ Options ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ --install-completion          Install completion for the current shell.                                                          │
│ --show-completion             Show completion for the current shell, to copy it or customize the installation.                   │
│ --help                        Show this message and exit.                                                                        │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Commands ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ code                  Open site in vscode. ✨                                                                                    │
│ create                Create a new site. ✨                                                                                      │
│ delete                Delete a site. ✨                                                                                          │
│ info                  Shows information about given site.                                                                        │
│ list                  Lists all of the available sites. ✨                                                                       │
│ logs                  Show logs for the given site. ✨                                                                           │
│ shell                 Open shell for the give site. ✨                                                                           │
│ start                 Start a site. ✨                                                                                           │
│ stop                  Stop a site. ✨                                                                                            │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

rahul286 ~/Developer/frappe
❯ fm list
⣾ Working
╭─ Running ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ erp.localhost                                                                                                                    │
│ /Users/rahul286/frappe/erp.localhost                                                                                             │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
Xieyt commented 1 year ago

Yess, we are using rich library and also python_on_whales for handling docker related stuffs. I will research on how I can improve the UX.

rahul286 commented 1 year ago

Did you try https://github.com/docker/docker-py ?

Xieyt commented 1 year ago

It appears that docker-py package has certain limitations:

  1. It lacks support for docker compose operations, which are essential for efficiently managing Docker containers.
  2. Attempting to replicate the compose feature using docker-py lead to a more complex and error-prone solution.
  3. Additionally, we do not require low-level Docker engine operations for our needs.

Considering these findings, I recommend using current approach of using python_on_whales or running Docker commands via subprocess or creating custom wrapper around docker compose like python_on_whales for our use case. Along with this improve output processing/presentation/ux.

Please let me know what should be best approach to go with ?

dhsathiya commented 1 year ago

@Xieyt I think the output is very verbose. What we can do is to have a verbose flag --verbose that will print out all the lines from the commands you are running internally. If verbose flag is not passed: We can just have state for each command you are running internally.

✅  docker pull 
✅  docker compose up
🚧  creating bench environment
...
rahul286 commented 1 year ago

Even when verbosity is disabled, complete log can be found in a file.