-
Notifications
You must be signed in to change notification settings - Fork 187
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
ssh transport : adapt for subclassing #4363
Merged
Merged
Changes from 11 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
65ea5a0
adapt ssh.py to handle subclassing file transport part.
adegomme 0689d2b
limit output of this logger call to 1000 chars.
adegomme 745ca9c
please linter
adegomme 4543bf7
add docstrings
adegomme 5f22ff6
clarify error message
adegomme 13fa71a
Don't catch everything, just sshexception.
adegomme 88b88c9
add comments for stat/lstat functionality and output (from paramiko)
adegomme 81319e4
rename symlink_internal to _symlink
adegomme a141f47
try to avoid warning by circleci
adegomme 5f84473
try again
adegomme 9f52676
transport name was renamed (and be more explicit by giving the full p…
adegomme bcab0a9
allow subclasses to configure cropping of log message without changin…
adegomme 41cd80b
Merge branch 'develop' into sshbase
sphuber File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
So the rest of the re-organization and wrapping of methods seems ok to me, but this is the only modification that I am unsure about. Can't you be loosing important log info like this? I would also maybe ask for the input of @giovannipizzi and/or @sphuber in this, since they probably know better what to expect inside that command and why is being logged.
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.
Also interested to know why @adegomme thinks this should be cropped.
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.
To send a file with the sshonly plugin, the resulting command is equivalent to
ssh remote "echo '$(cat localfile)' | cat > remotefile"
, with the '$(cat localfile)' being a python read instead, as I never managed to have the cat version behave correctly.This logger call means that the whole content of the file is printed in the log :
example when making a 'verdi computer test'
09/17/2020 10:17:12 AM <1120861> aiida.transport.SshOnlyTransport: [DEBUG] Command to be executed: cd '/path/aiida' && echo 'Test from '"'"'verdi computer test'"'"' on 2020-09-17T10:17:05.830707' | cat > /path/aiida/tmpbtteknws
So this adds the whole file content to the log output when debug is activated, which is not great. Every input file, structure file, pseudopotential file gets printed in the stdout or the log when debug is on, and when several MB get dumped on you, this can be troublesome.
Cropping is meant to avoid ruining the log and the terminal. 1000 char is a bit arbitrary (but seemed to be large enough to not affect other messages in my tests), and maybe we could add a comment when it's cropped ( simply "...", or "cropped to 1000 chars to maintain readability") to avoid confusion.
Another idea would be to have an optional parameter on _exec_command_internal to disable this log message, but you would not see any file upload log in this case.
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 see. Thanks for the explanation. In any case, even if we keep this, we should definitely comment this, because it is not obvious at all, especially given that the actual use case comes from a subclass that lives in another plugin package. @giovannipizzi do you see a way around this? If we make the cropping size an optional argument to the function, at least
SshOnly
can override the copy file method to call_exec_command_internal
to passmax_log_size=1000
or something to that effect.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.
After discussing with @sphuber I think a good solution is to have a class attribute, e.g.
_MAX_EXEC_COMMAND_LOG_SIZE=None
in this base class.Here the logic would not crop if
self._MAX_EXEC_COMMAND_LOG_SIZE
is None, otherwise it would crop to this length (command_to_execute[:self._MAX_EXEC_COMMAND_LOG_SIZE]
).In this way the current behaviour is unchanged, and in your subclass @adegomme you can just set
_MAX_EXEC_COMMAND_LOG_SIZE
to the value you want.@adegomme what do you think? Are you OK to do this small change? After, it's ready to merge for me