Skip to content
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

Merged
merged 18 commits into from
Nov 9, 2017
Merged

Conversation

briehl
Copy link
Member

@briehl briehl commented Oct 31, 2017

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:

  • Add an UPA API in Javascript
  • Test it
  • Add an UPA API in Python
  • Test it

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.006%) to 12.212% when pulling fd43c9a on briehl:copy-sharing-problem into f6f57e3 on kbase:develop.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.001%) to 12.216% when pulling 2cc03da on briehl:copy-sharing-problem into f6f57e3 on kbase:develop.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.001%) to 12.216% when pulling 58db396 on briehl:copy-sharing-problem into f6f57e3 on kbase:develop.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling e5557ff on briehl:copy-sharing-problem into ** on kbase:develop**.

@briehl briehl changed the title [WIP] First steps for copy sharing problem TASK-1229 - UPA handler API Nov 3, 2017
@coveralls
Copy link

Coverage Status

Coverage increased (+0.04%) to 12.254% when pulling d9dec65 on briehl:copy-sharing-problem into ca1a111 on kbase:develop.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.08%) to 12.292% when pulling 99007c5 on briehl:copy-sharing-problem into a6b9c0b on kbase:develop.

@MrCreosote
Copy link
Member

Caveats: I'm not qualified to review anything except the python changes.

"1/2/a",
"123/456/7/",
"1/2/3;",
"x/y/z"
Copy link
Member

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.

Copy link
Member Author

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about bracket serializations?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

"""

import re
from app_util import (system_variable)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for parens

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

if upa.startswith(ws_id):
return upa.replace(ws_id, "[{}]".format(ws_id), 1)
else:
return external_tag + upa
Copy link
Member

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.

Copy link
Member Author

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):
Copy link
Member

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

Copy link
Member Author

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)
Copy link
Member

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:
Copy link
Member

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

Copy link
Member Author

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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

Copy link
Member Author

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):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check error text

Copy link
Member Author

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):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@coveralls
Copy link

Coverage Status

Coverage increased (+0.08%) to 12.292% when pulling b0bcb0c on briehl:copy-sharing-problem into a6b9c0b on kbase:develop.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.08%) to 12.292% when pulling 5641eff on briehl:copy-sharing-problem into a6b9c0b on kbase:develop.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 12.309% when pulling 1d7f815 on briehl:copy-sharing-problem into a6b9c0b on kbase:develop.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 12.309% when pulling 99a3552 on briehl:copy-sharing-problem into a6b9c0b on kbase:develop.

@sychan
Copy link
Contributor

sychan commented Nov 9, 2017

@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

@briehl
Copy link
Member Author

briehl commented Nov 9, 2017

Yeah, that file got deleted and replaced with a different one. I'll catch this up with the develop branch and merge.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 12.311% when pulling a959379 on briehl:copy-sharing-problem into f6ec7b4 on kbase:develop.

@briehl briehl merged commit 6b4a466 into kbase:develop Nov 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants