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

Enable empty path dx:// for DXPath initialization #113

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

anujkumar93
Copy link
Collaborator

@jtratner CC @pkaleta

Background

This PR enables initialization of dx:// as a DXPath. We want to allow initialization of dx:// to be able to call listdir on it and see the projects the user has access to. stor ls dx:// will list such projects.

Changes

  • Changed DXPath initialization logic in utils to provision for dx://
  • Handled logic in all DXPath function to allow for dx://
  • Added tests for dx:// for all DXPath functions

Other unrelated tiny changes in this PR:

  • Added splitpath in DXPath. Had moved it earlier to individual subclasses but needed a declaration in DXPath too
  • Added my name to AUTHORS :)

Copy link
Contributor

@jtratner jtratner left a comment

Choose a reason for hiding this comment

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

This is definitely the right direction, but I'm not convinced of the rationale to drop support for list, walkfiles, glob, etc. (particularly for glob).

Also I think this needs to have some documentation notes about the behavior included so that users know how to use it.

Either would be helpful to write out rationale here or we can discuss independently and then migrate to notes here.

Left some comments about requested changes for error messages and a few additional test cases.

stor/dx.py Outdated Show resolved Hide resolved
'level': 'VIEW',
'explicit_perms': True
}
projects_generator = dxpy.find_projects(**kwargs)
Copy link
Contributor

Choose a reason for hiding this comment

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

will this find public projects too?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This will only list those public projects where the user was specifically given permission. So, if Myriad_Demo was a public project, it would show that in the list (because we were specifically invited into it) and won't show all other public projects.

stor/dx.py Outdated Show resolved Hide resolved
uri: https://api.dnanexus.com/system/findProjects
response:
body:
string: !!python/unicode '{"results":[{"id":"project-FXFPP6801YyXv3Q32v06xKyz","level":"ADMINISTER","permissionSources":["user-akumar_counsyl"],"public":false}],"next":null}'
Copy link
Contributor

Choose a reason for hiding this comment

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

why does this only end up returning one project? Also shouldn't this be returning project name too?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This call is a result of 'dest.canonical_project[here](https://github.com/counsyl/stor/blob/master/stor/dx.py#L614). We call_clonetreeand_movetreeinTestCopyTree.test_empty_path. If it was reversed to self.canonical_project == dest.canonical_project`, we'd not be making that dx call.

stor/dx.py Outdated Show resolved Hide resolved
stor/tests/test_dx_path_compat.py Show resolved Hide resolved
stor/tests/test_dx.py Outdated Show resolved Hide resolved
stor/tests/test_dx.py Show resolved Hide resolved
@@ -769,6 +844,11 @@ def test_stat_canonical_resource(self):


class TestExists(DXTestCase):
def test_empty_path(self):
dx_p = DXPath('dx://')
with pytest.raises(NotImplementedError):
Copy link
Contributor

Choose a reason for hiding this comment

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

NotImplementedError doesn't make sense. Perhaps this should always return True? Are there other cases where exists() causes an error?

Copy link
Collaborator Author

@anujkumar93 anujkumar93 Apr 14, 2019

Choose a reason for hiding this comment

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

Fixed this to return True. exists() doesn't error anywhere else. Although I don't know if it makes sense to call exists on dx://. Sounds like something the user is doing by mistake and should be notified of?

Copy link
Contributor

Choose a reason for hiding this comment

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

can imagine it with things like:

real_paths = [f.exists() for f in paths] or something

Copy link
Collaborator Author

@anujkumar93 anujkumar93 May 14, 2019

Choose a reason for hiding this comment

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

Gotcha. The code snippet above is outdated. This is currently fixed.

def test_empty_path(self):
dx_p = DXPath('dx://')
with pytest.raises(ValueError, match='not supported'):
dx_p.glob('*')
Copy link
Contributor

Choose a reason for hiding this comment

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

wouldn't the glob apply to project names generated?

Copy link
Collaborator Author

@anujkumar93 anujkumar93 Apr 14, 2019

Choose a reason for hiding this comment

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

Glob is implemented internally as walkfiles. Meaning it only finds the files within the path. So for consistency, ideally we should be finding all the files a user has access to across projects and returning the ones that match the glob pattern. Leaving it as not implemented for now.

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.

2 participants