-
Notifications
You must be signed in to change notification settings - Fork 53
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
TASK-1229 - UPA handler API #1199
Conversation
… Narrative cells.
Changes Unknown when pulling e5557ff on briehl:copy-sharing-problem into ** on kbase:develop**. |
Caveats: I'm not qualified to review anything except the python changes. |
"1/2/a", | ||
"123/456/7/", | ||
"1/2/3;", | ||
"x/y/z" |
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.
Try some upas with ws & obj names, or just names alone, or just numbers alone, with and without refpaths.
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
|
||
self.bad_serials = list() | ||
for bad_upa in self.bad_upas: | ||
self.bad_serials.append(external_tag + bad_upa) |
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 about bracket serializations?
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
src/biokbase/narrative/upa.py
Outdated
""" | ||
|
||
import re | ||
from app_util import (system_variable) |
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.
No need for parens
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
src/biokbase/narrative/upa.py
Outdated
if upa.startswith(ws_id): | ||
return upa.replace(ws_id, "[{}]".format(ws_id), 1) | ||
else: | ||
return external_tag + upa |
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.
One thing that's a little worrisome is that this makes it easy for bugs to creep in by devs not being careful about their inputs. I'd almost want to split this into two methods - serialize_upa and serialize_external_upa to ensure the devs know exactly what they're doing when then serialize something.
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.
We talked about this a little bit, so just to record it here - the intent of this API is that it should be used by wrapping widgets and under-the-covers processes. Devs who write viewer widgets or apps will probably never interact with it.
But, you're right, we should be explicit. I'll make the change to split it.
@mock.patch('biokbase.narrative.upa.system_variable', mock_sys_var) | ||
def test_serialize_bad(self): | ||
for bad_upa in self.bad_upas: | ||
with self.assertRaises(ValueError): |
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.
Should check the error text is accurate
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
] | ||
for t in bad_types: | ||
with self.assertRaises(ValueError): | ||
deserialize(t) |
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.
same
del os.environ['KB_WORKSPACE_ID'] | ||
with self.assertRaises(RuntimeError): | ||
serialize("1/2/3") | ||
if tmp is not 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.
This should be in a finally block so that the env is always restored
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
del os.environ['KB_WORKSPACE_ID'] | ||
with self.assertRaises(RuntimeError): | ||
deserialize("[1]/2/3") | ||
if tmp is not 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.
same
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
if 'KB_WORKSPACE_ID' in os.environ: | ||
tmp = os.environ.get('KB_WORKSPACE_ID') | ||
del os.environ['KB_WORKSPACE_ID'] | ||
with self.assertRaises(RuntimeError): |
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.
Check error text
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
if 'KB_WORKSPACE_ID' in os.environ: | ||
tmp = os.environ.get('KB_WORKSPACE_ID') | ||
del os.environ['KB_WORKSPACE_ID'] | ||
with self.assertRaises(RuntimeError): |
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.
same
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
@briehl Looks like the kbase-extension/static/kbase/js/api/fileStaging.js file has changed, perhaps due to the new staging service? Otherwise I think its fine |
Yeah, that file got deleted and replaced with a different one. I'll catch this up with the develop branch and merge. |
This is mainly to prototype a solution for some parts of the copy/sharing problems. This first step will introduce an API for dealing with UPAs in the narrative. I think the following steps should be carefully done and tested before merging: