-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Added docstring to "core.domain.exp_services" #2924
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #2924 +/- ##
===========================================
- Coverage 46.38% 46.14% -0.25%
===========================================
Files 226 228 +2
Lines 17705 17919 +214
Branches 2871 2883 +12
===========================================
+ Hits 8213 8268 +55
- Misses 9492 9651 +159
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 @DubeySandeep -- I think there might be a misunderstanding about the starting point for this PR. The idea was to start from develop, make the changes that have already been made in this PR, and apply the remaining open comments to get the new PR to a final stage where it can be merged. By starting from square one, you lose all the improvements that were made in the other PR, so I suggest not doing this.
core/domain/exp_services.py
Outdated
@@ -78,7 +78,7 @@ def _migrate_states_schema(versioned_exploration_states): | |||
|
|||
Args: | |||
versioned_exploration_states: A dict with two keys: | |||
- states_schema_version: the states schema version for the | |||
- states_schema_version: Int. the states schema version for 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.
int, not Int
core/domain/exp_services.py
Outdated
@@ -104,17 +104,21 @@ def _migrate_states_schema(versioned_exploration_states): | |||
|
|||
# Repository GET methods. | |||
def _get_exploration_memcache_key(exploration_id, version=None): | |||
"""Returns a memcache key for an exploration.""" | |||
""" |
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.
Missing one-line summary at top of docstring?
core/domain/exp_services.py
Outdated
"""Returns a memcache key for an exploration.""" | ||
""" | ||
Args: | ||
- exploration_id: str. The exploration id. |
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.
Follow format in other files -- there should be no hyphens.
core/domain/exp_services.py
Outdated
Args: | ||
- exploration_id: str. The exploration id. | ||
- version: int. Version of the exploration , default value None. | ||
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.
Follow format in other files -- there should be a blank line above this one.
Also, I'm going to stop reviewing here. Please see my general comment -- I think there might be a misunderstanding of what needs to be done 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.
I guess you mean to say, i should start working on "develop" branch and make the changes which were asked in the previous PR.
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.
Yes, that's what I meant -- no need to reinvent the wheel :)
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.
Okay! I'm working :) gonna make PR tonight .
Hi @DubeySandeep, have you had a chance to look into this? |
@DubeySandeep Are you still working on this ? |
I'm done with all the changes which were asked in the PR 2452 but still, I'm going through the docstring as I found it requires some more changes, anyhow I'll make a PR tonight. Thanks. @526avijitgupta |
Hi @DubeySandeep, this seems to be dragging on a bit. Any updates? Thanks! |
Reassigning to @kevintab95 for first review pass. |
Sorry, but I have made the PR with all the changes which were asked in the previous one. It was late because I am new at git so last week while fetching data from upstream, I changed my working branch to "develop" without making any commit in the previous branch and lost my entire work and then I repeated the same work again. :( |
core/domain/exp_services.py
Outdated
|
||
Args: | ||
committer_id: str. The id of the user who made the commit. | ||
exploration: exploration. The exploration domain object. |
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.
Use 'Exploration' not 'exploration' here because you've used it everywhere else.
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.
Okay! 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.
(Also, note that the reason we use Exploration is because that's what you get when you do type(...)
on the argument. It refers to the Exploration class defined in exp_domain.py.)
core/domain/exp_services.py
Outdated
|
||
Args: | ||
exp_summary: ExplorationSummary. An ExplorationSummary domain object. | ||
user_id: str. ID of the user whose permissions are being checked. |
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 noticed that you used 'ID' in some places an 'id' in others, can you change them all to just 'id' for consistency? 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.
That were written/used by the one who has made the last PR 2452 and that weren't marked for changes so, I left those as they were, but now I'll change them for sure. :)
@DubeySandeep I've left some comments, please make the changes. 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.
This looks pretty good, IMO! I just had a few comments, but hopefully they're easy to address.
core/domain/exp_services.py
Outdated
Returns: | ||
ExplorationSummary. The summary domain object corresponding to the | ||
given exploration. | ||
|
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.
Drop extra newline.
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/domain/exp_services.py
Outdated
|
||
Args: | ||
exp_ids: list(str). A list of exploration ids of exploration domain | ||
objects. |
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.
indent this by 4
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! :)
mistaken* :p
core/domain/exp_services.py
Outdated
exploration is exported. | ||
|
||
Returns: | ||
zipfile. A ZIP archive of the exploration. |
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.
Did you check the type here (by trying to trigger execution of this function)? Is it a zipfile.ZipFile or a str?
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.
LOG core.domain.exp_services_test.ZipFileExportUnitTests.test_export_to_zip_file:
<type 'str'>
test_export_to_zip_file (core.domain.exp_services_test.ZipFileExportUnitTests)
So overall this returns 'str' which is then converted into zip via zipfile.ZipFile(StringIO.StringIO(zip_file_output)) which is a zip file. Learnt a lot :) 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.
which one would be better?
str. The archive of the exploration.
OR
str. The archive of the exploration which is then converted into zip via zipfile.ZipFile().
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.
str. The contents of the ZIP archive of the exploration (which can be subsequently converted into a zip file via zipfile.ZipFile()).
Note how this docstring does not say anything about what is actually done with the return value, so that the outside context does not "leak into" the function, but it provides context around how the return value could be used by clients (and this acts as a sort of spec for the person writing or modifying code within this function).
core/domain/exp_services.py
Outdated
|
||
Args: | ||
committer_id: str. The id of the user who made the commit. | ||
exploration: exploration. The exploration domain object. |
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, note that the reason we use Exploration is because that's what you get when you do type(...)
on the argument. It refers to the Exploration class defined in exp_domain.py.)
core/domain/exp_services.py
Outdated
|
||
Returns: | ||
tuple. A 2-tuple consisting of: | ||
-list(ExplorationCommitLogEntry). A list containing |
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.
Add a space after each starting hyphen.
core/domain/exp_services.py
Outdated
Returns: | ||
tuple. A 2-tuple consisting of: | ||
-list(ExplorationCommitLogEntry). A list containing | ||
ExplorationCommitlogEntry domain object |
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.
domain objects. (note final 's' and full stop).
That said, this doesn't add any info that's not contained in the type at the beginning. Can you have the docstring explain the significance of the return value? E.g. A list of commit log entries corresponding to the given query.
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!
while going through the return value I came to know that this function returns a 3-tuple the last one is a bool which indicates whether there left any more results after this packet or not. added
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.
even in docstring tuple was misspelled with triple The return value is a triple* Done! :) Thanks.
core/domain/exp_services.py
Outdated
of the exploration. | ||
|
||
Returns: | ||
dict. |
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.
Add some info about what this dict is used for; what's its context? If I want to add stuff to this dict in the future, for example, what do I need to bear in mind?
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 great! 3 more small things, and then it's ready to merge.
core/domain/exp_services.py
Outdated
@@ -1490,12 +1497,15 @@ def get_next_page_of_all_non_private_commits( | |||
|
|||
def _exp_rights_to_search_dict(rights): | |||
# Allow searches like "is:featured". | |||
""" | |||
"""Returns a search dict with information about the exploration rights. This | |||
allows searches like "is:featured". | |||
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.
missing newline above this one
core/domain/exp_services.py
Outdated
Args: | ||
rights: ActivityRights. Domain object for the rights/publication status | ||
of the exploration. | ||
|
||
Returns: | ||
dict. If the status of the given exploration is publicized then 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.
nit: remove space after "dict."
core/domain/exp_services.py
Outdated
Args: | ||
rights: ActivityRights. Domain object for the rights/publication status | ||
of the exploration. | ||
|
||
Returns: | ||
dict. If the status of the given exploration is publicized then it | ||
returns a dict with a key "is" and value as "featured" else an empty |
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.
... with a key "is", and the value "featured". Otherwise, it returns an empty dict.
LGTM, great work @DubeySandeep! :) |
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, @DubeySandeep -- LGTM!
Also, one request for the future: please could you make sure to reply to all comments, following the instructions in step 5 here? In particular, for comments that you've addressed, please reply "Done." -- this helps keep track of which comments have been addressed and which haven't. Thanks!
Sorry, but I thought of not disturbing you all with such silly changes, but now I come to know how much it's important to reply to all comments. I'll do if for sure from next time. :) |
Yes, sounds good! Just make sure that your other branch is based off of the latest version of develop -- it's easier if you're working at HEAD, since it reduces the chance of merge conflicts later. |
Fix #2394: Add useful docstring to "core/domain/exp_services.py"