Skip to content

Commit

Permalink
Merge branch 'feature/copy_only_bulk_export' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Filip Tubic committed Nov 22, 2018
2 parents 44a0948 + b0b434f commit 24d6291
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 14 deletions.
9 changes: 9 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
0.17.1 (2018-11-22)
==================

- Improvements:
- Added copy_only parameter to bulk exports
- Bugfixes:
- [Issue #107](https://github.com/sbg/sevenbridges-python/issues/107)
- Removed unnecessary configuration check

0.17.0 (2018-10-30)
==================

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.17.0
0.17.1
2 changes: 1 addition & 1 deletion docs/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1482,7 +1482,7 @@ data for each job, for example:
'overwrite': False
},
]
response = api.exports.bulk_submit(exports=exports)
response = api.exports.bulk_submit(exports=exports, copy_only=False)
Managing automations
Expand Down
2 changes: 1 addition & 1 deletion sevenbridges/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import ssl
import logging

__version__ = "0.17.0"
__version__ = "0.17.1"

from sevenbridges.api import Api
from sevenbridges.config import Config
Expand Down
5 changes: 0 additions & 5 deletions sevenbridges/meta/resource.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import os
import copy
import logging

import six

from sevenbridges.errors import SbgError
from sevenbridges.http.client import HttpClient
from sevenbridges.meta.data import DataContainer
from sevenbridges.meta.fields import Field
from sevenbridges.meta.transformer import Transform
Expand Down Expand Up @@ -98,9 +96,6 @@ def deepcopy(self):
return type.__new__(mcs, name, bases, dct)

def __get__(cls, obj, objtype=None):
# SPHINX_DOC part is for generating documentation
if not isinstance(obj, HttpClient) and not os.environ['SPHINX_DOC']:
raise SbgError(message='Improperly configured client!')
if obj is None:
return cls
cls._API = obj
Expand Down
8 changes: 6 additions & 2 deletions sevenbridges/models/storage_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,11 @@ def bulk_get(cls, exports, api=None):
return ExportBulkRecord.parse_records(response=response, api=api)

@classmethod
def bulk_submit(cls, exports, api=None):
def bulk_submit(cls, exports, copy_only=False, api=None):
"""
Create exports in bulk.
:param exports: Exports to be submitted in bulk.
:param copy_only: If true files are kept on SevenBridges bucket.
:param api: Api instance.
:return: list of ExportBulkRecord objects.
"""
Expand Down Expand Up @@ -193,8 +194,11 @@ def bulk_submit(cls, exports, api=None):
items.append(item)

data = {'items': items}
params = {'copy_only': copy_only}

response = api.post(url=cls._URL['bulk_create'], data=data)
response = api.post(
url=cls._URL['bulk_create'], params=params, data=data
)
return ExportBulkRecord.parse_records(response=response, api=api)


Expand Down
8 changes: 5 additions & 3 deletions sevenbridges/tests/test_exports.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import faker
import pytest

generator = faker.Factory.create()

Expand Down Expand Up @@ -49,7 +50,8 @@ def test_exports_bulk_get(api, given, verifier):
verifier.exports.bulk_retrieved()


def test_exports_bulk_submit(api, given, verifier):
@pytest.mark.parametrize('copy_only', [True, False])
def test_exports_bulk_submit(api, given, verifier, copy_only):
# preconditions
total = 10

Expand All @@ -66,8 +68,8 @@ def test_exports_bulk_submit(api, given, verifier):
given.exports.can_be_submitted_in_bulk(exports)

# action
response = api.exports.bulk_submit(exports)
response = api.exports.bulk_submit(exports, copy_only=copy_only)

# verification
assert len(response) == total
verifier.exports.bulk_submitted()
verifier.exports.bulk_submitted(copy_only)
4 changes: 3 additions & 1 deletion sevenbridges/tests/verifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,10 @@ def submitted(self):
def bulk_retrieved(self):
self.checker.check_url('/bulk/storage/exports/get')

def bulk_submitted(self):
def bulk_submitted(self, copy_only=False):
qs = {'copy_only': [str(copy_only)]}
self.checker.check_url('/bulk/storage/exports/create')
self.checker.check_query(qs)


class DatasetVerifier(object):
Expand Down

0 comments on commit 24d6291

Please sign in to comment.