Skip to content

Commit e88838a

Browse files
author
Chris Turner
committed
Merge remote-tracking branch 'upstream/master' into issue-666
2 parents a3b7c65 + bd36d08 commit e88838a

22 files changed

+111
-49
lines changed

LNX-docker-compose.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,27 @@ services:
1919
- MINIO_ACCESS_KEY=datajoint
2020
- MINIO_SECRET_KEY=datajoint
2121
# ports:
22-
# - "9000:9000"
22+
# - "80:80"
2323
# volumes:
2424
# - ./minio/config:/root/.minio
2525
# - ./minio/data:/data
26-
command: server /data
26+
command: server --address ":80" /data
2727
healthcheck:
28-
test: ["CMD", "curl", "--fail", "http://minio:9000/minio/health/live"]
28+
test: ["CMD", "curl", "--fail", "http://minio:80/minio/health/live"]
2929
timeout: 5s
3030
retries: 60
3131
interval: 1s
3232
fakeservices.datajoint.io:
3333
<<: *net
34-
image: raphaelguzman/nginx:v0.0.4
34+
image: raphaelguzman/nginx:v0.0.5
3535
environment:
3636
- ADD_db_TYPE=DATABASE
3737
- ADD_db_ENDPOINT=db:3306
3838
- ADD_minio_TYPE=MINIO
39-
- ADD_minio_ENDPOINT=minio:9000
39+
- ADD_minio_ENDPOINT=minio:80
4040
- ADD_minio_PREFIX=/
4141
# ports:
42-
# - "9000:9000"
42+
# - "80:80"
4343
# - "443:443"
4444
# - "3306:3306"
4545
depends_on:
@@ -60,7 +60,7 @@ services:
6060
- DJ_TEST_HOST=fakeservices.datajoint.io
6161
- DJ_TEST_USER=datajoint
6262
- DJ_TEST_PASSWORD=datajoint
63-
- S3_ENDPOINT=fakeservices.datajoint.io:9000
63+
- S3_ENDPOINT=fakeservices.datajoint.io
6464
- S3_ACCESS_KEY=datajoint
6565
- S3_SECRET_KEY=datajoint
6666
- S3_BUCKET=datajoint-test

datajoint/admin.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@ def set_password(new_password=None, connection=None, update_config=None): # pr
2121
config.save_local(verbose=True)
2222

2323

24-
def kill(restriction=None, connection=None): # pragma: no cover
24+
def kill(restriction=None, connection=None, order_by=None): # pragma: no cover
2525
"""
2626
view and kill database connections.
2727
:param restriction: restriction to be applied to processlist
2828
:param connection: a datajoint.Connection object. Default calls datajoint.conn()
29+
:param order_by: order by string clause for output ordering. defaults to 'id'.
2930
3031
Restrictions are specified as strings and can involve any of the attributes of
3132
information_schema.processlist: ID, USER, HOST, DB, COMMAND, TIME, STATE, INFO.
@@ -39,7 +40,8 @@ def kill(restriction=None, connection=None): # pragma: no cover
3940
connection = conn()
4041

4142
query = 'SELECT * FROM information_schema.processlist WHERE id <> CONNECTION_ID()' + (
42-
"" if restriction is None else ' AND (%s)' % restriction)
43+
"" if restriction is None else ' AND (%s)' % restriction) + (
44+
' ORDER BY %s' % (order_by or 'id'))
4345

4446
while True:
4547
print(' ID USER HOST STATE TIME INFO')

datajoint/connection.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def is_connected(self):
185185
return True
186186

187187
@staticmethod
188-
def __execute_query(cursor, query, args, cursor_class, suppress_warnings):
188+
def _execute_query(cursor, query, args, cursor_class, suppress_warnings):
189189
try:
190190
with warnings.catch_warnings():
191191
if suppress_warnings:
@@ -211,7 +211,7 @@ def query(self, query, args=(), *, as_dict=False, suppress_warnings=True, reconn
211211
cursor_class = client.cursors.DictCursor if as_dict else client.cursors.Cursor
212212
cursor = self._conn.cursor(cursor=cursor_class)
213213
try:
214-
self.__execute_query(cursor, query, args, cursor_class, suppress_warnings)
214+
self._execute_query(cursor, query, args, cursor_class, suppress_warnings)
215215
except errors.LostConnectionError:
216216
if not reconnect:
217217
raise
@@ -222,7 +222,7 @@ def query(self, query, args=(), *, as_dict=False, suppress_warnings=True, reconn
222222
raise errors.LostConnectionError("Connection was lost during a transaction.") from None
223223
logger.debug("Re-executing")
224224
cursor = self._conn.cursor(cursor=cursor_class)
225-
self.__execute_query(cursor, query, args, cursor_class, suppress_warnings)
225+
self._execute_query(cursor, query, args, cursor_class, suppress_warnings)
226226
return cursor
227227

228228
def get_user(self):

datajoint/errors.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@ class MissingExternalFile(DataJointError):
8181
"""
8282

8383

84+
class BucketInaccessible(DataJointError):
85+
"""
86+
Error raised when a S3 bucket is inaccessible
87+
"""
88+
89+
8490
# environment variables to control availability of experimental features
8591

8692
ADAPTED_TYPE_SWITCH = "DJ_SUPPORT_ADAPTED_TYPES"

datajoint/external.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ def __init__(self, connection, store=None, database=None):
4646
if not self.is_declared:
4747
self.declare()
4848
self._s3 = None
49+
if self.spec['protocol'] == 'file' and not Path(self.spec['location']).is_dir():
50+
raise FileNotFoundError('Inaccessible local directory %s' %
51+
self.spec['location']) from None
4952

5053
@property
5154
def definition(self):

datajoint/fetch.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,9 @@ def __call__(self, *attrs, offset=None, limit=None, order_by=None, format=None,
173173
attributes = [a for a in attrs if not is_key(a)]
174174
ret = self._expression.proj(*attributes).fetch(
175175
offset=offset, limit=limit, order_by=order_by,
176-
as_dict=False, squeeze=squeeze, download_path=download_path)
176+
as_dict=False, squeeze=squeeze, download_path=download_path,
177+
format='array'
178+
)
177179
if attrs_as_dict:
178180
ret = [{k: v for k, v in zip(ret.dtype.names, x) if k in attrs} for x in ret]
179181
else:

datajoint/s3.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ class Folder:
1414
A Folder instance manipulates a flat folder of objects within an S3-compatible object store
1515
"""
1616
def __init__(self, endpoint, bucket, access_key, secret_key, *, secure=False, **_):
17-
self.client = minio.Minio(endpoint, access_key=access_key, secret_key=secret_key, secure=secure)
17+
self.client = minio.Minio(endpoint, access_key=access_key, secret_key=secret_key,
18+
secure=secure)
1819
self.bucket = bucket
1920
if not self.client.bucket_exists(bucket):
20-
warnings.warn('Creating bucket "%s"' % self.bucket)
21-
self.client.make_bucket(self.bucket)
21+
raise errors.BucketInaccessible('Inaccessible s3 bucket %s' % bucket) from None
2222

2323
def put(self, name, buffer):
2424
return self.client.put_object(
@@ -63,6 +63,6 @@ def get_size(self, name):
6363

6464
def remove_object(self, name):
6565
try:
66-
self.client.remove_objects(self.bucket, str(name))
66+
self.client.remove_object(self.bucket, str(name))
6767
except minio.ResponseError:
6868
return errors.DataJointError('Failed to delete %s from s3 storage' % name)

datajoint/table.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,6 @@ def describe(self, context=None, printout=True):
539539
parent_name = list(self.connection.dependencies.in_edges(parent_name))[0][0]
540540
lst = [(attr, ref) for attr, ref in fk_props['attr_map'].items() if ref != attr]
541541
definition += '->{props} {class_name}.proj({proj_list})\n'.format(
542-
attr_list=', '.join(r[0] for r in lst),
543542
props=index_props,
544543
class_name=lookup_class_name(parent_name, context) or parent_name,
545544
proj_list=','.join('{}="{}"'.format(a, b) for a, b in lst))
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
For example, to sort the output by hostname in descending order:
3+
4+
.. code-block:: text
5+
6+
In [3]: dj.kill(None, None, 'host desc')
7+
Out[3]:
8+
ID USER HOST STATE TIME INFO
9+
+--+ +----------+ +-----------+ +-----------+ +-----+
10+
33 chris localhost:54840 1261 None
11+
17 chris localhost:54587 3246 None
12+
4 event_scheduler localhost Waiting on empty queue 187180 None
13+
process to kill or "q" to quit > q
14+

local-docker-compose.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,28 @@ services:
2020
- MINIO_ACCESS_KEY=datajoint
2121
- MINIO_SECRET_KEY=datajoint
2222
# ports:
23-
# - "9000:9000"
23+
# - "80:80"
2424
# To persist MinIO data and config
2525
# volumes:
2626
# - ./minio/data:/data
2727
# - ./minio/config:/root/.minio
28-
command: server /data
28+
command: server --address ":80" /data
2929
healthcheck:
30-
test: ["CMD", "curl", "--fail", "http://minio:9000/minio/health/live"]
30+
test: ["CMD", "curl", "--fail", "http://minio:80/minio/health/live"]
3131
timeout: 5s
3232
retries: 60
3333
interval: 1s
3434
fakeservices.datajoint.io:
3535
<<: *net
36-
image: raphaelguzman/nginx:v0.0.4
36+
image: raphaelguzman/nginx:v0.0.5
3737
environment:
3838
- ADD_db_TYPE=DATABASE
3939
- ADD_db_ENDPOINT=db:3306
4040
- ADD_minio_TYPE=MINIO
41-
- ADD_minio_ENDPOINT=minio:9000
41+
- ADD_minio_ENDPOINT=minio:80
4242
- ADD_minio_PREFIX=/
4343
ports:
44-
- "9000:9000"
44+
- "80:80"
4545
- "443:443"
4646
- "3306:3306"
4747
depends_on:
@@ -63,7 +63,7 @@ services:
6363
- DJ_TEST_USER=datajoint
6464
- DJ_TEST_PASSWORD=datajoint
6565
# If running tests locally, make sure to add entry in /etc/hosts for 127.0.0.1 fakeservices.datajoint.io
66-
- S3_ENDPOINT=fakeservices.datajoint.io:9000
66+
- S3_ENDPOINT=fakeservices.datajoint.io
6767
- S3_ACCESS_KEY=datajoint
6868
- S3_SECRET_KEY=datajoint
6969
- S3_BUCKET=datajoint-test

0 commit comments

Comments
 (0)