Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve reliability of spuriousSSM calls #3

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
@@ -0,0 +1,3 @@
build/
*.egg-info
peppercompiler/_spuriousSSM
4 changes: 2 additions & 2 deletions peppercompiler/_spuriousSSM_wrapper.py
@@ -1,8 +1,8 @@
import sys
import os
import subprocess
import pkg_resources

def main():
binary_path = pkg_resources.resource_filename(__name__,'_spuriousSSM')

os.system(binary_path + " " + " ".join(sys.argv[1:]))
subprocess.run([binary_path]+sys.argv[1:])
24 changes: 18 additions & 6 deletions peppercompiler/design/spurious_design.py
Expand Up @@ -8,6 +8,8 @@
import string
import subprocess
import sys
import pkg_resources
import shlex

from .constraint_load import Convert

Expand All @@ -23,7 +25,8 @@ def print_list(xs, filename, format):
f.write(format % x)
f.close()

def design(basename, infilename, outfilename, cleanup=True, verbose=False, reuse=False, just_files=False, struct_orient=False, old_output=False, tempname=None, extra_pars="", findmfe=True, spuriousbinary="spuriousSSM"):
def design(basename, infilename, outfilename, cleanup=True, verbose=False, reuse=False, just_files=False, struct_orient=False,
old_output=False, tempname=None, extra_pars=tuple(), findmfe=True, spuriousbinary="spuriousSSM"):

if not tempname:
tempname = basename
Expand Down Expand Up @@ -79,12 +82,21 @@ def st_map(x):
quiet = "quiet=TRUE"

spo = open(sp_outname,'wb')

command = "%s score=automatic template=%s wc=%s eq=%s %s %s" % (spuriousbinary, stname, wcname, eqname, extra_pars, quiet)
print(command)

if spuriousbinary is None:
sp_binary_path = pkg_resources.resource_filename(
"peppercompiler", "_spuriousSSM"
)
else:
sp_binary_path = spuriousbinary
if isinstance(extra_pars, str):
extra_pars = shlex.split(extra_pars)
args = [sp_binary_path, "score=automatic", f"template={stname}", f"wc={wcname}",
f"eq={eqname}"] + list(extra_pars) + [quiet]
print(shlex.join(args))
if just_files:
return
spurious_proc = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)
spurious_proc = subprocess.Popen(args, shell=False, stdout=subprocess.PIPE)

data = spurious_proc.stdout.readline()
while data:
Expand Down Expand Up @@ -162,6 +174,6 @@ def main():
options.output = basename + ".mfe"

# Collect extra arguments for spuriousSSM
spurious_pars = " ".join(args[1:])
spurious_pars = args[1:]

design(basename, infilename, options.output, options.cleanup, options.verbose, options.reuse, options.just_files, options.struct_orient, options.old_output, options.tempname, spurious_pars)
4 changes: 2 additions & 2 deletions setup.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python

from setuptools import setup
from distutils.command.build import build
from setuptools.command.build import build
from setuptools.command.develop import develop


Expand Down Expand Up @@ -31,7 +31,7 @@ def run(self):

setup(
name="peppercompiler",
version="0.1.3",
version="0.1.4",
packages=['peppercompiler', 'peppercompiler.design'],
install_requires=["pyparsing", "six"],
include_package_data=True,
Expand Down