Skip to content
This repository was archived by the owner on Dec 8, 2023. It is now read-only.

Commit ab0c034

Browse files
authored
Merge pull request #45 from kabilar/main
Update Docker and Compose files. Add pytest fixture.
2 parents 564c32f + 6c7c638 commit ab0c034

File tree

8 files changed

+89
-63
lines changed

8 files changed

+89
-63
lines changed

docker-compose-dev.yaml

Lines changed: 0 additions & 33 deletions
This file was deleted.

Dockerfile.dev renamed to docker/Dockerfile.dev

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ FROM datajoint/djbase:py3.9-debian-fcd8909
22

33
USER anaconda:anaconda
44

5-
COPY ./workflow-array-ephys/apt_requirements.txt /tmp/
5+
COPY ./workflow-array-ephys/docker/apt_requirements.txt /tmp/
66
RUN /entrypoint.sh echo "Installed dependencies."
77

88
RUN mkdir /main/element-lab \

Dockerfile.test renamed to docker/Dockerfile.test

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ FROM datajoint/djbase:py3.9-debian-fcd8909
22

33
USER anaconda:anaconda
44

5-
COPY ./workflow-array-ephys/apt_requirements.txt /tmp/
5+
COPY ./workflow-array-ephys/docker/apt_requirements.txt /tmp/
66
RUN /entrypoint.sh echo "Installed dependencies."
77

88
WORKDIR /main/workflow-array-ephys
@@ -19,20 +19,23 @@ WORKDIR /main/workflow-array-ephys
1919
# RUN git clone https://github.com/<user>/workflow-array-ephys.git /main/workflow-array-ephys
2020

2121
# Option 3 - Install user's local fork of element and workflow
22-
RUN mkdir /main/element-lab
22+
RUN mkdir /main/element-lab \
23+
/main/element-animal \
24+
/main/element-session \
25+
/main/element-array-ephys \
26+
/main/workflow-array-ephys
27+
2328
COPY --chown=anaconda:anaconda ./element-lab /main/element-lab
24-
RUN pip install -e /main/element-lab
25-
RUN mkdir /main/element-animal
2629
COPY --chown=anaconda:anaconda ./element-animal /main/element-animal
27-
RUN pip install -e /main/element-animal
28-
RUN mkdir /main/element-session
2930
COPY --chown=anaconda:anaconda ./element-session /main/element-session
30-
RUN pip install -e /main/element-session
31-
RUN mkdir /main/element-array-ephys
3231
COPY --chown=anaconda:anaconda ./element-array-ephys /main/element-array-ephys
33-
RUN pip install -e /main/element-array-ephys
3432
COPY --chown=anaconda:anaconda ./workflow-array-ephys /main/workflow-array-ephys
35-
# RUN rm -f /main/workflow-array-ephys/dj_local_conf.json
33+
34+
RUN pip install -e /main/element-lab
35+
RUN pip install -e /main/element-animal
36+
RUN pip install -e /main/element-session
37+
RUN pip install -e /main/element-array-ephys
38+
RUN rm -f /main/workflow-array-ephys/dj_local_conf.json
3639

3740
# Install the workflow
3841
RUN pip install /main/workflow-array-ephys
File renamed without changes.

docker/docker-compose-dev.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# docker-compose -f ./docker/docker-compose-dev.yaml up -d --build
2+
# docker-compose -f ./docker/docker-compose-dev.yaml down
3+
4+
version: "2.4"
5+
x-net: &net
6+
networks:
7+
- main
8+
services:
9+
array-ephys-dev-db:
10+
<<: *net
11+
image: datajoint/mysql:5.7
12+
environment:
13+
- MYSQL_ROOT_PASSWORD=simple
14+
array-ephys-dev-workflow:
15+
<<: *net
16+
build:
17+
context: ../../
18+
dockerfile: ./workflow-array-ephys/docker/Dockerfile.dev
19+
env_file: .env
20+
image: workflow_array_ephys_dev:0.1.0a4
21+
environment:
22+
- EPHYS_ROOT_DATA_DIR=/main/test_data/workflow_ephys_data1/,/main/test_data/workflow_ephys_data2/
23+
volumes:
24+
- ${TEST_DATA_DIR}:/main/test_data
25+
- ./apt_requirements.txt:/tmp/apt_requirements.txt
26+
- ../../element-lab:/main/element-lab
27+
- ../../element-animal:/main/element-animal
28+
- ../../element-session:/main/element-session
29+
- ../../element-array-ephys:/main/element-array-ephys
30+
- ..:/main/workflow-array-ephys
31+
depends_on:
32+
array-ephys-dev-db:
33+
condition: service_healthy
34+
networks:
35+
main:
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
# export COMPOSE_DOCKER_CLI_BUILD=0 # some machines need for smooth --build
22
# .env file: TEST_DATA_DIR=<local parent directory of workflow_ephys_data{1,2}>
3-
# docker-compose -f docker-compose-test.yaml up --build
3+
# docker-compose -f ./docker/docker-compose-test.yaml up --build
44
# docker exec -it workflow-array-ephys_workflow_1 /bin/bash
5-
# docker-compose -f docker-compose-test.yaml down
5+
# docker-compose -f ./docker/docker-compose-test.yaml down
66

77
version: "2.4"
88
x-net: &net
99
networks:
1010
- main
1111
services:
12-
db:
12+
array-ephys-test-db:
1313
<<: *net
1414
image: datajoint/mysql:5.7
1515
environment:
1616
- MYSQL_ROOT_PASSWORD=simple
17-
workflow:
17+
array-ephys-test-workflow:
1818
<<: *net
1919
build:
20-
context: ../
21-
dockerfile: ./workflow-array-ephys/Dockerfile.test
20+
context: ../../
21+
dockerfile: ./workflow-array-ephys/docker/Dockerfile.test
2222
env_file: .env
2323
image: workflow_array_ephys_test:0.1.0a4
2424
environment:
@@ -37,13 +37,13 @@ services:
3737
volumes:
3838
- ${TEST_DATA_DIR}:/main/test_data
3939
- ./apt_requirements.txt:/tmp/apt_requirements.txt
40-
- ../element-lab:/main/element-lab
41-
- ../element-animal:/main/element-animal
42-
- ../element-session:/main/element-session
43-
- ../element-array-ephys:/main/element-array-ephys
44-
- .:/main/workflow-array-ephys
40+
- ../../element-lab:/main/element-lab
41+
- ../../element-animal:/main/element-animal
42+
- ../../element-session:/main/element-session
43+
- ../../element-array-ephys:/main/element-array-ephys
44+
- ..:/main/workflow-array-ephys
4545
depends_on:
46-
db:
46+
array-ephys-test-db:
4747
condition: service_healthy
4848
networks:
4949
main:

tests/__init__.py

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# run all tests: pytest -sv --cov-report term-missing \
2-
# --cov=workflow_array_ephys -p no:warnings tests/
3-
# run one test, debug: pytest [above options] --pdb tests/tests_name.py -k \
4-
# function_name
1+
# run all tests:
2+
# pytest -sv --cov-report term-missing --cov=workflow_array_ephys -p no:warnings tests/
3+
# run one test, debug:
4+
# pytest [above options] --pdb tests/tests_name.py -k function_name
55

66
import os
77
import sys
@@ -56,8 +56,7 @@ def dj_config():
5656
dj.config['custom'] = {
5757
'database.prefix': (os.environ.get('DATABASE_PREFIX')
5858
or dj.config['custom']['database.prefix']),
59-
'ephys_root_data_dir': (os.environ.get('EPHYS_ROOT_DATA_DIR').split(',')
60-
or dj.config['custom']['ephys_root_data_dir'])
59+
'ephys_root_data_dir': (os.environ.get('EPHYS_ROOT_DATA_DIR').split(',') if os.environ.get('EPHYS_ROOT_DATA_DIR') else dj.config['custom']['ephys_root_data_dir'])
6160
}
6261
return
6362

@@ -198,6 +197,28 @@ def testdata_paths():
198197
'npx3B-p1-ks': 'subject6/session1/towersTask_g0_imec0'
199198
}
200199

200+
@pytest.fixture
201+
def ephys_insertionlocation(pipeline, ingest_sessions):
202+
"""Insert probe location into ephys.InsertionLocation"""
203+
ephys = pipeline['ephys']
204+
205+
for probe_insertion_key in ephys.ProbeInsertion.fetch('KEY'):
206+
ephys.InsertionLocation.insert1(dict(**probe_insertion_key,
207+
skull_reference='Bregma',
208+
ap_location=0,
209+
ml_location=0,
210+
depth=0,
211+
theta=0,
212+
phi=0,
213+
beta=0))
214+
yield
215+
216+
if _tear_down:
217+
if verbose:
218+
ephys.InsertionLocation.delete()
219+
else:
220+
with QuietStdOut():
221+
ephys.InsertionLocation.delete()
201222

202223
@pytest.fixture
203224
def kilosort_paramset(pipeline):

workflow_array_ephys/pipeline.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from element_animal.subject import Subject
88
from element_lab.lab import Source, Lab, Protocol, User, Project
9-
from element_session.session import Session
9+
from element_session.session_with_datetime import Session
1010

1111
from .paths import get_ephys_root_data_dir, get_session_directory
1212

0 commit comments

Comments
 (0)