-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Fixes part of #4374: Update docstrings in the python backend code. #6028
Conversation
Updated docstrings in Python Backend code for core.storage.base_model.gae_models_test, core.storage.base_model.gae_models, core.storage.user.gae_models, core.tests.test_utils, core.tests.performance_tests.base, core.tests.performance_framework.perf_services, core.tests.performance_framework.perf_domain, core.domain.summary_services, core.domain.email_jobs_one_off_test, core.domain.visualization_registry
HI @YashJipkate, Thanks for the PR. |
@bansalnitish Done! PTAL! |
Codecov Report
@@ Coverage Diff @@
## develop #6028 +/- ##
========================================
Coverage 45.21% 45.21%
========================================
Files 523 523
Lines 30722 30722
Branches 4605 4605
========================================
Hits 13892 13892
Misses 16830 16830 Continue to review full report at Codecov.
|
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.
Hi @YashJipkate, Took a pass, PTAL!
core/tests/test_utils.py
Outdated
headers: dict. Extra headers to send. | ||
|
||
Returns: | ||
json_response: webtest.TestResponse instance. The response of the |
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.
Remove var name here (json_response
)
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 is it a general practice to not mention variable name in the return?
Thanks!
Done!
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!
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.
Oh Thanks for the info!
core/tests/test_utils.py
Outdated
upload_files: list. A list of (fieldname, filename, file_content). | ||
You can also use just (fieldname, filename) and the file contents | ||
will be read from disk. | ||
headers: dict. Extra headers to send. |
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.
Ditto. Write type info like dict(str, *)
for both key-value pairs.
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.
Done!
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.
Just a minor nit @YashJipkate, Please fix it. Thanks!
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.
@YashJipkate there are few minor nits that you missed. PTAL, else LGTM! Thanks!
Args: | ||
user_id: str. The id of the user. | ||
exploration_id: str. The id of the exploration. | ||
Returns: |
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.
This doesn't seem to be done. Add blank line before Returns
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.
Done! Sorry for missing it.
@@ -406,6 +418,15 @@ class ExplorationUserDataModel(base_models.BaseModel): | |||
|
|||
@classmethod | |||
def _generate_id(cls, user_id, exploration_id): | |||
"""Generates key for the instance of ExplorationUserDataModel class in | |||
the required format with the arguments provided. | |||
Args: |
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.
Ditto.
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.
Done!
Args: | ||
user_id: str. The id of the user. | ||
exploration_id: str. The id of the exploration. | ||
Returns: |
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.
Ditto
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.
Done!
@@ -173,6 +173,16 @@ def get_total_page_size_bytes(self): | |||
return total_size | |||
|
|||
def _get_duration_millisecs(self, event_end, event_initial): | |||
"""Get page load duration. | |||
Args: |
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.
Ditto
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.
Done!
# Waits for the complete page to load, otherwise XHR requests | ||
# made post initial page load will not be recorded. | ||
time.sleep(time_duration_secs or self.DEFAULT_WAIT_DURATION_SECS) | ||
|
||
def _setup_proxy_server(self, downstream_kbps=None, upstream_kbps=None, | ||
latency=None): | ||
"""Sets up a browsermobproxy server. | ||
Args: |
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.
Ditto
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.
Done!
@@ -294,6 +334,10 @@ def _is_current_user_logged_in(self, driver): | |||
return True | |||
|
|||
def _login_user(self, driver): | |||
"""Logs in a user and gets the cookie of the current session. | |||
Args: |
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.
Ditto. Add blank line before Args.
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.
Done!
core/tests/performance_tests/base.py
Outdated
@@ -79,6 +103,13 @@ def _record_average_page_timings_from_uncached_session( | |||
|
|||
def _record_average_page_timings_from_cached_session( | |||
self, session_count=DEFAULT_SESSION_SAMPLE_COUNT): | |||
"""Record average page timings from cached session. |
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.
Records (for consistency).
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.
Done!
Minor fixes
…ppia into docstrings-backend
Minor fixes Merge branch 'docstrings-backend' of https://github.com/YashJipkate/oppia into docstrings-backend
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.
LGTM, thanks @YashJipkate! 👍
@vibhor98 Thanks for your time and guidance and the approval! |
@ankita240796 Thanks for your review!! |
Hi @apb7, Can you review this PR also being one of the code owners? Thanks! |
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.
Hi @YashJipkate, this looks good! Left a few comments. Also, can you please ensure that we do not cutoff any line before the 80 character limit? Thanks!
Returns: | ||
str. Empty if recipient_id is 'recipient_id2', | ||
None if 'recipient_id1' and 'Email Hash' | ||
otherwise. |
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.
Can we shift otherwise
to the above line without exceeding the 80 characters limit? If yes, then please go ahead and shift 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.
Done!
@@ -429,6 +430,7 @@ def _compute_snapshot(self): | |||
return self.to_dict(exclude=['created_on', 'last_updated']) | |||
|
|||
def _reconstitute(self, snapshot_dict): | |||
"""Populates the model instance with the snapshot.""" |
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.
Hi @vibhor98, don't we require Args
for snapshot_dict
here?
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.
Hi @apb7 I have added it for now; will remove if turns out to be unnecesary.
Also, I am skeptical about the way I wrote the return type. PTAL. Thanks!
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.
It's optional in test files. Else, we need to write them. @YashJipkate, thanks for adding them here!
self.data_fetcher.load_url(self.page_url) | ||
|
||
def _record_page_metrics_from_uncached_session(self): | ||
"""Records the page metrics from uncached session for a given page | ||
URL. |
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.
Can we move URL
to the above line as well?
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.
Actually it exceeds the limit in this case...
Thanks!
core/tests/performance_tests/base.py
Outdated
self.page_metrics = ( | ||
self.data_fetcher.get_page_metrics_from_uncached_session( | ||
self.page_url)) | ||
|
||
def _record_page_metrics_from_cached_session(self): | ||
"""Records the page metrics from cached session for a given page | ||
URL. |
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.
Ditto.
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.
@apb7 Done!!
core/tests/performance_tests/base.py
Outdated
Args: | ||
page_config: dict. The page configuration parameters. | ||
append_username: bool. Whether to append username to the | ||
page URL. |
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.
Ditto.
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.
@apb7 Done!!
…ppia into docstrings-backend
linting checks ~2 linting checks ~3
@apb7 just a gentle reminder. Kindly review. |
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.
LGTM, thanks @YashJipkate!
Hi @BenHenning, can you review this PR being one of the code owners? Thanks! |
Hi @BenHenning, just a gentle reminder. Kindly review. |
Hi @BenHenning, A reminder again. Kindly review. |
Hi @seanlip, can you review this PR once since you're one of the code owners? Thanks! |
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.
Hi @YashJipkate, thanks for this PR. Just a few comments but otherwise it looks great!
"""Get page load duration. | ||
|
||
Args: | ||
event_end: str. The event upto which duration measurement is |
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.
Nit: upto --> up to
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.
Done!
downstream_kbps: int. The downstream speed in kbps. Defaults to | ||
None. | ||
upstream_kbps: int. The upstream speed in kbps. Defaults to None. | ||
latency: int. The latency of the server. Defaults to None. |
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 what unit?
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.
It is in milliseconds.
Done!
latency: int. The latency of the server. Defaults to None. | ||
|
||
Returns: | ||
tuple(server, proxy): A tuple consisting of the server and the |
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 don't think "server" and "proxy" are the actual type names; ditto for "driver" below and throughout the remainder of this file. Could you please make sure the types are correct? For instances of classes it should be the class name (so, in this case, it should be Server for the first arg, since it's an instance of browsermobproxy.Server).
Don't just change everything to start with uppercase, though -- make sure to actually figure out what class it is an instance of. When resolving this comment, please also include (in your comment) a reference to where the driver class is defined.
Thanks!
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 driver class is defined as here
Changed Server type name and updated proxy type to dict.
PTAL. Thanks!
core/tests/test_utils.py
Outdated
headers: dict(str, *). Extra headers to send. | ||
|
||
Returns: | ||
webtest.TestResponse instance: The response of the |
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.
webtest.TestResponse. The response of the POST request.
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.
Done.
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.
LGTM. Thanks!
self, app, url, data, expect_errors=False, expected_status_int=200, | ||
upload_files=None, headers=None): | ||
"""Sends a post request with the data provided to the url specified. | ||
|
||
Args: |
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.
@nithusha21 @seanlip I just saw it is showing 140 changed files changed. I recently pulled the latest develop branch in my current |
Hi @YashJipkate, I think @apb7 is the person you'll need to talk to for both these issues. The pylint-disable statement should not be added; instead, please try to figure out why missing-param-doc is arising erroneously. If it works correctly for other functions but not for yours, then it might actually be a problem with your code. (In general, don't use pylint pragmas and other similar "escape hatches" to get out of understanding an issue.) For the 140 files changed, I think this is a dev workflow issue and that @apb7 or @nithusha21 might be able to advise. But, generally, if you follow the steps on the PR instructions page, I believe that this shouldn't happen. Note that @apb7 is currently travelling so you might want to try and take a stab at resolving these on your own first. For the second one it's fine to create a new PR from scratch if that is easier. |
Params: | ||
app: WSGI application. The WSGI application which receives the | ||
Args: | ||
app: TestApp. The WSGI application which receives the |
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.
@seanlip Thanks for your advice! Will keep that in mind next time!
Well thanks to you, I figured out the cause, it was caused since I named the type as WSGI Application
and pylint was not happy with the space in between the type. So I set the type to TestApp
which is the class as is clear from the piece of code here and also from the source code of TestApp
PTAL. Thanks!
@YashJipkate, the PR looks good, but I noticed you force pushed. We generally discourage that because it overwrites history and makes diffs between successive commits harder to review. Instead perhaps reverting the merge commit (or whatever caused all the new files to be added) might have been a better way to go -- though it might be a good idea to try and figure out how you got into this state in the first place, so that we can avoid this happening to other folks in the future. Otherwise, the PR looks good, except that it fails Travis lint checks. Did these not run locally on your machine before you pushed? Once the Travis checks are fixed, this is good to merge. Thanks! |
@seanlip Thanks for the info. I actually used |
OK, thanks. No worries. I'm a bit concerned, though, that this issue seems to be recurring repeatedly for you. If it happens in the future can you document exactly what steps you took locally and file a bug against the dev workflow team so that they can look into it? |
@seanlip Yeah sure I will keep that in mind the next time I encounter this type of issue. |
@YashJipkate, glad that you've figured out the above issues! Also, as Sean suggested, feel free to file an issue if you face any recurring problem. Thanks! |
@apb7 Sure. Thanks for your help! |
@seanlip The checks have passed. Please take a final look. |
LGTM. Thanks! |
Updated docstrings in Python Backend code for core.storage.base_model.gae_models_test, core.storage.base_model.gae_models, core.storage.user.gae_models, core.tests.test_utils, core.tests.performance_tests.base, core.tests.performance_framework.perf_services, core.tests.performance_framework.perf_domain, core.domain.summary_services, core.domain.email_jobs_one_off_test, core.domain.visualization_registry
Explanation
Fixes part of #4374
Checklist
python scripts/pre_commit_linter.py
andbash scripts/run_frontend_tests.sh
.