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

allow writing into Data Volume in job submission #9

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from

Conversation

mtaghiza
Copy link
Contributor

No description provided.

Copy link
Contributor

@glemson glemson left a comment

Choose a reason for hiding this comment

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

I don't understand the lines like
426/554: datVols.append({'userVolumeId': vol.get('id')...
I thought data volumes are identified by their name, not by a userVolumeId.
Also, the API expect for datavolumes the attribute 'writable', not 'needsWriteAccess'.
I have attached a version of submitShellCommandJob that I have used to work around not being able to write to data volumes. See attached file:

my_submitshelljob.txt

@mtaghiza
Copy link
Contributor Author

mtaghiza commented Apr 3, 2020

the VolumeContainerModel seems to have both a name and an id. I'm now adding both, but probably you remember better whether name is enforced to be unique at registration time.

Copy link
Contributor

@glemson glemson left a comment

Choose a reason for hiding this comment

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

still some changes requested.
Sorry for delay in reviewing.

@@ -410,7 +410,7 @@ def submitNotebookJob(notebookPath, dockerComputeDomain=None, dockerImageName=No
datVols = [];
if dataVolumes is None:
Copy link
Contributor

Choose a reason for hiding this comment

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

I know this is not part of this PR, but I believe that when no dataVolumes are explicitly provided, whether as [] or as None, we should NOT mount any data volumes.

Copy link
Contributor

Choose a reason for hiding this comment

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

however, in any case I would NOT make them writable, even though the DV may be writable by default. I would be happy if users are explicit in what thye want us to do, and if by accident (not providing explicit list) they mount all data volumes, at least they should not be writable.

Choose a reason for hiding this comment

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

Currently behavior is to mount everything if no volumes are specified though. I think that does make for a much more convenient experience for the user instead having to specify a long list of dictionaries of user and data volumes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jonashaase : could you confirm you agree with the changes I just made?

@@ -422,12 +422,12 @@ def submitNotebookJob(notebookPath, dockerComputeDomain=None, dockerImageName=No
if vol.get('name') == dVol.get('name'):
found = True;
if dVol.get('needsWriteAccess'):
if dVol.get('needsWriteAccess') is True and 'write' in vol.get('allowedActions'):
if dVol.get('needsWriteAccess') is True:
Copy link
Contributor

Choose a reason for hiding this comment

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

why is the constraint on "'write' in allowedActions" removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's a bug fix (vol does not have 'allowedActions' field)

datVols.append({'id': vol.get('id'), 'name': vol.get('name'), 'writable': True});
else:
datVols.append({'id': vol.get('id'), 'name': vol.get('name'), 'writable': False});
else:
if 'write' in vol.get('allowedActions'):
if vol.get('writable') is True:
Copy link
Contributor

Choose a reason for hiding this comment

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

again here if a user does not ask for write access we should not give it by default, even if they are allowed to write there..
I'd rather err on the side of caution.

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 that.

@@ -538,7 +536,7 @@ def submitShellCommandJob(shellCommand, dockerComputeDomain = None, dockerImageN
datVols = [];
if dataVolumes is None:
for vol in dockerComputeDomain.get('volumes'):
if 'write' in vol.get('allowedActions'):
if vol.get('writable') is True:
Copy link
Contributor

Choose a reason for hiding this comment

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

see comments above.

… parameter value (but give data volumes only read permissions)
@glemson glemson requested a review from amitschang March 9, 2021 19:50
@glemson
Copy link
Contributor

glemson commented Mar 9, 2021

additions were made based on a conversation on slack. Will copy that here:
the issue was a bit with the fact that None means something different form [] which I was bitten by quite a few times. could we make this explicit, for example datavolumes='all' be interpreted that way? that's "nice" thing of python, data datatypes are not predefined so 'all' is valid. Prefer that over difference between None and [].

so @channel any votes for using the word 'all', both for data and user volumes to explicitly indicate all should be mounted? for data volumes this would imply all read-only, for user volumes mounting writable would depend on what rights you have?

if userVolumes is None:
if userVolumes == 'all':
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we be concerned with backward compatibility here? There may be some cases where users code is passing None and expecting all volumes. Might be good to give a warning about changing behavior prior to all out removal, or at least print warning that behavior has already changed.

@glemson
Copy link
Contributor

glemson commented Mar 9, 2021 via email

@mtaghiza
Copy link
Contributor Author

mtaghiza commented Mar 9, 2021

Could throw an exception, but new documentation and version number warn users as well. Much more disruptive changes might come in the future (like using classes), so users should not expect backwards compatibility for always.

@glemson
Copy link
Contributor

glemson commented Mar 9, 2021 via email

@amitschang
Copy link
Contributor

Yes, this is what I am getting after. There does appear to be some possible sense in a None value in this update (though you could equally force [], so it would be good to have a warning printed when using None

@glemson
Copy link
Contributor

glemson commented Mar 9, 2021

ok. so choice is how to treat None if it is used as an explicit value.
Throw exception or give warning that it will be transformed to []?
OR for backwards compatibility turn it into 'all', BUT give a warning that this is deprecated?

@amitschang
Copy link
Contributor

@mtaghiza just pushed a change to raise an exception, so none will no longer be valid. It will get the job done (nicer would be as you said, turn it to all and put warning - so anyone passing None won't have to fix things immediately)

@glemson
Copy link
Contributor

glemson commented Mar 9, 2021

@mtaghiza would you consider changing the behaviour to turn None to 'all' and raise a warning?

@mtaghiza
Copy link
Contributor Author

mtaghiza commented Mar 9, 2021

@mtaghiza would you consider changing the behaviour to turn None to 'all' and raise a warning?

sure, I did, but not in all methods. Just pushed it.

@glemson
Copy link
Contributor

glemson commented Mar 9, 2021

I meant that if a user specifies None explicitly for userVolumes or dataVolumes, the code will not throw an exception, but change that variable to 'all' and raise a warning. currently still throws an exception.

@mtaghiza
Copy link
Contributor Author

mtaghiza commented Mar 10, 2021

I meant that if a user specifies None explicitly for userVolumes or dataVolumes, the code will not throw an exception, but change that variable to 'all' and raise a warning. currently still throws an exception.

In this particular case, we might be overcomplicating things with adding a warning for a while an then sometime in the future switch the code to throw the exception. If we simply throw the exception in the first place, it is not the case that all users will immediately need to spend some time and effort updating their code. In fact, it is quite the contrary: it will only affect those users that have explicitly assigned the value to None, and only if they happen to create a new container and run the same code in it at some undetermined point in the future. More over, the code update is so trivial and explicit that those particular users can change the value from None to 'all' in a few seconds. And in real life, these end users generally disregard warnings whatsoever, and wait until the last second to update their code only when it breaks, which they will have to do anyways.

Copy link
Contributor

@glemson glemson left a comment

Choose a reason for hiding this comment

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

wow, this has been hanging around way too long.
And I need this code.
Hope others can also have a quick look still.

for vol in dockerComputeDomain.get('volumes'):
datVols.append({'name': vol.get('name')});
datVols.append({'id': vol.get('id'), 'name': vol.get('name'), 'writable': False});

else:
for dVol in dataVolumes:
Copy link
Contributor

Choose a reason for hiding this comment

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

it is still possible for the input argument dataVolumes to be None. In that case this code would throw an error I think.
maybe protect against that by setting dataVolumes to [] if the input was None?
Same for userVolumes.

for vol in dockerComputeDomain.get('volumes'):
datVols.append({'name': vol.get('name')});
datVols.append({'id': vol.get('id'), 'name': vol.get('name'), 'writable': False});
Copy link
Contributor

@glemson glemson Dec 29, 2021

Choose a reason for hiding this comment

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

Just noting here that we treat data volumes differently from user volumes. in the latter needsWriteAccess is decided by user privilege when 'all', for former we want users to explicitly ask for write access.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants