You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
as extensions mature they can be shipped with the core package, without
affecting the core Session class
the ExtensionBaseClass is provided, along with the register_namespace
decorator, to make this process easier
Example of adding a namespace
# Create your custom functionality in a subclass of ExtensionBaseClass and register it with the Session class:>>>importaind_session>>>@aind_session.register_namespace("my_extension") # The name here is how the extension will be accessed
... classMyExtension(aind_session.ExtensionBaseClass):
... # ...the name of the class itself is unimportant
...
... constant=42
...
... @classmethod
... defadd(cls, value) ->int:
... returncls.constant+value
...
... # Access the underlying Session object with self._base
... @property
... defoldest_data_asset_id(self) ->str:
... returnmin(self._base.data_assets, key=lambdax: x.created).id# Create a session object and access the new namespace:>>>session=aind_session.Session("ecephys_676909_2023-12-13_13-43-40")
>>>session.my_extension.constant42>>>session.my_extension.add(10)
52>>>session.my_extension.oldest_data_asset_id'16d46411-540a-4122-b47f-8cb2a15d593a'