Skip to content

Instantly share code, notes, and snippets.

@huyng
Created January 15, 2014 23:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save huyng/8447087 to your computer and use it in GitHub Desktop.
Save huyng/8447087 to your computer and use it in GitHub Desktop.
Timings for load_bundle
Line # Hits Time Per Hit % Time Line Contents
==============================================================
25 def load_bundle(bundle_dir):
26 """
27 Load and return a bundle object from its path.
28 The class of the returned bundle will be introspected
29 from the bundle metadata.
30
31 This is the preferred method of de-serializing bundles.
32 """
33
34 # load from a json meta file
35 107 545 5.1 0.2 meta_fname = os.path.join(bundle_dir, "meta.json")
36 107 1180 11.0 0.4 if os.path.exists(meta_fname):
37
38 # Load meta file (every bundle should have a meta.json)
39 106 5544 52.3 2.0 meta = json.load(open(meta_fname))
40
41 # Get bundle class (e.g., 'iqfeat.bundle.feature.UFLFeatureBundle').
42 # Every meta.json should have a 'cls' attribute.
43 106 1615 15.2 0.6 cls = _load_from_module(meta['cls'])
44
45 # Call the class method 'load' on bundle's class.
46 106 158009 1490.7 57.4 obj = cls.load(bundle_dir)
47
48 106 130 1.2 0.0 return obj
49
50 # load from pickle file
51 1 6 6.0 0.0 pkl_fname = os.path.join(bundle_dir, 'object.pickle')
52 1 13 13.0 0.0 if os.path.exists(pkl_fname):
53 1 7 7.0 0.0 from .feature import HiCFeatureBundle
54 1 108169 108169.0 39.3 return HiCFeatureBundle.load(bundle_dir)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment