Skip to content

Commit

Permalink
adding start of predictors (symbolator and actual)
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 Dec 4, 2021
1 parent fd0ee7a commit 477673c
Show file tree
Hide file tree
Showing 12 changed files with 381 additions and 33 deletions.
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,42 @@ you'll see:
3. Running splice predictors (not developed yet) but will give a prediction if the splice will work!
4. Commands, if provided, are then run to give an "actual" report of if it worked (according to the command) or not.

By default, the predictors used will be all that are provided (libabigail and symbolator and an actual) and if
any predictor dependency is missing, a warning will be printed and it will be skipped. If you want to filter
to a specific number of predictors, use `--predictor` for each.

```bash
$ spliced splice --package curl@7.50.2 --splice zlib --experiment curl --predictor actual --predictor symbolator
```

The above would run symbolator and an actual run (given a command) only. Here is what an entire run looks like, with a testing command and
output saved to a json file with `--outfile`

```bash
$ spliced splice --package curl@7.50.2 --splice zlib --runner spack --replace zlib --experiment curl --outfile examples/curl-result.json curl --head https://linuxize.com/
Concretizing curl@7.50.2
[+] /home/vanessa/Desktop/Code/spack-vsoch/opt/spack/linux-ubuntu20.04-skylake/gcc-9.3.0/berkeley-db-18.1.40-pdlzkb4o4qsw3nglppv7eqjm7lepqvod
[+] /home/vanessa/Desktop/Code/spack-vsoch/opt/spack/linux-ubuntu20.04-skylake/gcc-9.3.0/libiconv-1.16-infpf4xwcb7253odbry6ljjcsat2ksp5
[+] /home/vanessa/Desktop/Code/spack-vsoch/opt/spack/linux-ubuntu20.04-skylake/gcc-9.3.0/pkgconf-1.8.0-5bckkoeicca3dtolbeyz6tnnyxwcsfn5
[+] /home/vanessa/Desktop/Code/spack-vsoch/opt/spack/linux-ubuntu20.04-skylake/gcc-9.3.0/zlib-1.2.11-3kmnsdv36qxm3slmcyrb326gkghsp6px
[+] /home/vanessa/Desktop/Code/spack-vsoch/opt/spack/linux-ubuntu20.04-skylake/gcc-9.3.0/diffutils-3.8-ae4ve7adrxntd2kafm4xxmeyhrwpzpmg
[+] /home/vanessa/Desktop/Code/spack-vsoch/opt/spack/linux-ubuntu20.04-skylake/gcc-9.3.0/ncurses-6.2-5bzr63iqgpogufanleaw2fzjxnzziz67
[+] /home/vanessa/Desktop/Code/spack-vsoch/opt/spack/linux-ubuntu20.04-skylake/gcc-9.3.0/bzip2-1.0.8-doeyikigv6jk4dk6fdxm3cl5j7j465if
[+] /home/vanessa/Desktop/Code/spack-vsoch/opt/spack/linux-ubuntu20.04-skylake/gcc-9.3.0/readline-8.1-wkga37hicua476jm2bjjmuzufz6h574j
[+] /home/vanessa/Desktop/Code/spack-vsoch/opt/spack/linux-ubuntu20.04-skylake/gcc-9.3.0/gdbm-1.19-wuhyaf477mw6nmgftp3gvrxic7qzgpso
[+] /home/vanessa/Desktop/Code/spack-vsoch/opt/spack/linux-ubuntu20.04-skylake/gcc-9.3.0/perl-5.34.0-bvgnm2ejnajpvaruta22d5c24g6qi4zu
[+] /home/vanessa/Desktop/Code/spack-vsoch/opt/spack/linux-ubuntu20.04-skylake/gcc-9.3.0/openssl-1.1.1l-antishvjbtniecep64dku2cenh7hkonc
[+] /home/vanessa/Desktop/Code/spack-vsoch/opt/spack/linux-ubuntu20.04-skylake/gcc-9.3.0/curl-7.50.2-a7ncgyeci2upn3vimpc62whvdkagihou
Testing splicing in (and out) zlib@1.2.11
[+] /home/vanessa/Desktop/Code/spack-vsoch/opt/spack/linux-ubuntu20.04-skylake/gcc-9.3.0/zlib-1.2.11-3kmnsdv36qxm3slmcyrb326gkghsp6px
Testing splicing in (and out) zlib@1.2.8
[+] /home/vanessa/Desktop/Code/spack-vsoch/opt/spack/linux-ubuntu20.04-skylake/gcc-9.3.0/zlib-1.2.8-mtdthhgpvdcqsfmbqzzvdlvain56j6th
Testing splicing in (and out) zlib@1.2.3
[+] /home/vanessa/Desktop/Code/spack-vsoch/opt/spack/linux-ubuntu20.04-skylake/gcc-9.3.0/zlib-1.2.3-mum2pz5di4xf4pjkyac3olgpnbrtpxph
Making predictions for actual
Making predictions for symbolator
```


### Splice Matrix

Expand Down
94 changes: 94 additions & 0 deletions examples/curl-result.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
[
{
"binaries": [
"/home/vanessa/Desktop/Code/spack-vsoch/opt/spack/linux-ubuntu20.04-skylake/gcc-9.3.0/curl-7.50.2-7ybfviq4uauvq4hhggxn3npc6ib4clr3/bin/curl"
],
"predictions": {
"actual": [
{
"message": " % Total % Received % Xferd Average Speed Time Time Time Current\n Dload Upload Total Spent Left Speed\n\r 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0\r 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0\nHTTP/1.1 403 Forbidden\r\nDate: Sat, 04 Dec 2021 01:07:32 GMT\r\nContent-Type: text/html; charset=UTF-8\r\nConnection: close\r\nCF-Chl-Bypass: 1\r\nPermissions-Policy: accelerometer=(),autoplay=(),camera=(),clipboard-read=(),clipboard-write=(),fullscreen=(),geolocation=(),gyroscope=(),hid=(),interest-cohort=(),magnetometer=(),microphone=(),payment=(),publickey-credentials-get=(),screen-wake-lock=(),serial=(),sync-xhr=(),usb=()\r\nCache-Control: private, max-age=0, no-store, no-cache, must-revalidate, post-check=0, pre-check=0\r\nExpires: Thu, 01 Jan 1970 00:00:01 GMT\r\nX-Frame-Options: SAMEORIGIN\r\nExpect-CT: max-age=604800, report-uri=\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\"\r\nReport-To: {\"endpoints\":[{\"url\":\"https:\\/\\/a.nel.cloudflare.com\\/report\\/v3?s=7qbpxfTO2iFvTK6xWWcdT7JXLgStMWxeykf2sFLxpAjJSLvAULQJNMvLfLpgyjPxIM8Vw9TRr2DNlkfmKfmZhlXrMHYSWDzJpTi4lW6i7cXwmYINMnNgghJYEctQMw8R7krO0LFNOO8FEw%3D%3D\"}],\"group\":\"cf-nel\",\"max_age\":604800}\r\nNEL: {\"success_fraction\":0,\"report_to\":\"cf-nel\",\"max_age\":604800}\r\nStrict-Transport-Security: max-age=15552000; includeSubDomains; preload\r\nX-Content-Type-Options: nosniff\r\nServer: cloudflare\r\nCF-RAY: 6b812372aac4638a-ORD\r\nalt-svc: h3=\":443\"; ma=86400, h3-29=\":443\"; ma=86400, h3-28=\":443\"; ma=86400, h3-27=\":443\"; ma=86400\r\n\r\n",
"return_code": 0,
"prediction": true,
"command": "/home/vanessa/Desktop/Code/spack-vsoch/opt/spack/linux-ubuntu20.04-skylake/gcc-9.3.0/curl-7.50.2-7ybfviq4uauvq4hhggxn3npc6ib4clr3/bin/curl --head https://linuxize.com/"
}
],
"symbolator": {
"/home/vanessa/Desktop/Code/spack-vsoch/opt/spack/linux-ubuntu20.04-skylake/gcc-9.3.0/curl-7.50.2-7ybfviq4uauvq4hhggxn3npc6ib4clr3/bin/curl": {
"/home/vanessa/Desktop/Code/spack-vsoch/opt/spack/linux-ubuntu20.04-skylake/gcc-9.3.0/zlib-1.2.11-3kmnsdv36qxm3slmcyrb326gkghsp6px/lib/libz.so.1.2.11": true
}
}
},
"libs": [
{
"dep": "zlib@1.2.11%gcc@9.3.0+optimize+pic+shared arch=linux-ubuntu20.04-skylake",
"paths": [
"/home/vanessa/Desktop/Code/spack-vsoch/opt/spack/linux-ubuntu20.04-skylake/gcc-9.3.0/zlib-1.2.11-3kmnsdv36qxm3slmcyrb326gkghsp6px/lib/libz.so.1.2.11"
]
}
],
"experiment": null,
"result": "splice-success",
"success": true,
"splice": "zlib@1.2.11",
"package": "curl@7.50.2"
},
{
"binaries": [
"/home/vanessa/Desktop/Code/spack-vsoch/opt/spack/linux-ubuntu20.04-skylake/gcc-9.3.0/curl-7.50.2-uyqxrcmgypzjxolcxsfrkjtvbptcoeud/bin/curl"
],
"predictions": {
"actual": [
{
"message": " % Total % Received % Xferd Average Speed Time Time Time Current\n Dload Upload Total Spent Left Speed\n\r 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0\r 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0\nHTTP/1.1 403 Forbidden\r\nDate: Sat, 04 Dec 2021 01:07:33 GMT\r\nContent-Type: text/html; charset=UTF-8\r\nConnection: close\r\nCF-Chl-Bypass: 1\r\nPermissions-Policy: accelerometer=(),autoplay=(),camera=(),clipboard-read=(),clipboard-write=(),fullscreen=(),geolocation=(),gyroscope=(),hid=(),interest-cohort=(),magnetometer=(),microphone=(),payment=(),publickey-credentials-get=(),screen-wake-lock=(),serial=(),sync-xhr=(),usb=()\r\nCache-Control: private, max-age=0, no-store, no-cache, must-revalidate, post-check=0, pre-check=0\r\nExpires: Thu, 01 Jan 1970 00:00:01 GMT\r\nX-Frame-Options: SAMEORIGIN\r\nExpect-CT: max-age=604800, report-uri=\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\"\r\nReport-To: {\"endpoints\":[{\"url\":\"https:\\/\\/a.nel.cloudflare.com\\/report\\/v3?s=rNqO6HRZsOL3%2F7JIX077X%2BQ%2B2gdKkpAaex%2FBYQlO4i46JJ%2Fr5B1Dg34z6%2FBmY%2F%2BQJCQYabk9Gx1Xecv8oXgmh5ev3t%2BTTDgiHLNDAaFZHYbi4FsozTL9a1%2F%2F4aUxmbzQlWs3%2Biphc42xpg%3D%3D\"}],\"group\":\"cf-nel\",\"max_age\":604800}\r\nNEL: {\"success_fraction\":0,\"report_to\":\"cf-nel\",\"max_age\":604800}\r\nStrict-Transport-Security: max-age=15552000; includeSubDomains; preload\r\nX-Content-Type-Options: nosniff\r\nServer: cloudflare\r\nCF-RAY: 6b8123738dbe2c11-ORD\r\nalt-svc: h3=\":443\"; ma=86400, h3-29=\":443\"; ma=86400, h3-28=\":443\"; ma=86400, h3-27=\":443\"; ma=86400\r\n\r\n",
"return_code": 0,
"prediction": true,
"command": "/home/vanessa/Desktop/Code/spack-vsoch/opt/spack/linux-ubuntu20.04-skylake/gcc-9.3.0/curl-7.50.2-uyqxrcmgypzjxolcxsfrkjtvbptcoeud/bin/curl --head https://linuxize.com/"
}
],
"symbolator": {
"/home/vanessa/Desktop/Code/spack-vsoch/opt/spack/linux-ubuntu20.04-skylake/gcc-9.3.0/curl-7.50.2-uyqxrcmgypzjxolcxsfrkjtvbptcoeud/bin/curl": {
"/home/vanessa/Desktop/Code/spack-vsoch/opt/spack/linux-ubuntu20.04-skylake/gcc-9.3.0/zlib-1.2.8-mtdthhgpvdcqsfmbqzzvdlvain56j6th/lib/libz.so.1.2.8": true
}
}
},
"libs": [
{
"dep": "zlib@1.2.8%gcc@9.3.0+optimize+pic+shared arch=linux-ubuntu20.04-skylake",
"paths": [
"/home/vanessa/Desktop/Code/spack-vsoch/opt/spack/linux-ubuntu20.04-skylake/gcc-9.3.0/zlib-1.2.8-mtdthhgpvdcqsfmbqzzvdlvain56j6th/lib/libz.so.1.2.8"
]
}
],
"experiment": null,
"result": "splice-success",
"success": true,
"splice": "zlib@1.2.8",
"package": "curl@7.50.2"
},
{
"binaries": [
"/home/vanessa/Desktop/Code/spack-vsoch/opt/spack/linux-ubuntu20.04-skylake/gcc-9.3.0/curl-7.50.2-6wfkzljni43ly6uh3ocgotxgrlq5b347/bin/curl"
],
"predictions": {
"actual": [
{
"message": " % Total % Received % Xferd Average Speed Time Time Time Current\n Dload Upload Total Spent Left Speed\n\r 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0\r 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0\nHTTP/1.1 403 Forbidden\r\nDate: Sat, 04 Dec 2021 01:07:33 GMT\r\nContent-Type: text/html; charset=UTF-8\r\nConnection: close\r\nCF-Chl-Bypass: 1\r\nPermissions-Policy: accelerometer=(),autoplay=(),camera=(),clipboard-read=(),clipboard-write=(),fullscreen=(),geolocation=(),gyroscope=(),hid=(),interest-cohort=(),magnetometer=(),microphone=(),payment=(),publickey-credentials-get=(),screen-wake-lock=(),serial=(),sync-xhr=(),usb=()\r\nCache-Control: private, max-age=0, no-store, no-cache, must-revalidate, post-check=0, pre-check=0\r\nExpires: Thu, 01 Jan 1970 00:00:01 GMT\r\nX-Frame-Options: SAMEORIGIN\r\nExpect-CT: max-age=604800, report-uri=\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\"\r\nReport-To: {\"endpoints\":[{\"url\":\"https:\\/\\/a.nel.cloudflare.com\\/report\\/v3?s=3%2BztzQcSul%2BM%2F0TX716OuDtoSHRsyYSLG4qpGr946MviZ4Re9N8%2BUCxnT0Gz8%2BfSe5ShCTuIffaM4gB5%2FZJPPJvc0rb%2F9nTANKNscCroZ%2FVNStPnNz0Ud3lFv3%2FqM54lej%2FL%2FOl0VAUh0Q%3D%3D\"}],\"group\":\"cf-nel\",\"max_age\":604800}\r\nNEL: {\"success_fraction\":0,\"report_to\":\"cf-nel\",\"max_age\":604800}\r\nStrict-Transport-Security: max-age=15552000; includeSubDomains; preload\r\nX-Content-Type-Options: nosniff\r\nServer: cloudflare\r\nCF-RAY: 6b8123746e216327-ORD\r\nalt-svc: h3=\":443\"; ma=86400, h3-29=\":443\"; ma=86400, h3-28=\":443\"; ma=86400, h3-27=\":443\"; ma=86400\r\n\r\n",
"return_code": 0,
"prediction": true,
"command": "/home/vanessa/Desktop/Code/spack-vsoch/opt/spack/linux-ubuntu20.04-skylake/gcc-9.3.0/curl-7.50.2-6wfkzljni43ly6uh3ocgotxgrlq5b347/bin/curl --head https://linuxize.com/"
}
]
},
"libs": [
{
"dep": "zlib@1.2.3%gcc@9.3.0+optimize+pic+shared arch=linux-ubuntu20.04-skylake",
"paths": []
}
],
"experiment": null,
"result": "splice-success",
"success": true,
"splice": "zlib@1.2.3",
"package": "curl@7.50.2"
}
]
8 changes: 8 additions & 0 deletions spliced/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@ def get_parser():
dest="replace",
help="splice IN this package or library (overridden by replace in config yaml)",
)

splice.add_argument(
"--predictor",
dest="predictor",
help="A named predictor to use (if not defined, defaults to all)",
action="append",
)

splice.add_argument(
"-r",
"--runner",
Expand Down
5 changes: 4 additions & 1 deletion spliced/client/matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ def generate_spack_matrix(args, experiment, command=None):
# We will build up a matrix of container and associated compilers
matrix = []

# Command can come from command line or config file
command = command or experiment.command

# Generate list of commands
for version in versions:

Expand All @@ -70,7 +73,7 @@ def generate_spack_matrix(args, experiment, command=None):
if args.container:
cmd = "%s --containers %s" % (cmd, args.container)
if command:
cmd = '%s --command "%s"' % (cmd, command)
cmd = "%s %s" % (cmd, command)
matrix.append(
{
"command": cmd,
Expand Down
13 changes: 7 additions & 6 deletions spliced/client/splice.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def main(args, parser, extra, subparser):
elif not args.runner:
sys.exit("You must provide an experiment runner.")
else:
sys.exit("Runner %s is not recognized")
sys.exit("Runner %s is not recognized" % args.runner)


def run_spack_experiment(args, command):
Expand All @@ -39,16 +39,17 @@ def run_spack_experiment(args, command):

# Perform the splice!
experiment.run()
results = experiment.to_dict()

######
# TODO need to run the other splicers here
######
# TODO can we run_parallel here as an option? And do splice -> predict as such
# And make predictions
experiment.predict(args.predictor)
results = experiment.to_dict()

if args.outfile:
utils.write_json(results, args.outfile)
else:
json.dumps(results, indent=4)
print(json.dumps(results, indent=4))


def add_spack_to_path():
"""
Expand Down
27 changes: 24 additions & 3 deletions spliced/experiment/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

# TODO can we run in parallel?

from spliced.logger import logger
import spliced.predict
import spliced.schemas
import spliced.utils as utils
import jsonschema
Expand Down Expand Up @@ -34,12 +36,11 @@ def __init__(
self.predictions = {}
self.libs = []
self.package = package
self.corpora = []
self._experiment = None
self.success = success
self.result = result
self.splice = splice
self.command = command
self.command = command

def to_dict(self):
"""
Expand All @@ -49,7 +50,6 @@ def to_dict(self):
"binaries": self.binaries,
"predictions": self.predictions,
"libs": self.libs,
"corpora": self.corpora,
"experiment": self._experiment,
"result": self.result,
"success": self.success,
Expand All @@ -68,6 +68,7 @@ class Experiment:
"""
A base Experiment holds information for a splice experiment!
"""

def __init__(self):
self.splices = []
self.config_file = None
Expand Down Expand Up @@ -101,6 +102,26 @@ def run(self):
"""
raise NotImplementedError

def run_parallel(self):
# TODO- will be nice to possibly speed things up!
pass

def predict(self, names=None):
"""
Given a single named predictor (or a list to skip) make predictions.
"""
predictors = spliced.predict.get_predictors(names)
if not predictors:
logger.warning("No matching predictors were found.")
return

for name, predictor in predictors.items():
logger.info("Making predictions for %s" % name)

# Result is added to splice
for splice in self.splices:
predictor.predict(splice)

def to_json(self):
"""
Return a json dump of results
Expand Down
2 changes: 1 addition & 1 deletion spliced/experiment/spack.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def _populate_splice(self, splice, spliced_spec):
if self.command:

# We need to know the binary of interest from the command
binary = shlex.split(command)[0]
binary = shlex.split(self.command)[0]

# Add binaries to the libary
splice.binaries = list(add_contenders(spliced_spec, "bin", binary))
Expand Down
17 changes: 17 additions & 0 deletions spliced/predict/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from .base import Prediction, Actual
from .symbolator import SymbolatorPrediction


def get_predictors(names=None):
"""
Get a lookup of predictors for an experiment to run.
"""
names = names or []
predictors = {"actual": Actual(), "symbolator": SymbolatorPrediction()}
if names:
keepers = {}
for name, predictor in predictors.items():
if name in names:
keepers[name] = predictor
predictors = keepers
return predictors
46 changes: 46 additions & 0 deletions spliced/predict/base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)

from spliced.logger import logger
import spliced.utils as utils

import shlex
import os
import re


class Prediction:
"""
A prediction is a base for assessing a Splice and making predictions.
"""

def predict(self, splice):
raise NotImplementedError

def __str__(self):
return str(self.__class__.__name__)


class Actual(Prediction):
"""
Given a splice result with a command, get an actual result.
"""

def predict(self, splice):
if not splice.command:
return

# Check each binary to match the command
executable = shlex.split(splice.command)[0]
results = []
for binary in splice.binaries:
if binary.endswith(executable):
cmd = "%s%s%s" % (os.path.dirname(binary), os.path.sep, splice.command)
res = utils.run_command(cmd)
res["prediction"] = True if res["return_code"] == 0 else False
res["command"] = cmd
results.append(res)

splice.predictions["actual"] = results

0 comments on commit 477673c

Please sign in to comment.