Skip to content

Commit

Permalink
a metric base needs the commit checked out first
Browse files Browse the repository at this point in the history
Signed-off-by: vsoch <vsochat@stanford.edu>
  • Loading branch information
vsoch committed Jan 15, 2021
1 parent 6c73fd5 commit 8a75aa1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions caliper/managers/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ def init(self, dest=None):
def config(self, key, value, dest=None):
self.run_command(self.init_cmd(dest) + ["config", key, value])

def checkout(self, commit, dest=None):
self.run_command(self.init_cmd(dest) + ["checkout", commit])

def ls_files(self, dest=None):
"""init an empty repository in a directory of choice"""
dest = dest or self.folder or ""
Expand Down
7 changes: 7 additions & 0 deletions caliper/metrics/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ def __init__(self, git=None, filename=__file__):
self.classpath = os.path.dirname(filename)

def extract(self):
"""extract for a metric base assumes one timepoint, so we checkout the
commit for the user.
"""
for tag, index in self.iter_tags():
self.git.checkout(str(tag.commit), dest=self.git.folder)
self._data[index] = self._extract(tag.commit)

@property
Expand Down Expand Up @@ -83,6 +87,9 @@ def _extract(self, commit1, commit2):
pass

def extract(self):
"""extract for a change metric base has two timepoints, we don't do
any checkout on behalf of the user.
"""
for tag, parent, index in self.iter_tags():
self._data[index] = self._extract(tag.commit, parent)

Expand Down
2 changes: 2 additions & 0 deletions caliper/metrics/collection/functiondb/metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ def _extract(self, commit):
# Add the temporary directory to the PYTHONPATH
sys.path.insert(0, self.git.folder)

# Checkout the right commit

# Helper function to populate lookup
def add_functions(filepath, modulepath):

Expand Down

0 comments on commit 8a75aa1

Please sign in to comment.