Skip to content

Commit

Permalink
refactoring compspec metric to extract into database
Browse files Browse the repository at this point in the history
Signed-off-by: vsoch <vsoch@users.noreply.github.com>
  • Loading branch information
vsoch committed Feb 16, 2023
1 parent b5fc226 commit dd42e8c
Show file tree
Hide file tree
Showing 11 changed files with 691 additions and 474 deletions.
25 changes: 18 additions & 7 deletions caliper/analysis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@


class CaliperAnalyzerBase:
"""A Caliper Analyzer takes a caliper.yaml, reads it in, and then builds
"""
A Caliper Analyzer takes a caliper.yaml, reads it in, and then builds
containers across a grid of builds to test a set of user provided scripts.
This analyzer base provides the functionality to read in and validate
the caliper.yaml, and abstract functions for the main classes. Output
Expand All @@ -36,7 +37,9 @@ def __repr__(self):
return self.__str__()

def _load_config(self, config_file):
"""Given a caliper.yaml file, load the config an ensure that it is valid."""
"""
Given a caliper.yaml file, load the config an ensure that it is valid.
"""
if not os.path.exists(config_file):
logger.exit("%s does not exist." % config_file)
self.config_file = config_file
Expand Down Expand Up @@ -75,7 +78,8 @@ def _load_config(self, config_file):

class CaliperAnalyzer(CaliperAnalyzerBase):
def get_analyzer(self):
"""Given the validated and loaded config, return the correct analyzer
"""
Given the validated and loaded config, return the correct analyzer
class depending on the packagemanger field. Currently we only support
pypi
"""
Expand All @@ -88,7 +92,9 @@ class depending on the packagemanger field. Currently we only support


class CaliperPypiAnalyzer(CaliperAnalyzerBase):
"""A Pypi Analyzer expects a package that is intended for pypi."""
"""
A Pypi Analyzer expects a package that is intended for pypi.
"""

name = "pypi"

Expand All @@ -102,7 +108,9 @@ def run_analysis(
force=False,
cleanup=False,
):
"""Once the config is loaded, run the analysis."""
"""
Once the config is loaded, run the analysis.
"""
# The release filter is a regular expression we use to find the correct
# platform / architecture. We select linux wheels and source
release_filter = release_filter or "(.*manylinux.*x86_64.*|[.]tar[.]gz)"
Expand Down Expand Up @@ -183,14 +191,17 @@ def run_analysis(
return self._run_serial(tasks)

def _run_parallel(self, tasks, nproc, show_progress=True):
"""Run tasks in parallel"""
"""
Run tasks in parallel
"""
workers = Workers(nproc, show_progress=show_progress)
for key, task in tasks.items():
workers.add_task(key, func=task[0], params=task[1])
return workers.run()

def _run_serial(self, tasks, show_progress=True):
"""Run tasks in serial. The workers save result files, so we don't
"""
Run tasks in serial. The workers save result files, so we don't
care about the results (would take more memory to try and return the
same content).
"""
Expand Down
3 changes: 2 additions & 1 deletion caliper/analysis/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@


def analysis_task(**kwargs):
"""A shared analysis task for the serial or parallel workers. We will
"""
A shared analysis task for the serial or parallel workers. We will
read in the Dockerfile template, and generate and run/test a container
for a particular Python version, etc.
"""
Expand Down
3 changes: 2 additions & 1 deletion caliper/metrics/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ def _setup_save(self, package_dir, fmt, force):
return outfile

def update_index(self, extractor_dir, content):
"""If an index already exists, load it and update it with the data type
"""
If an index already exists, load it and update it with the data type
(represented as the key of a dictionary in content). If an index does not
exist, write a new one. Filepaths should be relative.
"""
Expand Down

0 comments on commit dd42e8c

Please sign in to comment.