def ephemeral(profile): from pacu.util import identity from pacu.core.model import fixture l = manager.instance('log') resource = identity.formattempfile('%s-db-engine-ephemeral.db') engine = _create_sqlite_engine(profile.uri + resource, profile.echo.bool) engine.__pacu_protect__ = profile.PROTECT.bool s = get_scoped(engine) if not Path(resource).is_file(): fixture.base.setup(s) l.info('Tables of ephemeral db has initialized.') return s
from pacu.profile import manager # from pacu.core.io.scanbox.impl import ScanboxIO opt = manager.instance('opt') # def index_meta(mouse, day): # io_paths = sorted(set( # path.with_suffix('.io') # for path in opt.scanbox_root.joinpath(mouse, day).ls('*.sbx') # if path.is_file())) # ios = map(ScanboxIO, io_paths) # return dict(mouse=mouse, day=day, io_attrs_set=[r.attributes for r in ios]) # # def index_day(mouse): # days = sorted(set(path.name # for path in opt.scanbox_root.joinpath(mouse).ls() # if path.is_dir())) # return dict(mouse=mouse, days=days) # # def index_mouse(): # mice = sorted(set(path.name # for path in opt.scanbox_root.ls() # if path.is_dir())) # return dict(mice=mice) def get_config(req): return dict(root=opt.sparsenoise_root.str)
def ScanimageIOFetcher(year, month, day, mouse, image, session): root = manager.instance('opt').scanimage_root date = '{}.{:2}.{:2}'.format(year, month, day) path = Path(root).joinpath(date, mouse, image) return ScanimageIO(path).set_session(session)
def TrajectoryIOFetcher(recording, trial, session): root = manager.instance('opt').trajectory_root path = Path(root).joinpath(recording, trial) return TrajectoryIO(path).set_session(session)
def unfold(self): yield Path(self.data) # print FSGraph(sbxpath).render().to_json() # qwe = FSGraph(sbxpath.joinpath('JZ5', 'JZ5_000_003.mat')).render().to_json() # print qwe.render().to_json() # print qwe.catch() # print qwe # qwe = FSGraph(sbxpath.joinpath('fake-error-data.mat')).render().to_json() # jz5 = '/Volumes/Users/ht/tmp/pysbx-data/JZ5/JZ5_000_003' # f = FileGroup(jz5) from pacu.profile import manager sbxroot = manager.instance('opt').scanbox_root sbxpath = Path(sbxroot) # sbxpath = Path('/Volumes/Users/ht/tmp/pysbx-data') # sbxpath = Path('/Volumes/Recordings/scanbox-jack/my4r_1_3') def get(req, anchor, *hops, **kwargs): action = kwargs.get('action') # dest = path.cwd.joinpath(*hops) dest = sbxpath.joinpath(*hops) try: graph = FSGraph(dest) return graph.action(action) if action else graph.render().to_json() except Exception as e: print e
def ScanboxIOFetcher(mouse, day, io_name, workspace_id): root = manager.instance('opt').scanbox_root path = Path(root).joinpath(mouse, day, io_name) return ScanboxIO(path).set_workspace(workspace_id).set_channel(0)