Skip to content
This repository was archived by the owner on Jan 21, 2026. It is now read-only.
Open
Show file tree
Hide file tree
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
44 changes: 20 additions & 24 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
branches:
except:
- /^stage.*$/
sudo: required
env:
global:
Expand Down Expand Up @@ -34,6 +37,14 @@ main: &main
- ./serve.sh up TRAVIS
jobs:
include:
- stage: "Lint: Syntax"
language: python
install:
- pip install flake8
script:
- |
flake8 datajoint_connection_hub --count --select=E9,F63,F7,F82 --show-source \
--statistics
- <<: *main
env:
- PY_VER: "3.8"
Expand All @@ -54,31 +65,16 @@ jobs:
env:
- PY_VER: "3.8"
- MYSQL_VER: "8.0"
- <<: *main
env:
- PY_VER: "3.7"
- MYSQL_VER: "8.0"
- <<: *main
env:
- PY_VER: "3.6"
- MYSQL_VER: "8.0"
- <<: *main
env:
- PY_VER: "3.5"
- MYSQL_VER: "8.0"
- <<: *main
env:
- PY_VER: "3.8"
- MYSQL_VER: "5.6"
- <<: *main
env:
- PY_VER: "3.7"
- MYSQL_VER: "5.6"
- <<: *main
env:
- PY_VER: "3.6"
- MYSQL_VER: "5.6"
- <<: *main
env:
- PY_VER: "3.5"
- MYSQL_VER: "5.6"
- stage: "Lint: Style"
language: python
install:
- pip install flake8
script:
- |
flake8 --ignore=E121,E123,E126,E226,E24,E704,W503,W504,E722,F401,W605 \
datajoint_connection_hub --count --max-complexity=62 --max-line-length=127 \
--statistics
12 changes: 8 additions & 4 deletions LNX-docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,17 @@ services:
condition: service_healthy
fakeservices.datajoint.io:
<<: *net
image: raphaelguzman/nginx:v0.0.2
image: raphaelguzman/nginx:v0.0.6
environment:
- ADD_db_TYPE=DATABASE
- ADD_db_ENDPOINT=db:3306
- ADD_minio_TYPE=MINIO
- ADD_minio_ENDPOINT=minio:9000
- ADD_minio_PREFIX=/
- ADD_minio_PORT=80 # allow unencrypted connections
- ADD_minio_PREFIX=/datajoint
- ADD_browser_TYPE=MINIOADMIN
- ADD_browser_ENDPOINT=minio:9000
- ADD_browser_PORT=80 # allow unencrypted connections
- ADD_hub_TYPE=REST
- ADD_hub_ENDPOINT=hub:5000
- ADD_hub_PREFIX=/api
Expand Down Expand Up @@ -80,10 +84,10 @@ services:
- DJ_TEST_USER=datajoint
- DJ_TEST_PASSWORD=datajoint
# If running tests locally, make sure to add entry in /etc/hosts for 127.0.0.1 fakeservices.datajoint.io
- S3_ENDPOINT=fakeservices.datajoint.io:9000
- S3_ENDPOINT=fakeservices.datajoint.io
- S3_ACCESS_KEY=datajoint
- S3_SECRET_KEY=datajoint
- S3_BUCKET=datajoint-test
- S3_BUCKET=datajoint.test
- PYTHON_USER=dja
- JUPYTER_PASSWORD=datajoint
- DISPLAY
Expand Down
20 changes: 11 additions & 9 deletions datajoint_connection_hub/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import requests
from requests.adapters import HTTPAdapter
from datajoint.errors import DataJointError
from datajoint.connection import get_host_hook
import pymysql as client
from .version import __version__

Expand All @@ -21,27 +22,28 @@ def get_host(host_input):
if re.match(HUB_PROTOCOL, host_input) and len(hub_path) > 2:
try:
resp = session.get('{}{}{}{}'.format(REQUEST_PROTOCOL,
hub_path[0][1:], API_ROUTE, API_TARGETS['PIPELINE']),
params={'org_name': hub_path[1][1:], 'pipeline_name': hub_path[2][1:]},
timeout=10)
hub_path[0][1:], API_ROUTE, API_TARGETS['PIPELINE']),
params={'org_name': hub_path[1][1:],
'pipeline_name': hub_path[2][1:]}, timeout=10)
if resp.status_code == 200:
return resp.json()[0]['database_dsn']
elif resp.status_code == 204:
raise DataJointError(
'DataJoint Hub database resource `{}/{}/{}` not found.'.format(
hub_path[0][1:], hub_path[1][1:], hub_path[2][1:]))
hub_path[0][1:], hub_path[1][1:], hub_path[2][1:]))
elif resp.status_code == 404:
raise DataJointError(
'DataJoint Hub endpoint `{}{}{}{}` unavailable.'.format(
REQUEST_PROTOCOL, hub_path[0][1:], API_ROUTE, API_TARGETS['PIPELINE']))
REQUEST_PROTOCOL, hub_path[0][1:], API_ROUTE,
API_TARGETS['PIPELINE']))
except requests.exceptions.SSLError:
raise DataJointError(
'TLS security violation on DataJoint Hub target `{}{}{}`.'.format(
REQUEST_PROTOCOL, hub_path[0][1:], API_ROUTE))
REQUEST_PROTOCOL, hub_path[0][1:], API_ROUTE))
except requests.exceptions.ConnectionError:
raise DataJointError(
'Unable to reach DataJoint Hub target `{}{}{}`.'.format(
REQUEST_PROTOCOL, hub_path[0][1:], API_ROUTE))
REQUEST_PROTOCOL, hub_path[0][1:], API_ROUTE))
elif not re.match('.*/', host_input):
return host_input
else:
Expand All @@ -54,8 +56,8 @@ def connect_host(connection_obj):
except client.err.OperationalError:
if not connection_obj.is_connected:
target = [int(v) if i == 1 else v
for i, v in enumerate(
get_host_hook(connection_obj.conn_info['host_input']).split(':'))]
for i, v in enumerate(
get_host_hook(connection_obj.conn_info['host_input']).split(':'))]
if (target[0] != connection_obj.conn_info['host'] or len(target) > 1 and
target[1] != connection_obj.conn_info['port']):
connection_obj.conn_info['host'] = target[0]
Expand Down
2 changes: 1 addition & 1 deletion datajoint_connection_hub/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.0.4"
__version__ = "0.0.5"
19 changes: 13 additions & 6 deletions local-docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ services:
- MYSQL_ROOT_PASSWORD=${DJ_PASS}
# ports:
# - "3306:3306"
# To persist MySQL data
# # To persist MySQL data
# volumes:
# - ./mysql/data:/var/lib/mysql
# - ./mysql/my.cnf:/etc/mysql/my.cnf
# # Additional mounts may go here
# - ../datajoint-python/notebook/backups:/backups
minio:
<<: *net
environment:
Expand Down Expand Up @@ -44,13 +46,17 @@ services:
condition: service_healthy
fakeservices.datajoint.io:
<<: *net
image: raphaelguzman/nginx:v0.0.2
image: raphaelguzman/nginx:v0.0.6
environment:
- ADD_db_TYPE=DATABASE
- ADD_db_ENDPOINT=db:3306
- ADD_minio_TYPE=MINIO
- ADD_minio_ENDPOINT=minio:9000
- ADD_minio_PREFIX=/
- ADD_minio_PORT=80 # allow unencrypted connections
- ADD_minio_PREFIX=/datajoint
- ADD_browser_TYPE=MINIOADMIN
- ADD_browser_ENDPOINT=minio:9000
- ADD_browser_PORT=80 # allow unencrypted connections
- ADD_hub_TYPE=REST
- ADD_hub_ENDPOINT=hub:5000
- ADD_hub_PREFIX=/api
Expand Down Expand Up @@ -82,10 +88,10 @@ services:
- DJ_TEST_USER=datajoint
- DJ_TEST_PASSWORD=datajoint
# If running tests locally, make sure to add entry in /etc/hosts for 127.0.0.1 fakeservices.datajoint.io
- S3_ENDPOINT=fakeservices.datajoint.io:9000
- S3_ENDPOINT=fakeservices.datajoint.io
- S3_ACCESS_KEY=datajoint
- S3_SECRET_KEY=datajoint
- S3_BUCKET=datajoint-test
- S3_BUCKET=datajoint.test
- PYTHON_USER=dja
- JUPYTER_PASSWORD=datajoint
- DISPLAY
Expand Down Expand Up @@ -118,6 +124,7 @@ services:
- .:/src
- /tmp/.X11-unix:/tmp/.X11-unix:rw
- ~/Documents/keys/datajoint-dev.pem:/home/dja/keys/datajoint-dev.pem:ro
# Additional mounted notebooks may go here
# # Additional mounted notebooks may go here
# - ../datajoint-python/notebook:/home/dja/notebooks
networks:
main:
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"Operating System :: OS Independent",
],
setup_requires=['setuptools_certificate'],
install_requires=['datajoint', 'requests'],
install_requires=['datajoint>=0.12.5b1', 'requests'],
privkey_path='~/keys/datajoint-dev.pem',
entry_points={
'datajoint_plugins.connection': [
Expand Down