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

Shrink the size of environment entries #11

Merged
merged 2 commits into from
Feb 28, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Shrink the size of environment entries to avoid running into the ArgL…
…imit
  • Loading branch information
Dekker1 committed Feb 25, 2021
commit 29ef7654dd2ad7fc4e65a525c134a335b3ca8e21
26 changes: 20 additions & 6 deletions src/mzn_bench/mzn_slurm.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,33 @@ class Configuration:

def to_dict(self):
obj = asdict(self)
obj["solver"] = self.solver.output_configuration()
obj["sol_ident"] = self.solver._identifier
if self.solver._identifier is not None:
obj["solver"] = ""
obj["sol_ident"] = self.solver._identifier
else:
obj["solver"] = self.solver.output_configuration()
obj["sol_ident"] = ""
if self.minizinc is not None:
obj["minizinc"] = str(self.minizinc)
return obj

@classmethod
def from_dict(cls, obj):
field_names = set(f.name for f in fields(minizinc.Solver))
obj["solver"] = minizinc.Solver(
**{k: v for k, v in json.loads(obj["solver"]).items() if k in field_names}
)
obj["solver"]._identifier = obj.pop("sol_ident")
identifier = obj.pop("sol_ident")
if identifier == "":
obj["solver"] = minizinc.Solver(
**{
k: v
for k, v in json.loads(obj["solver"]).items()
if k in field_names
}
)
elif identifier.endswith(".msc"):
obj["solver"] = minizinc.Solver.load(identifier)
else:
obj["solver"] = minizinc.Solver.lookup(identifier)

if obj["minizinc"] is not None:
obj["minizinc"] = Path(obj["minizinc"])
return cls(**obj)
Expand Down