diff --git a/setup.py b/setup.py index 09f36631f..c9c28f824 100644 --- a/setup.py +++ b/setup.py @@ -57,7 +57,7 @@ def run(self): setup(name='citrine', - version='0.12.0', + version='0.12.1', url='http://github.com/CitrineInformatics/citrine-python', description='Python library for the Citrine Platform', author='Andrew Millspaugh', diff --git a/src/citrine/seeding/find_or_create.py b/src/citrine/seeding/find_or_create.py index 3126ea0dd..d0b6d6c9f 100644 --- a/src/citrine/seeding/find_or_create.py +++ b/src/citrine/seeding/find_or_create.py @@ -7,24 +7,16 @@ def find_collection(collection, name): Returns it, or if not found, returns None """ - i = 1 - per_page = 100 - result = None - while True: - collection_list = list(collection.list(page=i, per_page=per_page)) - if len(collection_list) == 0: - break - matching_resources = [resource for resource in collection_list if resource.name == name] - if len(matching_resources) > 0: - if result or len(matching_resources) > 1: - raise ValueError("Found multiple collections with name {}".format(name)) - else: - result = matching_resources.pop() - i += 1 - - if result: + collection_list = collection.list() + matching_resources = [resource for resource in collection_list if resource.name == name] + if len(matching_resources) > 1: + raise ValueError("Found multiple collections with name '{}'".format(name)) + if len(matching_resources) == 1: + result = matching_resources.pop() print('Found existing: {}'.format(result)) - return result + return result + else: + return None def get_by_name_or_create(collection, name, default_provider):