-
Notifications
You must be signed in to change notification settings - Fork 25
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
Split out FilenameProvider, rename DirectoryProvider to PathProvider #245
Conversation
Before I continue, I'd like to hear if you have any suggestions. @coretl @mrakitin @DiamondJoseph |
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 can think of 2 usecases for us:
- For testing we would like all the files for a given detector to be placed in a predictable
tmp_path
. I guess we could either use a differentStaticPathProvider
andAutoIncrementingFilenameProvider
for each detector, or we could pass downdevice_name
to allFilenameProvider
s and allowAutoIncrementingFilenameProvider
to use that in its format string. - In production we will probably make a
PathProvider
that doesn't use aFilenameProvider
at all, just generates the names according to DLS conventions
So feel free to delete all the prefix
and suffix
code that you wouldn't use yourself.
I'll review once rebased :) |
@mrakitin @danielballan @coretl I think this is ready for review and potentially merge |
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.
Looks great to me! Proposed some non-blocking suggestions, most of them are optional.
I have some fixes from yesterday's and today's work at HEX in jwlodek#1. Please merge, then we can rebase. |
1b8b510
to
734dbcf
Compare
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.
Not sure if it's a leftover from my rebasing...
Is it all now implemented in https://github.com/bluesky/ophyd-async/blob/main/src/ophyd_async/epics/areadetector/writers/general_hdffile.py?
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.
OK, this is passing now! Codecov is failing, but I don't think it should be a blocker.
A couple of questions to @coretl, @evalott100, and @abbiemery are below.
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 guess we'll also need https://github.com/bluesky/ophyd-async/blob/main/src/ophyd_async/epics/areadetector/writers/general_hdffile.py, not this file, right?
A comment #245 (review) was intended to be a part of my review. Sorry for posting it separately. |
src/ophyd_async/core/_providers.py
Outdated
class UUIDFilenameProvider(FilenameProvider): | ||
def __init__( | ||
self, uuid_call_func: Callable = uuid.uuid4, uuid_call_args: Optional[List] = [] | ||
): |
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 think we should make this explicitly a Callable with no input args: if you want to use a uuid generator that takes arguments, you should construct a partial
and pass that.
This then is just a CallableFileNameProvider, as it could take any partial not just a UUID one.
The case of needing the current state to calculate the FileName isn't covered here: it's always taking the same uuid_call_args with every call.
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.
Or make call_func: Callable[[P], str], call_args: P
where P = ParamSpec("P")
@pytest.fixture | ||
def static_path_provider_factory(tmp_path: Path): | ||
def create_static_dir_provider_given_fp(fp: FilenameProvider): | ||
return StaticPathProvider(fp, tmp_path) | ||
|
||
return create_static_dir_provider_given_fp | ||
|
||
|
||
@pytest.fixture | ||
def static_path_provider( | ||
static_path_provider_factory: callable, | ||
static_filename_provider: FilenameProvider, | ||
): | ||
return static_path_provider_factory(static_filename_provider) |
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.
@pytest.fixture | |
def static_path_provider_factory(tmp_path: Path): | |
def create_static_dir_provider_given_fp(fp: FilenameProvider): | |
return StaticPathProvider(fp, tmp_path) | |
return create_static_dir_provider_given_fp | |
@pytest.fixture | |
def static_path_provider( | |
static_path_provider_factory: callable, | |
static_filename_provider: FilenameProvider, | |
): | |
return static_path_provider_factory(static_filename_provider) | |
@pytest.fixture | |
def static_path_provider(tmp_path: Path, static_filename_provider: StaticFilenameProvider): | |
return StaticPathProvider(static_filename_provider, tmp_path) |
Do you need this factory function elsewhere? It doesn't seem to be required.
Co-authored-by: DiamondJoseph <[email protected]>
18e12a5
to
0b344e4
Compare
Creating this as a draft PR first to get some feedback before I apply fixes to the filewriters to account for this change.
Addresses #214