Skip to content
New issue

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

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

Already on GitHub? # to your account

Add a meaningful error warning when KDS path is not provided when running yarn run devserver-with-kds #11657

Merged
merged 2 commits into from
Dec 21, 2023

Conversation

KshitijThareja
Copy link
Contributor

Summary

This PR aims to make the yarn run devserver-with-kds command throw an error warning when KDS path is not provided while running it in the cli.

References

#11632

Reviewer guidance

  1. Run the yarn run devserver-with-kds command in the cli without specifying the path to the local kds.
  2. You'll see an error message and the command will terminate with exit code 1.

Screenshot

Errorproof


Testing checklist

  • Contributor has fully tested the PR manually
  • If there are any front-end changes, before/after screenshots are included
  • Critical user journeys are covered by Gherkin stories
  • Critical and brittle code paths are covered by unit tests

PR process

  • PR has the correct target branch and milestone
  • PR has 'needs review' or 'work-in-progress' label
  • If PR is ready for review, a reviewer has been added. (Don't use 'Assignees')
  • If this is an important user-facing change, PR or related issue has a 'changelog' label
  • If this includes an internal dependency change, a link to the diff is provided

Reviewer checklist

  • Automated test coverage is satisfactory
  • PR is fully functional
  • PR has been tested for accessibility regressions
  • External dependency files were updated if necessary (yarn and pip)
  • Documentation is updated
  • Contributor is in AUTHORS.md

@github-actions github-actions bot added DEV: tools Internal tooling for development SIZE: very small labels Dec 16, 2023
@KshitijThareja
Copy link
Contributor Author

@MisRob I had to use the --kds flag here (as also suggested by @Jaspreet-singh-1032) because without it, I don't think there's any direct way to know if the yarn command is run using devserver or devserver-with-kds.
If there are any suggestions from your side, I'd be happy to work on them.

Copy link
Member

@nucleogenesis nucleogenesis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love the introduction of an error message here. This will make things much easier to work out why something has gone awry when it inevitably does. Thank you for your work on this!

Each of my review comments is merge-blocking. Please let me know if you have any questions!

package.json Outdated
@@ -26,7 +26,7 @@
"app-devserver": "concurrently --passthrough-arguments --kill-others \"yarn:watch --watchonly {1}\" yarn:app-python-devserver yarn:hashi-dev --",
"devserver": "concurrently --passthrough-arguments --kill-others \"yarn:watch --watchonly {1}\" yarn:python-devserver yarn:hashi-dev --",
"devserver-hot": "concurrently --passthrough-arguments --kill-others \"yarn:watch-hot --watchonly {1}\" yarn:python-devserver yarn:hashi-dev --",
"devserver-with-kds": "concurrently --passthrough-arguments --kill-others \"yarn:watch --watchonly --kds-path={1}\" yarn:python-devserver yarn:hashi-dev --",
"devserver-with-kds": "concurrently --passthrough-arguments --kill-others \"yarn:watch --watchonly --kds --kds-path={1}\" yarn:python-devserver yarn:hashi-dev --",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing that I think might be an issue here is that this seems like it will disallow the use of the baked-in --watchonly call which can be passed a comma-separated list of plugins like so IIRC:

yarn devserver learn,coach which will restrict the build process to those Kolibri plugins.

The --kds-path is swallowing the entirety of what is passes in as the --watchonly option will never receive any user input.

So we cannot call yarn devserver-with-kds learn,coach to only build those plugins because the resulting call will be

kolibri-tools build dev --file ./build_tools/build_plugins.txt --cache --watchonly --kds-path=learn,coach


Perhaps we can maintain the functionality by changing this line to:

"devserver-with-kds": "concurrently --passthrough-arguments --kill-others \"yarn:watch --watchonly={2} --kds --kds-path={1}\" yarn:python-devserver yarn:hashi-dev --"

(note the ={2} added after --watchonly)

In this case, we can call: yarn devserver-with-kds ../path/to/kds learn,coach which would result in this call:

kolibri-tools build dev --file ./build_tools/build_plugins.txt --cache --watchonly=learn,coach --kds-path=../path/to/kds

And this should fix the issue here.

@@ -226,8 +227,15 @@ program
list,
[]
)
.option('--kds', 'Flag to use local kds', false)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that maybe the description here isn't entirely true. You don't need this flag to run with local KDS but rather you just need this flag if you want to get errors related to your attempts to use local KDS.

It might be better to call this something like --require-kds-path to better indicate what it is really doing.

.option('--kds-path <kdsPath>', 'Full path to local kds directory', String, '')
.action(function(mode, options) {
if (options.kds) {
if (!options.kdsPath) {
cliLogging.error('Path to the local KDS directory not specified.');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think updating this to indicate why the error was received will help here. Like "The --require-kds-path flag was given but no --kds-path value was given. Please provide the local KDS directory" (or something like that).

@KshitijThareja
Copy link
Contributor Author

Hi @nucleogenesis. Thanks for your suggestions. I've made all the required changes as requested. Can you please go through them once and check if there are any more changes needed?

Copy link
Member

@nucleogenesis nucleogenesis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @KshitijThareja !

I've tested the failed state and got the error as expected.

I also tested by updating KTextbox in my and the files were being watched and rebuilt when I saved the file then I saw my changes:

image

I'll be drafting a follow-up issue re: the --watchonly flag separately. I'm not super sure how best to begin addressing that issue at the moment.

@@ -26,7 +26,7 @@
"app-devserver": "concurrently --passthrough-arguments --kill-others \"yarn:watch --watchonly {1}\" yarn:app-python-devserver yarn:hashi-dev --",
"devserver": "concurrently --passthrough-arguments --kill-others \"yarn:watch --watchonly {1}\" yarn:python-devserver yarn:hashi-dev --",
"devserver-hot": "concurrently --passthrough-arguments --kill-others \"yarn:watch-hot --watchonly {1}\" yarn:python-devserver yarn:hashi-dev --",
"devserver-with-kds": "concurrently --passthrough-arguments --kill-others \"yarn:watch --watchonly --kds-path={1}\" yarn:python-devserver yarn:hashi-dev --",
"devserver-with-kds": "concurrently --passthrough-arguments --kill-others \"yarn:watch --watchonly={2} --require-kds-path --kds-path={1}\" yarn:python-devserver yarn:hashi-dev --",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking as I think this is probably out of scope of the issue you're trying to resolve here, so I'll make a follow-up issue after merging this.

But - I think that we'll need to do some tweaking because when I use the --watchonly flag here with:

yarn devserver-with-kds path/to/kds user_auth then the build system doesn't recognize whenever I make a change in KDS.

But when I don't pass in any plugins for the --watchonly then the front-end rebuilds reactively to changes I make within KDS.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that. And yes, it'd be better to have a follow-up for this issue so that it can be focussed on separately. I too am not sure how to move forward with it. I believe this is one important feature to have and requires separate attention.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
DEV: tools Internal tooling for development SIZE: small SIZE: very small
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants