-
Notifications
You must be signed in to change notification settings - Fork 191
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
update computer test output #3544
Conversation
|
||
self.assertEquals(get_job('861352').title, 'Pressure_PBEsol_0') | ||
|
||
self.assertEquals(get_job('863554').requested_wallclock_time_seconds, None) # not set |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing I noticed is that this time will also be None
, if the value could not be parsed.
Perhaps ok, but it means that finding a value None
does no longer mean that parsing failed.
I feel the change you are making to the scheduler parsing is too important to be muffled away in a commit on changing the output format of a computer test function. Would you be willing to separate that in another PR? |
edcabfa
to
7ff62a8
Compare
Done #3586 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor visual suggestions, but ok to leave it as is if you disagree
@@ -141,11 +142,11 @@ def _computer_create_temp_file(transport, scheduler, authinfo): # pylint: disab | |||
|
|||
file_content = "Test from 'verdi computer test' on {}".format(datetime.datetime.now().isoformat()) | |||
echo.echo('> Creating a temporary file in the work directory...') | |||
echo.echo(' `-> Getting the remote user name...') | |||
echo.echo(' -> Getting the remote user name...') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it is nice to put the [OK]
on the same line as the first line.
This would go for all other lines as well where there is no other intermediate result but just an ok.
Put the message with ellipses and OK on the same line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree this looks nicer and I wanted to do this at first. It's nasty though - what do you do if the test fails?
During test failures, some commands print random stuff, which will then inevitably land on the same line.
For the "echo" statements originating from the command itself one could handle it, but also there you would need to do quite a bit of if/else in order to avoid having stuff printed on the same line that shouldn't be.
I've made the changes here https://github.com/ltalirz/aiida-core/tree/computer-test-echo-nl-false
Let me know what you prefer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it fails, we can still print the error after a [FAILED]
right? Or even on the next line if it is multiple lines. But I would imagine something like this:
* Getting job list... [OK]: Found 6 jobs in the queue
* Checking that no spurious output is present... [FAILED]
* Getting the remote user name... [OK]: <ltalirz>
* Retrieving the file and checking its content... [FAILED]: file not found
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well, that is if you control everything that happens between printing "..." and the failure.
currently, many of the methods being called here just randomly print stuff (and not just the ones defined inside this file).
I'd have to start capturing all of this - can be done but is quite some work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can just put the calling blocks in with Capturing()
no? If you are ok with it, I will gladly update your other branch to do it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, please go ahead!
you have write acces to my fork already
|
||
handle, destfile = tempfile.mkstemp() | ||
os.close(handle) | ||
try: | ||
transport.getfile(remote_file_path, destfile) | ||
with io.open(destfile, encoding='utf8') as dfile: | ||
read_string = dfile.read() | ||
echo.echo(' [Retrieved]') | ||
echo.echo(' [Retrieved]') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe remove this one and just put [OK]
instead of [Content OK]
on same line.
transport.remove(remote_file_path) | ||
echo.echo(' [Deleted successfully]') | ||
echo.echo(' [Deleted successfully]') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here, just [OK]
would suffice?
else: | ||
echo.echo('Test completed (all {} tests succeeded)'.format(num_tests)) | ||
echo.echo_success('All {} tests succeeded)'.format(num_tests)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the string contains unbalanced closing parens
7ff62a8
to
9007485
Compare
@ltalirz I have updated the branch. I intended to push this to your second "test" branch but accidentally did it to the PR branch. Anyway, I didn't touch your commit, just rebased it so it is up-to-date. The additional commit will make it look as follows: SuccessFailedWith traceback |
try: | ||
echo.echo('> Testing connection...') | ||
echo.echo('* Opening connection... ', nl=False) | ||
|
||
with transport: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if an error happens here (e.g. configure a wrong username).
It will start printing stuff...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
num_tests += 1 | ||
for test in [_computer_test_no_unexpected_output, _computer_test_get_jobs, _computer_create_temp_file]: | ||
|
||
click.secho('[OK]', fg=echo.COLORS['success'], bold=echo.BOLD) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in my 2nd PR I introduced an echo.echo_highlight
command that saves one from specifying the bold
parameter + one can pass directly 'success'
.
Can save some text...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added this to your first commit and then used it in mine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For me it's anyhow an improvement and good to merge.
@sphuber Since it's my PR, you will need to approve yourself ;-)
* fix indentation * add color to results of all 3 tests * add "success" to final message * add `aiida.cmdline.utils.echo.echo_highlight` function
The number of tests is increased and messaging from within each test is disabled. The tests now return a tuple of a boolean indicating success or failure and an optional message. This message can be informational in case of success or an error message. With echo'ing only being performed in the main function, the output can be given a consistent look. Each test will have `[OK]` or `[FAILED]` on the same line with an optional message. Additional lines, such as for the full traceback, are prepended with newline and two spaces of indentation.
9007485
to
09fb35b
Compare
I included |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @sphuber , looks good to me!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @ltalirz
This PR updates the output of
verdi computer test
Old output:
New output: