From eca59f5fb958275cc9b5e37b32303b0e199928c4 Mon Sep 17 00:00:00 2001 From: luiz Date: Mon, 6 May 2024 17:38:14 +0200 Subject: [PATCH] fix for download file --- common/processor_pipeline.py | 33 +++++++++++++++++++-------- si_mountainsort5/.gitignore | 3 ++- si_mountainsort5/test_in_container.sh | 4 +++- 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/common/processor_pipeline.py b/common/processor_pipeline.py index 34623d4..677bf77 100644 --- a/common/processor_pipeline.py +++ b/common/processor_pipeline.py @@ -36,12 +36,17 @@ def run_pipeline(context: PipelineFullContext): ff = context.input.get_file(download=download) logger.info('Creating input recording') - recording = NwbRecordingExtractor( - file=ff, - electrical_series_path=context.recording_context.electrical_series_path, - # file_path=context.input.get_url(), - # stream_mode="remfile" - ) + if download: + source_file_path = context.input.local_file_name + recording = NwbRecordingExtractor( + file_path=source_file_path, + electrical_series_path=context.recording_context.electrical_series_path, + ) + else: + recording = NwbRecordingExtractor( + file=ff, + electrical_series_path=context.recording_context.electrical_series_path, + ) if context.recording_context.stub_test: logger.info('Running in stub test mode') @@ -156,10 +161,20 @@ def run_pipeline(context: PipelineFullContext): output_fname = 'output/output.nwb' - h5_file = h5py.File(ff, 'r') - with pynwb.NWBHDF5IO(file=h5_file, mode='r', load_namespaces=True) as io: + if download: + nwbhdf5io_kwargs = { + 'path': source_file_path, + 'mode': 'r', + 'load_namespaces': True + } + else: + nwbhdf5io_kwargs = { + 'file': h5py.File(ff, 'r'), + 'mode': 'r', + 'load_namespaces': True + } + with pynwb.NWBHDF5IO(**nwbhdf5io_kwargs) as io: nwbfile_rec = io.read() - nwbfile_base = create_base_nwb_file(nwbfile_original=nwbfile_rec) if waveform_extractor is not None: diff --git a/si_mountainsort5/.gitignore b/si_mountainsort5/.gitignore index dd736b8..d2f54fa 100644 --- a/si_mountainsort5/.gitignore +++ b/si_mountainsort5/.gitignore @@ -1,3 +1,4 @@ results/ scratch/ -output/ \ No newline at end of file +output/ +tmp/ \ No newline at end of file diff --git a/si_mountainsort5/test_in_container.sh b/si_mountainsort5/test_in_container.sh index 08460b3..880375f 100644 --- a/si_mountainsort5/test_in_container.sh +++ b/si_mountainsort5/test_in_container.sh @@ -10,6 +10,7 @@ ARGS="test-app-processor --app-dir . --processor spikeinterface_pipeline_mountai # Run the Docker container, with conveninent volumes docker run --gpus all \ + -v $(pwd)/tmp:/tmp \ -v $(pwd)/results/output:/app/output \ -v $(pwd)/results/results:/app/results \ -v $(pwd)/results/scratch:/app/scratch \ @@ -17,8 +18,9 @@ docker run --gpus all \ -v /mnt/shared_storage/Github/si-dendro-apps/common:/app/common \ -v /mnt/shared_storage/Github/dendro/python:/src/dendro/python \ -v /mnt/shared_storage/Github/spikeinterface_pipelines:/src/spikeinterface_pipelines \ - -v /mnt/shared_storage/Github/spikeinterface:/src/spikeinterface \ -w /app \ --entrypoint "$ENTRYPOINT_CMD" \ $IMAGE \ $ARGS + +# -v /mnt/shared_storage/Github/spikeinterface:/src/spikeinterface \ \ No newline at end of file