Skip to content

Commit

Permalink
Update .gitignore and add parameters to Database.create_collection
Browse files Browse the repository at this point in the history
  • Loading branch information
joowani committed May 16, 2018
1 parent 7ff6f2d commit 0827a3e
Show file tree
Hide file tree
Showing 5 changed files with 147 additions and 26 deletions.
122 changes: 110 additions & 12 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,110 @@
*.pyc
*.pyo
*.idea
*.egg-info
*build/
*dist/
*htmlcov/
*.coverage
.cache/
tests/__pycache__/
*.DS_Store
venv
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/

# MacOS
.DS_Store

# PyCharm
.idea/
8 changes: 4 additions & 4 deletions arango/aql.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,14 +230,14 @@ def execute(self,
:type intermediate_commit_size: int
:param satellite_sync_wait: Number of seconds in which the server must
synchronize the satellite collections involved in the query. When
the threshold is reached, the query is stopped. This parameter is
for enterprise version of ArangoDB only.
the threshold is reached, the query is stopped. Applies only to
enterprise version of ArangoDB.
:type satellite_sync_wait: int | float
:param read_collections: Names of collections read during query
execution. This parameter is required for transactions only.
execution. Required for :doc:`transactions <transaction>`.
:type read_collections: [str | unicode]
:param write_collections: Names of collections written to during query
execution. This parameter is required for transactions only.
execution. Required for :doc:`transactions <transaction>`.
:type write_collections: [str | unicode]
:return: Result cursor.
:rtype: arango.cursor.Cursor
Expand Down
36 changes: 28 additions & 8 deletions arango/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,10 @@ def create_collection(self,
shard_fields=None,
shard_count=None,
index_bucket_count=None,
replication_factor=None):
replication_factor=None,
shard_like=None,
sync_replication=None,
enforce_replication_factor=None):
"""Create a new collection.
:param name: Collection name.
Expand Down Expand Up @@ -863,6 +866,19 @@ def create_collection(self,
every write to the master is copied to all slaves before operation
is reported successful).
:type replication_factor: int
:param shard_like: Name of prototype collection whose sharding
specifics are imitated. Prototype collections cannot be dropped
before imitating collections. Applies to enterprise version of
ArangoDB only.
:type shard_like: str | unicode
:param sync_replication: If set to True, server reports success only
when collection is created in all replicas. You can set this to
False for faster server response, and if full replication is not a
concern.
:type sync_replication: bool
:param enforce_replication_factor: Check if there are enough replicas
available at creation time, or halt the operation.
:type enforce_replication_factor: bool
:return: Standard collection API wrapper.
:rtype: arango.collection.StandardCollection
:raise arango.exceptions.CollectionCreateError: If create fails.
Expand All @@ -879,14 +895,9 @@ def create_collection(self,
'doCompact': compact,
'isSystem': system,
'isVolatile': volatile,
'keyOptions': key_options
'keyOptions': key_options,
'type': 3 if edge else 2
}

if edge:
data['type'] = 3
else:
data['type'] = 2

if journal_size is not None:
data['journalSize'] = journal_size
if shard_count is not None:
Expand All @@ -897,10 +908,19 @@ def create_collection(self,
data['indexBuckets'] = index_bucket_count
if replication_factor is not None:
data['replicationFactor'] = replication_factor
if shard_like is not None:
data['distributeShardsLike'] = shard_like

params = {}
if sync_replication is not None:
params['waitForSyncReplication'] = sync_replication
if enforce_replication_factor is not None:
params['enforceReplicationFactor'] = enforce_replication_factor

request = Request(
method='post',
endpoint='/_api/collection',
params=params,
data=data
)

Expand Down
2 changes: 1 addition & 1 deletion arango/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '4.0.1'
__version__ = '4.1.0'
5 changes: 4 additions & 1 deletion tests/test_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,10 @@ def test_collection_management(db, bad_db):
shard_count=2,
shard_fields=['test_attr'],
index_bucket_count=10,
replication_factor=1
replication_factor=1,
shard_like='',
sync_replication=False,
enforce_replication_factor=False
)
assert db.has_collection(col_name) is True

Expand Down

0 comments on commit 0827a3e

Please sign in to comment.