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

Created default executable script on new Script and added validation #3273

Merged
merged 2 commits into from
Jan 10, 2024

Conversation

abujeda
Copy link
Contributor

@abujeda abujeda commented Jan 2, 2024

Creates a default executable script in the project's directory when a new Script is created.
As well, it adds a validation message when there are no executable scripts in the project.

Fixes #3255

@johrstrom
Copy link
Contributor

Sorry for the delay on this, I'll be sure to look it over shortly.

@johrstrom
Copy link
Contributor

Sorry, we're really felling the pressure for 3.1 so I may not get to this quickly as it's not really required for 3.1.


script_content = <<~EOF
#!/bin/bash
# Sample script to configure project defaults. Delete when other scrips available.
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be "Delete when other scripts are available."

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

Comment on lines +14 to +19
@valid_scripts = Script.scripts?(@project.directory)

alert_messages = []
alert_messages << I18n.t('dashboard.jobs_project_invalid_configuration_clusters') unless @valid_project
alert_messages << I18n.t('dashboard.jobs_project_invalid_configuration_scripts') if @scripts.any? && !@valid_scripts
flash.now[:alert] = alert_messages.join(' ') if alert_messages.any?
Copy link
Contributor

Choose a reason for hiding this comment

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

I cannot seem to get these alerts to show up. But honestly, if it creates a hello_world.sh automatically - I wonder if we need them at all?

I think creating the default script without asking/or alerting the user is actually a good first step. Maybe we could build in the alert/prompt later - but I'm now wondering what value it provides?

Maybe actually - just a note on the success notice like -

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The script error message will appear if there are Scripts created and afterwards, the user manually deletes all the executable scripts from the project. Then, when rendering the projects page, the error message will show.

As scripts are added/removed by the user with the file upload tool, it is possible that the user deletes all executables.

Copy link
Contributor

Choose a reason for hiding this comment

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

The script error message will appear if there are Scripts created and afterwards, the user manually deletes all the executable scripts from the project.

That was the step I was missing! Yes I'm now able to get the alert to flash.

OK - While I'm fine for this for now, I would still make a ticket to make this flash a modal that you says something to the same effect, where you can click to create one.

An executable shell script is required for your project.

Would you like to create a hello world shell script?
[yes]   [no]

If you want to pick that up now or later, either is fine with me.

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 think later is better.

I am not sure about the modal as it will keep appearing and forcing the user to select an option every time the projects page is displayed (if they select no and until a script is created).

Copy link
Contributor

Choose a reason for hiding this comment

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

OK.

I am not sure about the modal as it will keep appearing and forcing the user to select an option every time the projects page is displayed (if they select no and until a script is created).

That's fine by me. They need a script for any of this to work, so it's either our modal telling them that or the sbatch or similar failure message when they attempt to start a job - which they may or may not understand.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added the default script created message

Comment on lines 202 to 203
return if Script.scripts?(project_dir)
return if default_script_path.exist?
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you combine these into return if Script.scripts?(project_dir) || default_script_path.exist?. Little bit of a nit-pick, but I just think that's the ruby way (whatever that means).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

Copy link
Contributor

@johrstrom johrstrom left a comment

Choose a reason for hiding this comment

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

Thanks!

@johrstrom johrstrom merged commit f91999a into OSC:master Jan 10, 2024
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pm - create hello_world.sh if there are no scripts
3 participants