diff --git a/miniscope_io/cli.py b/miniscope_io/cli.py new file mode 100644 index 00000000..45dce48b --- /dev/null +++ b/miniscope_io/cli.py @@ -0,0 +1,11 @@ +import click +from miniscope_io.commands.capture import sdaqprof + +@click.group() +def cli(): + pass + +cli.add_command(sdaqprof) + +if __name__ == '__main__': + cli() \ No newline at end of file diff --git a/miniscope_io/commands/__init__.py b/miniscope_io/commands/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/miniscope_io/commands/capture.py b/miniscope_io/commands/capture.py new file mode 100644 index 00000000..1fc87d8a --- /dev/null +++ b/miniscope_io/commands/capture.py @@ -0,0 +1,26 @@ +import click +import os + +from pathlib import Path + + +from miniscope_io.stream_daq import StreamDaqConfig, StreamDaq +from miniscope_io.utils import hash_video, hash_file + +@click.command() +@click.option('-c', '--config', required=True, help='YAML file to configure the streamDaq') +@click.option('-s', '--source', required=False, help='RAW FPGA data to plug into okDevMock') +@click.option('-o', '--output', default='output', help='Video output filename') +def sdaqprof(config, source, output): + + output_video = Path("output") / (output + ".avi") + + if source: + # environment variable to allow import okDevMock + os.environ['STREAMDAQ_PROFILERUN'] = 'just_placeholder' + os.environ['PYTEST_OKDEV_DATA_FILE'] = source + + daqConfig = StreamDaqConfig.from_yaml(config) + + daq_inst = StreamDaq(config=daqConfig) + daq_inst.capture(source="fpga", video=output_video) \ No newline at end of file diff --git a/miniscope_io/stream_daq.py b/miniscope_io/stream_daq.py index 77cc44d6..b68dd088 100644 --- a/miniscope_io/stream_daq.py +++ b/miniscope_io/stream_daq.py @@ -230,7 +230,7 @@ def _uart_recv( def _init_okdev(self, BIT_FILE: Path) -> Union[okDev, okDevMock]: # FIXME: when multiprocessing bug resolved, remove this and just mock in tests - dev = okDevMock() if os.environ.get("PYTEST_CURRENT_TEST") is not None else okDev() + dev = okDevMock() if os.environ.get("PYTEST_CURRENT_TEST") or os.environ.get("STREAMDAQ_PROFILERUN") else okDev() dev.uploadBit(str(BIT_FILE)) dev.setWire(0x00, 0b0010) diff --git a/poetry.lock b/poetry.lock index 4b3931c9..cdd6245b 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.8.2 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.6.1 and should not be changed by hand. [[package]] name = "alabaster" @@ -410,7 +410,7 @@ files = [ name = "click" version = "8.1.7" description = "Composable command line interface toolkit" -optional = true +optional = false python-versions = ">=3.7" files = [ {file = "click-8.1.7-py3-none-any.whl", hash = "sha256:ae74fb96c20a0277a1d615f1e4d73c8414f5a98db8b799a7931d1582f3390c28"}, @@ -1219,7 +1219,6 @@ optional = false python-versions = ">=3.9" files = [ {file = "pandas-2.2.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:90c6fca2acf139569e74e8781709dccb6fe25940488755716d1d354d6bc58bce"}, - {file = "pandas-2.2.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:c7adfc142dac335d8c1e0dcbd37eb8617eac386596eb9e1a1b77791cf2498238"}, {file = "pandas-2.2.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4abfe0be0d7221be4f12552995e58723c7422c80a659da13ca382697de830c08"}, {file = "pandas-2.2.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8635c16bf3d99040fdf3ca3db669a7250ddf49c55dc4aa8fe0ae0fa8d6dcc1f0"}, {file = "pandas-2.2.2-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:40ae1dffb3967a52203105a077415a86044a2bea011b5f321c6aa64b379a3f51"}, @@ -1240,7 +1239,6 @@ files = [ {file = "pandas-2.2.2-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:43498c0bdb43d55cb162cdc8c06fac328ccb5d2eabe3cadeb3529ae6f0517c32"}, {file = "pandas-2.2.2-cp312-cp312-win_amd64.whl", hash = "sha256:d187d355ecec3629624fccb01d104da7d7f391db0311145817525281e2804d23"}, {file = "pandas-2.2.2-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:0ca6377b8fca51815f382bd0b697a0814c8bda55115678cbc94c30aacbb6eff2"}, - {file = "pandas-2.2.2-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:9057e6aa78a584bc93a13f0a9bf7e753a5e9770a30b4d758b8d5f2a62a9433cd"}, {file = "pandas-2.2.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:001910ad31abc7bf06f49dcc903755d2f7f3a9186c0c040b827e522e9cef0863"}, {file = "pandas-2.2.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:66b479b0bd07204e37583c191535505410daa8df638fd8e75ae1b383851fe921"}, {file = "pandas-2.2.2-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:a77e9d1c386196879aa5eb712e77461aaee433e54c68cf253053a73b7e49c33a"}, @@ -1701,7 +1699,6 @@ files = [ {file = "PyYAML-6.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34"}, {file = "PyYAML-6.0.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:855fb52b0dc35af121542a76b9a84f8d1cd886ea97c84703eaa6d88e37a2ad28"}, {file = "PyYAML-6.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:40df9b996c2b73138957fe23a16a4f0ba614f4c0efce1e9406a184b6d07fa3a9"}, - {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a08c6f0fe150303c1c6b71ebcd7213c2858041a7e01975da3a99aed1e7a378ef"}, {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6c22bec3fbe2524cde73d7ada88f6566758a8f7227bfbf93a408a9d86bcc12a0"}, {file = "PyYAML-6.0.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8d4e9c88387b0f5c7d5f281e55304de64cf7f9c0021a3525bd3b1c542da3b0e4"}, {file = "PyYAML-6.0.1-cp312-cp312-win32.whl", hash = "sha256:d483d2cdf104e7c9fa60c544d92981f12ad66a457afae824d146093b8c294c54"}, @@ -2095,4 +2092,4 @@ tests = ["matplotlib", "pytest", "pytest-timeout"] [metadata] lock-version = "2.0" python-versions = "^3.9" -content-hash = "91f29159374a90b955caa921b26c99c228f4a6f078ba6390733941069456a09f" +content-hash = "64cfeaddfb34950d72821fc2200f1b3953855b00159380b932e9ef4ff2fcaf3c" diff --git a/pyproject.toml b/pyproject.toml index c006b6e8..1ab572f2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -55,6 +55,7 @@ black = {version="^24.1.1", optional=true} ruff = {version="^0.2.0", optional=true} pre-commit = {version = "^3.7.1", optional = true} nox = {version = ">=2024.4.15", optional = true} +click = "^8.1.7" [tool.poetry.extras] tests = ["pytest", "pytest-timeout", "matplotlib"] @@ -73,6 +74,7 @@ requires = ["poetry-core"] build-backend = "poetry.core.masonry.api" [tool.poetry.scripts] +mio = "miniscope_io.cli:cli" streamDaq = "miniscope_io.stream_daq:main" updateDevice = "miniscope_io.device_update:updateDevice"