If a sample class needs to access the FreezerBox database (e.g. using ReagentConfig), the default is for each instance to load its own copy of the database. In other words, there isn't a global instance of the database that is shared by default. Loading the database is quite expensive, and when you multiply than by ≈50 samples (a large but not unreasonable number), this can take several minutes to finish. Some thoughts:
The most straight-forward solution is to load the database manually and assign the same copy to each sample. But this is easy to forget to do.
I could cache the database in a global variable. I'm wary about having global data like this, but the fact that the database is read-only makes this plausible.
Previously this wasn't an issue because there was a single object representing all the reactions, and the database was owned by it. Now that object doesn't exist any more.
It might make sense to solve this problem just by making freezerbox faster:
Even loading the database once is pretty slow.
The "template tag" feature stands out as being particularly expensive, so I might consider if I really need that.
I could cache the database in a pickle, so that I don't need to parse everything every time. I'd probably want to store a separate pickle file for each database file, so that I won't have to invalidate the whole cache whenever one input file is updated.
I could run a FreezerBox daemon. This seems pretty heavy, though, and it would require pickling everything.
Right now I like the caching idea. That should help a lot, and not be too much work.
If a sample class needs to access the FreezerBox database (e.g. using
ReagentConfig
), the default is for each instance to load its own copy of the database. In other words, there isn't a global instance of the database that is shared by default. Loading the database is quite expensive, and when you multiply than by ≈50 samples (a large but not unreasonable number), this can take several minutes to finish. Some thoughts:Right now I like the caching idea. That should help a lot, and not be too much work.