-
Notifications
You must be signed in to change notification settings - Fork 43
feat: change storages arguments to function instance #1789
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
base: main
Are you sure you want to change the base?
Conversation
ElePT
left a comment
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 comment as I left on another PR: As a side note, I think that it would be good to also start documenting more internal-facing changes in the release notes, as we started doing with interface changes. I left some pointers in another PR on how to do this: #1788 (comment). If you don't agree, I am open for discussion on what should and shouldn't be part of the renos.
Thanks @ElePT . Change is done |
korgan00
left a comment
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.
Looks good to me. Just a minor thing.
gateway/api/services/file_storage.py
Outdated
| Attributes: | ||
| username (str): storage user's username | ||
| working_dir (WorkingDir(Enum)): working directory |
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 think that you can safely remove this too.
| Args: | ||
| function: Program model instance containing title, provider, and author | ||
| """ | ||
| username = function.author.username |
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.
Correct if I'm wrong but this is not correct. The username comes from the request, not from the author from the function, right?
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.
Different users can use the same function and artifacts need to be stored in the path that the user is using it. The issue was only proposing to change function title and provider. User will need to continue being required.
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.
Yeah, I didn't take that in mind. Can you add a test before fix this to catch 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.
You are right! I have changed it
| Args: | ||
| function: Program model instance containing title, provider, and author | ||
| """ | ||
| username = function.author.username |
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.
Yeah, I didn't take that in mind. Can you add a test before fix this to catch this case?
…-serverless into feat-improve-storage-logic
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 release note looks very good, thanks @paaragon. I have not had time to go through the rest of the PR, but I see that you already have a good amount of reviews.
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.
Could you add a test trying to access Arguments storage with multiple users and have different contents in the files? The function creator with some arguments, one user with other arguments and a third one without a file. The three using the same function.
I think it should test #1789 (comment).
| def __init__(self, function): | ||
| """ | ||
| Initialize the storage path for a given function. | ||
| Args: | ||
| function: Program model instance containing author | ||
| """ | ||
| username = function.author.username | ||
| self.user_results_directory = os.path.join( | ||
| settings.MEDIA_ROOT, username, "results" | ||
| ) |
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 think this changes is putting the result data in the wrong folder. The folder should be the user who runs the job. That means, this change is not needed at all.
| self.assertEqual(job.config.max_workers, 5) | ||
| self.assertEqual(job.config.workers, None) | ||
| self.assertEqual(job.config.auto_scaling, True) | ||
|
|
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 should assert if the folder name where the result/argument/logs/whatever is created is right, not only the content.
Summary
This PR refactors the storages arguments so instead of receiving title and provider, they receive a function instance.
Details and comments