-
Notifications
You must be signed in to change notification settings - Fork 2.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
feat: remove separated workspace param #1722
Conversation
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.
maybe we need to remove pea_workspace
as well
Latency summaryCurrent PR yields:
Breakdown
Backed by latency-tracking. Further commits will update this comment. |
…move-separated-workspace-param # Conflicts: # daemon/api/endpoints/flow.py # jina/peapods/pods/__init__.py
Codecov Report
@@ Coverage Diff @@
## master #1722 +/- ##
===========================================
- Coverage 85.18% 74.48% -10.71%
===========================================
Files 134 134
Lines 6865 6878 +13
===========================================
- Hits 5848 5123 -725
- Misses 1017 1755 +738
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.
Not ready to be merged, we need to add some set of integration tests
208d55c
to
d73bd0a
Compare
2037d81
to
881d16b
Compare
881d16b
to
cb4e38d
Compare
""" Property to access `workspace` if existing or default to `./`. Useful to provide good interface when | ||
using executors directly in python. | ||
|
||
.. highlight:: python |
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 snippet doesn't seem relevant
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.
What would you change?
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'd remove it, right?
dismiss review but not approving as part of the ticket
…move-separated-workspace-param # Conflicts: # jina/parsers/peapods/pea.py
…move-separated-workspace-param # Conflicts: # tests/integration/incremental_indexing/test_incremental_indexing.py
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.
Good job, great refactoring. Just one point. I'd be happy to be convinced, that your implementation is better than my suggestion. :)
|
||
:return: returns the workspace property of the executor or default to './' | ||
""" | ||
return self.workspace or './' |
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 am totally surprised, that this works.
After digging around a little: Seems like I never thought about how boolean expressions work in python. I am totally surprised, that
a = 'a' or 'b'
=> a = 'a' (First `True` evaluated element)
a = 'a' and 'b'
=> a = 'b' (Last `True` evaluated element)
a = '' or 'b'
=> a = 'b' (First `True` evaluated element, which is the second one)
a = '' and 'b'
=> a = '' (First `False` evaluated element)
When you think how and
and or
are implemented (via __and__
and __or__
) this makes total sense. I am just amazed... A consequence is:
def my_func():
return 'haha'
if ['a'] and my_func():
....
breaks down to
if 'haha':
...
which is obviously True
.
jina/executors/__init__.py
Outdated
@staticmethod | ||
def get_shard_workspace(workspace_folder: str, workspace_name: str, pea_id: int) -> str: | ||
# TODO (Joan, Florian). We would prefer not to keep `pea_id` condition, but afraid many tests rely on this | ||
return os.path.join(workspace_folder, f'{workspace_name}-{pea_id}') if pea_id > 0 else os.path.join(workspace_folder) |
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.
couldn't it be just ... else workspace_folder
?
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.
And furthermore, if the whole line would just be
if pea_id < 0:
pea_id = 0
return os.path.join(workspace_folder, f'{workspace_name}-{pea_id}')
we might be able to heavily simplify the parsers, non? If we have shards, it makes total sense, that we have the pea_id
in the workspace name. But if we don't have shards but only one Pea
, it still makes total sense to add the pea_id
to the workspace name (in my opinion).
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.
couldn't it be just
... else workspace_folder
?
oh sure!!
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.
About the second point, I agree, but I was afraid that it would break current logic and a huge amount of tests, and thus we decided to keep it like this as in the TODO
is expressd
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.
Ah I should read the comments as well... That's why I almost never write comments: I also never read them :D
Fine I'll approve
Your suggestion is definitely better, we went conservative on the amount of things we would break |
I would suggest to give it a try in a different 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.
LGTM
Breaking Change #1606
related discussion:
#1720
Changes introduced
separate_workspace
pea_workspace
metaworkspace
metas default toNone
to allow understand the logic where the user does not explicitly provides a value. Useful to clarify workspace structure in the case ofCompoundExecutors
. (In CompoundExecutor, components will compute its workspace considering some logic on itsCompoundExecutor
continent.shard_workspace
property to be defined functionallydepending
on theworkspace
, thename
and thepea_id
.CompoundExecutor
root_workspace
androot_name
to set toroot
executor needed forCompoundExecutor
andref_indexer
.workspaces
(Single, with Compound, with Compound but with specific workspace for itscomponents
, withref_indexer
, withref_indexer
inside aCompound
complete_path
to finduses_internal
resource tobind
intodocker
when spinning apea
in acontainer