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

Scoped object search #373

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 25 additions & 6 deletions solvebio/resource/object.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,20 +406,39 @@ def _object_list_helper(self, **params):
items = self.all(client=self._client, **params)
return items

def files(self, **params):
def files(self, query='', **params):
if query:
params['query'] = query
params.pop('object_type', None)
return self._object_list_helper(object_type='file', **params)

def folders(self, **params):
def folders(self, query='', **params):
if query:
params['query'] = query
params.pop('object_type', None)
return self._object_list_helper(object_type='folder', **params)

def datasets(self, **params):
def datasets(self, query='', **params):
if query:
params['query'] = query
params.pop('object_type', None)
return self._object_list_helper(object_type='dataset', **params)

def objects(self, **params):
def objects(self, query='', **params):
if query:
params['query'] = query
return self._object_list_helper(**params)

def ls(self, **params):
return self.objects(**params)
def ls(self, query='', **params):
query = query or params.pop('query', '')
return self.objects(query=query, **params)

def search(self, query='', **params):
query = query or params.pop('query', '')
Copy link
Member

Choose a reason for hiding this comment

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

This is not necessary

# TODO
params['ancestor_id'] = self.id
params['limit'] = 1000
return super(Object, self).search(query, **params)
Copy link
Contributor Author

@jsh2134 jsh2134 Dec 1, 2020

Choose a reason for hiding this comment

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

I believe I left this TODO in here in order to determine if there should be a recursive option. Should the user be able to get anything in this folder, or just depth=0 objects.

and/or ancestor_id needs to be replaced by parent_object_id (although the server may handle this)

This PR needs tests

Copy link
Member

Choose a reason for hiding this comment

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

Lets keep it ancestor_id so that it is recursive. Users can pass depth=0 if they want, and we will document this.

Copy link
Member

Choose a reason for hiding this comment

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

Object.search(), super not necessary because search is a classmethod


def __getattr__(self, name):
"""Shortcut to access attributes of the underlying Dataset resource"""
Expand Down