Skip to content

Commit

Permalink
add click for making dev easy
Browse files Browse the repository at this point in the history
  • Loading branch information
t-sasatani committed Jun 22, 2024
1 parent aac78ce commit e4d3936
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 7 deletions.
11 changes: 11 additions & 0 deletions miniscope_io/cli.py
Original file line number Diff line number Diff line change
@@ -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()
Empty file.
26 changes: 26 additions & 0 deletions miniscope_io/commands/capture.py
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 1 addition & 1 deletion miniscope_io/stream_daq.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 3 additions & 6 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -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"

Expand Down

0 comments on commit e4d3936

Please sign in to comment.