Skip to content

Commit

Permalink
Merge pull request Pyomo#3261 from mrmundt/link-checking
Browse files Browse the repository at this point in the history
Add URL Checking to `.py` files
  • Loading branch information
mrmundt committed May 21, 2024
2 parents f9c5a2f + 7d25d13 commit 0e749d0
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 33 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/test_branches.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,16 @@ jobs:
uses: urlstechie/urlchecker-action@0.0.34
with:
# A comma-separated list of file types to cover in the URL checks
file_types: .md,.rst
file_types: .md,.rst,.py
# Choose whether to include file with no URLs in the prints.
print_all: false
# More verbose summary at the end of a run
verbose: true
# How many times to retry a failed request (defaults to 1)
retry_count: 3
# Exclude Jenkins because it's behind a firewall
exclude_urls: https://pyomo-jenkins.sandia.gov/
# Exclude Jenkins because it's behind a firewall; ignore RTD because
# a magically-generated string is triggering a failure
exclude_urls: https://pyomo-jenkins.sandia.gov/,https://pyomo.readthedocs.io/en/%s/errors.html


build:
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/test_pr_and_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,16 @@ jobs:
uses: urlstechie/urlchecker-action@0.0.34
with:
# A comma-separated list of file types to cover in the URL checks
file_types: .md,.rst
file_types: .md,.rst,.py
# Choose whether to include file with no URLs in the prints.
print_all: false
# More verbose summary at the end of a run
verbose: true
# How many times to retry a failed request (defaults to 1)
retry_count: 3
# Exclude Jenkins because it's behind a firewall
exclude_urls: https://pyomo-jenkins.sandia.gov/
# Exclude Jenkins because it's behind a firewall; ignore RTD because
# a magically-generated string is triggering a failure
exclude_urls: https://pyomo-jenkins.sandia.gov/,https://pyomo.readthedocs.io/en/%s/errors.html


build:
Expand Down
5 changes: 4 additions & 1 deletion examples/dae/ReactionKinetics.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,10 @@ def regression_model():

# Model & data from:
#
# http://www.doiserbia.nb.rs/img/doi/0367-598X/2014/0367-598X1300037A.pdf
# https://doiserbia.nb.rs/img/doi/0367-598X/2014/0367-598X1300037A.pdf
# Almagrbi, A. M., Hatami, T., Glišić, S., & Orlović, A. (2014).
# Determination of kinetic parameters for complex transesterification
# reaction by standard optimisation methods.
#
model = ConcreteModel()

Expand Down
4 changes: 2 additions & 2 deletions pyomo/common/gsl.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
)
def get_gsl(downloader):
logger.info(
"As of February 9, 2023, AMPL GSL can no longer be downloaded\
through download-extensions. Visit https://portal.ampl.com/\
"As of February 9, 2023, AMPL GSL can no longer be downloaded \
through download-extensions. Visit https://portal.ampl.com/ \
to download the AMPL GSL binaries."
)

Expand Down
5 changes: 3 additions & 2 deletions pyomo/dataportal/plugins/db_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,8 +385,9 @@ def __init__(self, filename=None, data=None):
will override that in the file.
"""

# ugh hardcoded strings. See following URL for info:
# http://publib.boulder.ibm.com/infocenter/idshelp/v10/index.jsp?topic=/com.ibm.odbc.doc/odbc58.htm
# Hardcoded string required here.
# See documentation:
# https://www.ibm.com/docs/en/informix-servers/12.10?topic=SSGU8G_12.1.0/com.ibm.odbc.doc/ids_odbc_062.html
self.ODBC_DS_KEY = 'ODBC Data Sources'
self.ODBC_INFO_KEY = 'ODBC'

Expand Down
6 changes: 3 additions & 3 deletions pyomo/scripting/plugins/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ def _call_impl(self, args, unparsed, logger):
self.downloader.cacert = args.cacert
self.downloader.insecure = args.insecure
logger.info(
"As of February 9, 2023, AMPL GSL can no longer be downloaded\
through download-extensions. Visit https://portal.ampl.com/\
to download the AMPL GSL binaries."
"As of February 9, 2023, AMPL GSL can no longer be downloaded \
through download-extensions. Visit https://portal.ampl.com/ \
to download the AMPL GSL binaries."
)
for target in DownloadFactory:
try:
Expand Down
42 changes: 23 additions & 19 deletions pyomo/solvers/plugins/solvers/CBCplugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ def process_logfile(self):
tokens = tuple(re.split('[ \t]+', line.strip()))
n_tokens = len(tokens)
if n_tokens > 1:
# https://projects.coin-or.org/Cbc/browser/trunk/Cbc/src/CbcSolver.cpp?rev=2497#L3769
# https://github.com/coin-or/Cbc/blob/cb6bf98/Cbc/src/CbcSolver.cpp#L3769
if n_tokens > 4 and tokens[:4] == (
'Continuous',
'objective',
Expand Down Expand Up @@ -539,7 +539,7 @@ def process_logfile(self):
results.problem.name = results.problem.name.split('/')[-1]
if '\\' in results.problem.name:
results.problem.name = results.problem.name.split('\\')[-1]
# https://projects.coin-or.org/Cbc/browser/trunk/Cbc/src/CbcSolver.cpp?rev=2497#L10840
# https://github.com/coin-or/Cbc/blob/cb6bf98/Cbc/src/CbcSolver.cpp#L10840
elif tokens[0] == 'Presolve':
if n_tokens > 9 and tokens[3] == 'rows,' and tokens[6] == 'columns':
results.problem.number_of_variables = int(tokens[4]) - int(
Expand All @@ -551,7 +551,7 @@ def process_logfile(self):
results.problem.number_of_objectives = 1
elif n_tokens > 6 and tokens[6] == 'infeasible':
soln.status = SolutionStatus.infeasible
# https://projects.coin-or.org/Cbc/browser/trunk/Cbc/src/CbcSolver.cpp?rev=2497#L11105
# https://github.com/coin-or/Cbc/blob/cb6bf98/Cbc/src/CbcSolver.cpp#L11105
elif (
n_tokens > 11
and tokens[:2] == ('Problem', 'has')
Expand All @@ -563,7 +563,7 @@ def process_logfile(self):
results.problem.number_of_constraints = int(tokens[2])
results.problem.number_of_nonzeros = int(tokens[6][1:])
results.problem.number_of_objectives = 1
# https://projects.coin-or.org/Cbc/browser/trunk/Cbc/src/CbcSolver.cpp?rev=2497#L10814
# https://github.com/coin-or/Cbc/blob/cb6bf98/Cbc/src/CbcSolver.cpp#L10814
elif (
n_tokens > 8
and tokens[:3] == ('Original', 'problem', 'has')
Expand All @@ -579,7 +579,7 @@ def process_logfile(self):
in ' '.join(tokens)
):
results.problem.sense = maximize
# https://projects.coin-or.org/Cbc/browser/trunk/Cbc/src/CbcSolver.cpp?rev=2497#L3047
# https://github.com/coin-or/Cbc/blob/cb6bf98/Cbc/src/CbcSolver.cpp#L3047
elif n_tokens > 3 and tokens[:2] == ('Result', '-'):
if tokens[2:4] in [('Run', 'abandoned'), ('User', 'ctrl-c')]:
results.solver.termination_condition = (
Expand Down Expand Up @@ -609,15 +609,15 @@ def process_logfile(self):
'solution': TerminationCondition.other,
'iterations': TerminationCondition.maxIterations,
}.get(tokens[4], TerminationCondition.other)
# perhaps from https://projects.coin-or.org/Cbc/browser/trunk/Cbc/src/CbcSolver.cpp?rev=2497#L12318
# https://github.com/coin-or/Cbc/blob/cb6bf98/Cbc/src/CbcSolver.cpp#L12318
elif n_tokens > 3 and tokens[2] == "Finished":
soln.status = SolutionStatus.optimal
optim_value = _float(tokens[4])
# https://projects.coin-or.org/Cbc/browser/trunk/Cbc/src/CbcSolver.cpp?rev=2497#L7904
# https://github.com/coin-or/Cbc/blob/cb6bf98/Cbc/src/CbcSolver.cpp#L7904
elif n_tokens >= 3 and tokens[:2] == ('Objective', 'value:'):
# parser for log file generetated with discrete variable
optim_value = _float(tokens[2])
# https://projects.coin-or.org/Cbc/browser/trunk/Cbc/src/CbcSolver.cpp?rev=2497#L7904
# https://github.com/coin-or/Cbc/blob/cb6bf98/Cbc/src/CbcSolver.cpp#L7904
elif n_tokens >= 4 and tokens[:4] == (
'No',
'feasible',
Expand All @@ -630,25 +630,25 @@ def process_logfile(self):
lower_bound is None
): # Only use if not already found since this is to less decimal places
results.problem.lower_bound = _float(tokens[2])
# https://projects.coin-or.org/Cbc/browser/trunk/Cbc/src/CbcSolver.cpp?rev=2497#L7918
# https://github.com/coin-or/Cbc/blob/cb6bf98/Cbc/src/CbcSolver.cpp#L7918
elif tokens[0] == 'Gap:':
# This is relative and only to 2 decimal places - could calculate explicitly using lower bound
gap = _float(tokens[1])
# https://projects.coin-or.org/Cbc/browser/trunk/Cbc/src/CbcSolver.cpp?rev=2497#L7923
# https://github.com/coin-or/Cbc/blob/cb6bf98/Cbc/src/CbcSolver.cpp#L7923
elif n_tokens > 2 and tokens[:2] == ('Enumerated', 'nodes:'):
nodes = int(tokens[2])
# https://projects.coin-or.org/Cbc/browser/trunk/Cbc/src/CbcSolver.cpp?rev=2497#L7926
# https://github.com/coin-or/Cbc/blob/cb6bf98/Cbc/src/CbcSolver.cpp#L7926
elif n_tokens > 2 and tokens[:2] == ('Total', 'iterations:'):
results.solver.statistics.black_box.number_of_iterations = int(
tokens[2]
)
# https://projects.coin-or.org/Cbc/browser/trunk/Cbc/src/CbcSolver.cpp?rev=2497#L7930
# https://github.com/coin-or/Cbc/blob/cb6bf98/Cbc/src/CbcSolver.cpp#L7930
elif n_tokens > 3 and tokens[:3] == ('Time', '(CPU', 'seconds):'):
results.solver.system_time = _float(tokens[3])
# https://projects.coin-or.org/Cbc/browser/trunk/Cbc/src/CbcSolver.cpp?rev=2497#L7933
# https://github.com/coin-or/Cbc/blob/cb6bf98/Cbc/src/CbcSolver.cpp#L7933
elif n_tokens > 3 and tokens[:3] == ('Time', '(Wallclock', 'Seconds):'):
results.solver.wallclock_time = _float(tokens[3])
# https://projects.coin-or.org/Cbc/browser/trunk/Cbc/src/CbcSolver.cpp?rev=2497#L10477
# https://github.com/coin-or/Cbc/blob/cb6bf98/Cbc/src/CbcSolver.cpp#L10477
elif n_tokens > 4 and tokens[:4] == (
'Total',
'time',
Expand Down Expand Up @@ -832,11 +832,15 @@ def process_soln_file(self, results):
tokens = tuple(re.split('[ \t]+', line.strip()))
n_tokens = len(tokens)
#
# These are the only header entries CBC will generate (identified via browsing CbcSolver.cpp)
# See https://projects.coin-or.org/Cbc/browser/trunk/Cbc/src/CbcSolver.cpp
# Search for (no integer solution - continuous used) Currently line 9912 as of rev2497
# Note that since this possibly also covers old CBC versions, we shall not be removing any functionality,
# even if it is not seen in the current revision
# These are the only header entries CBC will generate
# (identified via browsing CbcSolver.cpp). See
# https://github.com/coin-or/Cbc/tree/master/src/CbcSolver.cpp
# Search for "(no integer solution - continuous used)"
# (L10796 as of cb855c7)
#
# Note that since this possibly also supports old CBC
# versions, we shall not be removing any functionality, even
# if it is not seen in the current revision
#
if not header_processed:
if tokens[0] == 'Optimal':
Expand Down

0 comments on commit 0e749d0

Please sign in to comment.