-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert formats
to yaml
with id
s
#76
Merged
Merged
Changes from 13 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
f916757
prepare rm sd formats
sneakers-the-rat e9e4738
rm sdcard formats
sneakers-the-rat ffd5af0
narrowing in on a bug in streamdaq format...
sneakers-the-rat a4d0c56
broken version loaded from yaml file
sneakers-the-rat adee0dc
working version again
sneakers-the-rat c6bb772
oop forgot to actually commit the relevant config
sneakers-the-rat 0d9d80f
now back to not working version
sneakers-the-rat 27e39ac
correct instantiation
sneakers-the-rat 9d698e6
implement config from id in streaming daq
sneakers-the-rat 7db10db
instantiate streamdaq from id in cli and tests
sneakers-the-rat 8333a5f
rm formats module
sneakers-the-rat e8aee8c
cleanup older impls
sneakers-the-rat 0d6910e
Merge branch 'main' into formats-to-yaml
sneakers-the-rat a736c5b
instantiate click type
sneakers-the-rat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
""" | ||
Shared CLI utils | ||
""" | ||
|
||
from os import PathLike | ||
from pathlib import Path | ||
from typing import Optional | ||
|
||
from click import Context, Parameter, ParamType | ||
|
||
|
||
class ConfigIDOrPath(ParamType): | ||
""" | ||
A custom click type to accept either a config `id` or a path | ||
as input, resolving relative paths first against | ||
the current working directory and second against the user config directory. | ||
""" | ||
|
||
name = "config-id-or-path" | ||
|
||
def convert( | ||
self, value: str | PathLike[str], param: Optional[Parameter], ctx: Optional[Context] | ||
) -> str | Path: | ||
""" | ||
If something looks like a yaml file, return as a path, otherwise return unchanged. | ||
|
||
Don't do validation here, the Config model will handle that on instantiation. | ||
""" | ||
if value.endswith(".yaml") or value.endswith(".yml"): | ||
value = Path(value) | ||
return value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
id: wirefree-sd-layout-battery | ||
mio_model: miniscope_io.models.sdcard.SDLayout | ||
mio_version: v5.0.0 | ||
sectors: | ||
header: 1022 | ||
config: 1023 | ||
data: 1024 | ||
size: 512 | ||
write_key0: 226277911 | ||
write_key1: 226277911 | ||
write_key2: 226277911 | ||
write_key3: 226277911 | ||
word_size: 4 | ||
header: | ||
gain: 4 | ||
led: 5 | ||
ewl: 6 | ||
record_length: 7 | ||
fs: 8 | ||
delay_start: 9 | ||
battery_cutoff: 10 | ||
config: | ||
width: 0 | ||
height: 1 | ||
fs: 2 | ||
buffer_size: 3 | ||
n_buffers_recorded: 4 | ||
n_buffers_dropped: 5 | ||
buffer: | ||
linked_list: 1 | ||
frame_num: 2 | ||
buffer_count: 3 | ||
frame_buffer_count: 4 | ||
write_buffer_count: 5 | ||
dropped_buffer_count: 6 | ||
timestamp: 7 | ||
write_timestamp: 9 | ||
length: 0 | ||
data_length: 8 | ||
battery_voltage: 10 | ||
version: 0.1.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
id: wirefree-sd-layout | ||
mio_model: miniscope_io.models.sdcard.SDLayout | ||
mio_version: v5.0.0 | ||
sectors: | ||
header: 1022 | ||
config: 1023 | ||
data: 1024 | ||
size: 512 | ||
write_key0: 226277911 | ||
write_key1: 226277911 | ||
write_key2: 226277911 | ||
write_key3: 226277911 | ||
word_size: 4 | ||
header: | ||
gain: 4 | ||
led: 5 | ||
ewl: 6 | ||
record_length: 7 | ||
fs: 8 | ||
delay_start: 9 | ||
battery_cutoff: 10 | ||
config: | ||
width: 0 | ||
height: 1 | ||
fs: 2 | ||
buffer_size: 3 | ||
n_buffers_recorded: 4 | ||
n_buffers_dropped: 5 | ||
buffer: | ||
linked_list: 1 | ||
frame_num: 2 | ||
buffer_count: 3 | ||
frame_buffer_count: 4 | ||
write_buffer_count: 5 | ||
dropped_buffer_count: 6 | ||
timestamp: 7 | ||
write_timestamp: null | ||
length: 0 | ||
data_length: 8 | ||
battery_voltage: null |
14 changes: 14 additions & 0 deletions
14
miniscope_io/data/config/wireless/stream-buffer-header.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
id: stream-buffer-header | ||
mio_model: miniscope_io.models.stream.StreamBufferHeaderFormat | ||
mio_version: "v5.0.0" | ||
linked_list: 0 | ||
frame_num: 1 | ||
buffer_count: 2 | ||
frame_buffer_count: 3 | ||
write_buffer_count: 4 | ||
dropped_buffer_count: 5 | ||
timestamp: 6 | ||
write_timestamp: 8 | ||
pixel_count: 7 | ||
battery_voltage_raw: 9 | ||
input_voltage_raw: 10 |
4 changes: 4 additions & 0 deletions
4
miniscope_io/data/config/WLMS_v02_200px.yml → ...o/data/config/wireless/wireless-200px.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might not fully understand the benefit of having a dedicated
id
field when we could also use the file path directly. (I assume it'll be one configuration per one YAML file here.)config
as a unique ID to call configs? Likewirefree/sd-layout-battery
for this example or maybeuser/some-config
if it's a user directory.ScopeX-1
,ScopeX-2
,ScopeX-old
,ScopeX-latest
, andScopeY
for a device calledScopeX
), compared to when we just use path/filename as IDs.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ope responded to this as a global comment before i read the individual comments. Responded to most of these there, but for continuity's sake: currently we get both, and there are reasons to have both, and they don't really trade off.
this would be an interface question. so we would want something like
but again you can always specify something as a path if you want to.
the goal is that we don't want to have
scope-v1
,scope-v2
, etc. The idea behind having theid
is that we want to have a way of identifying unique configurations semantically, so then different versions could each beid: scope-default
with a differentmio_version
field to identify that they are related configs that are for different versions of the scope. Then the id only contains the minimal semantic information necessary to identify it: like one would usually just usewireless
to run their wireless miniscope, but if they had some custom configuration they could usewireless-mycustomconfig
everywhere and not have to worry about keeping the rest of their code up to date with the current location of that file, or the different file names as the version changes.Filenames are unique identifiers to the system, but we want to provide an interface that potentially allows people to have multiple versions of the same configuration, and exposing them in the filesystem makes for nicer ux than just having them in a database somewhere. so that's the compromise - have an
id
field and allow it to be decoupled from the filename.if someone wants to refer to something by the filename, then they just go
path/filename.yaml
. if someone wants to refer to something by the id, they gomyconfig
. one can make the filename match the if they want to, but they have the ability to make it orthogonal to filename in cases where that's useful.