-
-
Notifications
You must be signed in to change notification settings - Fork 42
Orange ImageAnalytics client updated to repeat sending images when request not successful #66
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
d486b86
Image embedder client repeats sending request to server when not succ…
PrimozGodec d6f33eb
Skipped images that are not loaded for future resending
PrimozGodec 170f033
Updated advance function to advance only when successful
PrimozGodec 3a7e746
Number of repeats of sending image to the server set to 4
PrimozGodec fcd99f4
Registered new embedders
PrimozGodec 941af93
Url changed to new service
PrimozGodec 8ca4fc7
Temporary fix for hyper library
PrimozGodec 230e5fb
Changed embedders order and default
PrimozGodec f20514e
Cancel button always on just disabled when no actual.
PrimozGodec b247052
Local fix for hyper updated to hyper fix
PrimozGodec File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| # -*- coding: utf-8 -*- | ||
| """ | ||
| Temporary fix for hyper library until next version from 0.7.0 is out | ||
| """ | ||
| import logging | ||
|
|
||
| log = logging.getLogger(__name__) | ||
|
|
||
| # Define the largest chunk of data we'll send in one go. Realistically, we | ||
| # should take the MSS into account but that's pretty dull, so let's just say | ||
| # 1kB and call it a day. | ||
| MAX_CHUNK = 1024 | ||
|
|
||
|
|
||
| class Stream(object): | ||
|
|
||
| def send_data(self, data, final): | ||
| """ | ||
| Send some data on the stream. If this is the end of the data to be | ||
| sent, the ``final`` flag _must_ be set to True. If no data is to be | ||
| sent, set ``data`` to ``None``. | ||
| """ | ||
| # Define a utility iterator for file objects. | ||
| def file_iterator(fobj): | ||
| while True: | ||
| data = fobj.read(MAX_CHUNK) | ||
| yield data | ||
| if len(data) < MAX_CHUNK: | ||
| break | ||
|
|
||
| # Build the appropriate iterator for the data, in chunks of CHUNK_SIZE. | ||
| if hasattr(data, 'read'): | ||
| chunks = file_iterator(data) | ||
| else: | ||
| chunks = (data[i:i+MAX_CHUNK] | ||
| for i in range(0, len(data), MAX_CHUNK)) | ||
|
|
||
| # since we need to know when we have a last package we need to know | ||
| # if there is another package in advance | ||
| cur_chunk = None | ||
| try: | ||
| cur_chunk = next(chunks) | ||
| while True: | ||
| next_chunk = next(chunks) | ||
| self._send_chunk(cur_chunk, False) | ||
| cur_chunk = next_chunk | ||
| except StopIteration: | ||
| if cur_chunk is not None: # cur_chunk none when no chunks to send | ||
| self._send_chunk(cur_chunk, final) | ||
|
|
||
|
|
||
| def _send_chunk(self, data, final): | ||
| """ | ||
| Implements most of the sending logic. | ||
| Takes a single chunk of size at most MAX_CHUNK, wraps it in a frame and | ||
| sends it. Optionally sets the END_STREAM flag if this is the last chunk | ||
| (determined by being of size less than MAX_CHUNK) and no more data is | ||
| to be sent. | ||
| """ | ||
| # If we don't fit in the connection window, try popping frames off the | ||
| # connection in hope that one might be a window update frame. | ||
| while len(data) > self._out_flow_control_window: | ||
| self._recv_cb() | ||
|
|
||
| # Send the frame and decrement the flow control window. | ||
| with self._conn as conn: | ||
| conn.send_data( | ||
| stream_id=self.stream_id, data=data, end_stream=final | ||
| ) | ||
| self._send_outstanding_data() | ||
|
|
||
| if final: | ||
| self.local_closed = True | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| hyper==0.7.0 | ||
| hyper>=0.7.0 | ||
| numpy>=1.10.0 | ||
| Orange3>=3.3.5 | ||
| Pillow>=2.7.0 | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 file is under MIT license from hyper.
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.
Another thing to consider: development branch of hyper has a lot of new commits after the last version 0.7.0 (see python-hyper/hyper@v0.7.0...development). You are fixing just one bug. Maybe it would be better to base our usage on development branch and not on 0.7.0?
In the mean time, as we're waiting for upstream to merge python-hyper/hyper#356, we can use in requirements.txt your fixed branch
e.g.
pip install git+https://github.com/PrimozGodec/hyper@d8ed47aadbc1b66e8493726beeffcf0361ae8729
We switch to the upstream's version as soon the fix is merged. And nudge Lukasa to make another official version ;)
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.
If we plan to release a version of image-analytics add-on with this fix, I would rather have it base on a released version of the hyper package.
Otherwise, we are installing development version of hyper package into users environment, If we distribute over conda, we need to make sure hyper-devel builds are available, ...
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.
Ok if we are waiting for new release do I use my fixed branch anyway or leave as it 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.
@astaric I am not sure if we want to wait until next release. Hyper had a last release 0.7.0 more than one year ago. What means that releases are not so frequent. Is there any other solution since we are in hurry in margin this?
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 agree. I've asked to make e new release, but I don't know when it will be done. We can wait few days. Otherwise, we can just use a fixed commit ID in hyper and upgrade later?
git+https://github.com/Lukasa/hyper@a8109c3aaf8e2aa7314f23bf46e20af2bc241cd7
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.
Feel free to use git+... in requirements and merge this PR.
But please do not create a (pypi) release that depends on development versions of packages.