Changed build status "package_unavailable" to "package_install_failed" to cover more errors. Added an error message for this status. Outputs of ECG are now always created at the beginning to avoid issues with Snakemake (maybe not a good idea).

This commit is contained in:
antux18 2024-08-20 18:47:32 +02:00
parent 72a638cd17
commit 513b21754c
3 changed files with 17 additions and 9 deletions

View File

@ -120,7 +120,7 @@ The timestamp corresponds to when the result is being logged, not to when it hap
The following are the possible results of the build: The following are the possible results of the build:
- `success`: The Docker image has been built successfully. - `success`: The Docker image has been built successfully.
- `package_unavailable`: A command requested the installation of a package that is not available. - `package_install_failed`: A command requested the installation of a package that failed.
- `baseimage_unavailable`: The base image needed for this container is not available. - `baseimage_unavailable`: The base image needed for this container is not available.
- `artifact_unavailable`: The artifact could not be downloaded. - `artifact_unavailable`: The artifact could not be downloaded.
- `dockerfile_not_found`: No Dockerfile has been found in the location specified in the configuration file. - `dockerfile_not_found`: No Dockerfile has been found in the location specified in the configuration file.

View File

@ -28,7 +28,7 @@ def analysis(input_table):
# All build status, initialized to 0. # All build status, initialized to 0.
# This is required to make the column of the result table deterministic, # This is required to make the column of the result table deterministic,
# so they can be determined without the header in the CSV file. # so they can be determined without the header in the CSV file.
buildstatus = {"success":0, "package_unavailable":0, "baseimage_unavailable":0, "artifact_unavailable":0, "dockerfile_not_found":0, "script_crash":0, "job_time_exceeded":0, "unknown_error":0} buildstatus = {"success":0, "package_install_failed":0, "baseimage_unavailable":0, "artifact_unavailable":0, "dockerfile_not_found":0, "script_crash":0, "job_time_exceeded":0, "unknown_error":0}
for row in input_table: for row in input_table:
# Third column is the result: # Third column is the result:
buildstatus[row[2]] += 1 buildstatus[row[2]] += 1

22
ecg.py
View File

@ -164,17 +164,19 @@ def builderror_identifier(output):
# The key is the category, the value is a tuple of error messages belonging to # The key is the category, the value is a tuple of error messages belonging to
# to this category: # to this category:
build_errors = { build_errors = {
"package_unavailable":("Unable to locate package"), "package_install_failed":("Unable to locate package", "error: failed to compile"),
"baseimage_unavailable":("manifest unknown: manifest unknown"), "baseimage_unavailable":("manifest unknown: manifest unknown",),
"dockerfile_not_found":("Dockerfile: no such file or directory") "dockerfile_not_found":("Dockerfile: no such file or directory",)
} }
# Last error found is the right one in theory:
found_error = "" found_error = ""
unknown_error = True unknown_error = True
for error_cat, error in build_errors.items(): for error_cat, error_msgs in build_errors.items():
if error in output: for error in error_msgs:
unknown_error = False if error in output:
found_error = error_cat unknown_error = False
found_error = error_cat
if unknown_error: if unknown_error:
found_error = "unknown_error" found_error = "unknown_error"
return found_error return found_error
@ -437,6 +439,12 @@ def main():
# log_path = "log.txt" # Output of the program # log_path = "log.txt" # Output of the program
# log_path = args.log_path # log_path = args.log_path
# Creating the output files to avoid complaints from Snakemake about missing
# outputs...
pathlib.Path(pkglist_path).touch()
pathlib.Path(buildstatus_path).touch()
pathlib.Path(arthashlog_path).touch()
# Setting up the log: # Setting up the log:
logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO) logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO)
# # Old version where the script writes its own log to the given file: # # Old version where the script writes its own log to the given file: