text
stringlengths
1
93.6k
]
PYTHON = ["3.12"]
@nox.session(python=PYTHON, reuse_venv=True)
def run_tests(session: nox.Session):
"""Run unit tests."""
session.install(".[dev]")
pytest_args = session.posargs if session.posargs else []
session.run("pytest", *pytest_args)
@nox.session(python=PYTHON, reuse_venv=True)
def format_code(session: nox.Session):
"""Lint code and re-format where necessary."""
session.install(".[dev]")
session.run("black", "--config=pyproject.toml", ".")
session.run("ruff", "check", ".", "--config=pyproject.toml", "--fix")
@nox.session(python=PYTHON, reuse_venv=True)
def check_code_formatting(session: nox.Session):
"""Check code for formatting errors."""
session.install(".[dev]")
session.run("black", "--config=pyproject.toml", "--check", ".")
session.run("ruff", "check", ".", "--config=pyproject.toml")
@nox.session(python=PYTHON, reuse_venv=True)
def check_types(session: nox.Session):
"""Run static type checking."""
session.install(".[dev]")
session.run("mypy")
@nox.session(python=PYTHON, reuse_venv=True)
def build_and_deploy(session: nox.Session):
"""Build wheel and deploy to PyPI."""
try:
from dotenv import load_dotenv
load_dotenv()
except ModuleNotFoundError:
session.warn("Expecting PYPI_USR and PYPI_PWD in local environment variables.")
try:
PYPI_USR = os.environ["PYPI_USR"]
PYPI_PWD = os.environ["PYPI_PWD"]
except KeyError as e:
session.error(f"{str(e)} not found in local environment variables.")
session.install(".[deploy]")
session.run("rm", "-rf", "dist")
session.run("python", "-m", "build")
session.run("twine", "upload", "dist/*", "-u", PYPI_USR, "-p", PYPI_PWD)
# <FILESEP>
""" Imitation Learning (IL) evaluations, using SCIP. """
import sys
import time
import os
import yaml
import random
import argparse
import pickle
from collections import OrderedDict
import numpy as np
import torch
import pyscipopt as scip
from src.environments import *
from models.feedforward import *
import faulthandler
faulthandler.enable()
# solver parametric setting, key ('sandbox' or 'default') to be specified in argparse --setting
settings = {
'sandbox': {
'heuristics': False, # enable primal heuristics
'cutoff': True, # provide cutoff (value needs to be passed to the environment)
'conflict_usesb': False, # use SB conflict analysis
'probing_bounds': False, # use probing bounds identified during SB
'checksol': False,
'reevalage': 0,
},
'default': {
'heuristics': True,
'cutoff': False,
'conflict_usesb': True,
'probing_bounds': True,
'checksol': True,
'reevalage': 10,
},
}
# limits in solvers
limits = {