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

Fail transparently for failed output accumulation #278

Merged
merged 1 commit into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
15 changes: 9 additions & 6 deletions alphadia/outputtransform.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@
logger = logging.getLogger()


class OutputGenerationError(Exception):
"""Raised when an error occurs during output generation"""

pass


def get_frag_df_generator(folder_list: list[str]):
"""Return a generator that yields a tuple of (raw_name, frag_df)

Expand Down Expand Up @@ -509,20 +515,17 @@ def build_precursor_table(

if not os.path.exists(psm_path):
logger.warning(f"no psm file found for {raw_name}, skipping")
run_df = pd.DataFrame()
else:
try:
run_df = pd.read_parquet(psm_path)
psm_df_list.append(run_df)
except Exception as e:
logger.warning(f"Error reading psm file for {raw_name}")
logger.warning(e)
run_df = pd.DataFrame()

psm_df_list.append(run_df)

if len(psm_df_list) == 0:
logger.error("No psm files found, can't continue")
raise FileNotFoundError("No psm files found, can't continue")
logger.error("No psm files accumulated, can't continue")
raise OutputGenerationError("No psm files accumulated, can't continue")
GeorgWa marked this conversation as resolved.
Show resolved Hide resolved

logger.info("Building combined output")
psm_df = pd.concat(psm_df_list)
Expand Down
17 changes: 6 additions & 11 deletions alphadia/planning.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,18 +370,13 @@ def run(
)
raise e

try:
base_spec_lib = SpecLibBase()
base_spec_lib.load_hdf(
os.path.join(self.output_folder, "speclib.hdf"), load_mod_seq=True
)

output = outputtransform.SearchPlanOutput(self.config, self.output_folder)
output.build(workflow_folder_list, base_spec_lib)
base_spec_lib = SpecLibBase()
base_spec_lib.load_hdf(
os.path.join(self.output_folder, "speclib.hdf"), load_mod_seq=True
)

except Exception as e:
logger.error(f"Output failed with error {e}", exc_info=True)
raise e
output = outputtransform.SearchPlanOutput(self.config, self.output_folder)
output.build(workflow_folder_list, base_spec_lib)

logger.progress("=================== Search Finished ===================")

Expand Down
Loading