Skip to content
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

Pull "ephemeral" collections into their own module #109

Merged
merged 2 commits into from
Feb 3, 2023
Merged

Conversation

thetorpedodog
Copy link
Contributor

The meaning and usage of the various SimpleWhatever collections was unclear with them colocated with the abstract implementation. Moving them to their own ephemeral module and not having them in the main somacore namespace will make them less attractive. They still have value in being the most basic possible implementation of a collection, and are useful in tests for this package.

In the process of removing the SimpleCollection export from the package root, also changes the __init__.py to just import module members rather than the module itself. Since this is at the top level and is exclusively for re-export, this does not have the same potential circular dependency problems as doing so within internal modules, while reducing repetition and the possibility of errors.

The meaning and usage of the various `SimpleWhatever` collections was
unclear with them colocated with the abstract implementation. Moving
them to their own `ephemeral` module and not having them in the main
`somacore` namespace will make them less attractive. They still have
value in being the most basic possible implementation of a collection,
and are useful in tests for this package.

In the process of removing the `SimpleCollection` export from the
package root, also changes the `__init__.py` to just import module
members rather than the module itself. Since this is at the top level
and is exclusively for re-export, this does not have the same potential
circular dependency problems as doing so within internal modules, while
reducing repetition and the possibility of errors.
@thetorpedodog
Copy link
Contributor Author

Another little note as I do some follow-up work:

Another thing I have found the ephemeral types useful for is to validate the type hierarchy and make sure generics work as I expect. I also think in the future they could be more useful in testing if we had in-memory dataframes/ndarrays that wrapped pandas dataframes / numpy ndarrays and provided appropriate methods; experimentquery could be tested entirely in isolation (but that is a future thing, if ever).


@property
def uri(self) -> str:
return f"somacore:simple-collection:{id(self):x}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ephemeral-collection for consistency?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also fixed.



class SimpleCollectionTest(unittest.TestCase):
class EphemeralCollectionTest(unittest.TestCase):
def test_basic(self):
# Since the SimpleCollection implementation is straightforward this is
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might want to s/\bSimple(.+)\b/Ephemeral$1/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops! Thank you.

Copy link
Member

@atolopko-czi atolopko-czi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. The separation helps!

Just a couple spots where "simple" still exists; suggest a full search & replace. Approving optimistically.

@thetorpedodog thetorpedodog merged commit 1c2b1f7 into main Feb 3, 2023
@thetorpedodog thetorpedodog deleted the inmemory branch February 3, 2023 01:41
@johnkerl johnkerl changed the title Pull "ephemeral" collections into their own module. Pull "ephemeral" collections into their own module Feb 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants