-
Notifications
You must be signed in to change notification settings - Fork 11
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
watcher keep alive even get 304 not modified #36
Conversation
Good point. It is possible. We can use a loop instead of recursion to avoid stack overflow. def _schedule_watch(self, num_attempts_so_far: int) -> None:
while num_attempts_so_far >= 0:
if num_attempts_so_far == 0:
delay = _DELAY_ON_SUCCESS_MILLIS if self._latest is None else 0
else:
delay = self._next_delay_millis(num_attempts_so_far)
time.sleep(delay / 1000)
num_attempts_so_far = self._watch(num_attempts_so_far)
def _watch(self, num_attempts_so_far: int) -> int:
if self._is_stopped():
return -1
...
// return 0 to watch again
// return num_attempts_so_far + 1 in case a error occur Are you interested in fixing it as well? |
Sure! Thank you for your suggestion. I just updated the code based on your suggestion with some test code. Please take a look the commit |
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, @doubleknd26!
I'm looking forward to more feedback on centraldogma-python
😉
Codecov Report
@@ Coverage Diff @@
## main #36 +/- ##
==========================================
+ Coverage 93.44% 93.74% +0.29%
==========================================
Files 23 23
Lines 702 703 +1
==========================================
+ Hits 656 659 +3
+ Misses 46 44 -2
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
The permission to merge is granted to the maintainers of this project. It is normal that you can't merge this PR. |
@syleeeee Do you mind adding CLA assistant bot to this repository? 😄 |
Oh I see. Thanks for the detail :) |
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 for your contribution. Please check comments.
tests/test_repository_watcher.py
Outdated
|
||
|
||
def create_watcher(): | ||
return RepositoryWatcher( |
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.
Changing AbstractWatcher._schedule_watch()
affects not only RepositoryWatcher
but also FileWatcher
. It would be better to add tests at the same time. Furthermore, integration test seems proper to replay the case you reported.
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.
Added tests for FileWatcher.
I tried implements integration test for my case, but I faced that the dogma client returns either timeout exception or response 304 NOT_MODIFIED. Because the timeout exception is not related to the case I reported, I'm not sure the integration test can fully cover it. Nevertheless, I have thought about the integration test code like below. WDYT?
def test_not_modified_repository_watcher(self, run_around_test):
timeout_millis = 1000
# we need to pass timeout_millis as a parameter.
watcher: Watcher[Revision] = dogma.repository_watcher(
project_name, repo_name, "/**", timeout_millis
)
# wait until watcher get NOT_MODIFIED at least one.
time.sleep(5 * timeout_millis / 1000)
commit = Commit("Upsert modify.txt")
upsert_text = Change("/path/modify.txt", ChangeType.UPSERT_TEXT, "modified")
result = dogma.push(project_name, repo_name, commit, [upsert_text])
assert result.revision == watcher.latest.revision.major
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.
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.
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.
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 integration test code sounds good to me.
By the way, the code suggestion left above does not seem to be correctly applied.
// return 0 to watch again
// return num_attempts_so_far + 1 in case a error occur
@doubleknd26 Could you sign the CLA, please? |
8fc46cf
to
b69ff86
Compare
Done. Thanks! |
Mostly LGTM 🎉 Please check broken tests. |
Thanks for your comment! I fixed your point and confirmed it works in my forked repo. I hope it works well in here too. |
result = dogma.push(project_name, repo_name, commit, [upsert_text]) | ||
|
||
# wait until watcher watch latest. | ||
time.sleep(4 * timeout_second) |
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.
👍
Co-authored-by: Seunggon Kim <[email protected]>
Co-authored-by: Seunggon Kim <[email protected]>
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 a lot! @doubleknd26 🚀❤️
Please check the lint failure which might be caused by applying suggestions in the comments. |
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 a lot!
@syleeeee Could you check why CLA is pending? |
I didn't sign which blocks the CLA. 😱 |
@minwoox Would you like to review more? |
Hi all! I'm really happy to see this project. I'm working on some python project and it use central dogma so this is what I really want! I've test it in my project and I've found the repository watcher is dead after 304 response.
I think it because here. new_latest revision is None when 304 returned so schedule_watch is not triggered. So I moved schedule_watch out from if statement. Could you please check if it makes sense to you? I worried about stackeoverflow but, focused on keeping alive watcher for now.
I look forward to your reply. Thanks!
p.s 저는 한국 개발자입니다. 컨텍스트 공유를 위해 영어로 작성해봤어요. 수고에 진심으로 감사드립니다 :)