Aluriak / PowerGrASP

Compress graphs
12 stars 1 forks source link

Options not handled with new version of clyngor having clingo as dependency. #1

Open ArnaudBelcour opened 2 years ago

ArnaudBelcour commented 2 years ago

Hi,

While using powergrasp in metage2metabo, I encountered the following error:

Traceback (most recent call last):
  File "/usr/local/bin/m2m_analysis", line 33, in <module>
    sys.exit(load_entry_point('Metage2Metabo', 'console_scripts', 'm2m_analysis')())
  File "/shared/programs/metage2metabo/metage2metabo/__main_analysis__.py", line 292, in main
    main_analysis_workflow(network_dir, args.targets, args.seeds, args.out, args.taxon,
  File "/shared/programs/metage2metabo/metage2metabo/__main_analysis__.py", line 307, in main_analysis_workflow
    run_analysis_workflow(*allargs)
  File "/shared/programs/metage2metabo/metage2metabo/m2m_analysis/m2m_analysis_workflow.py", line 48, in run_analysis_workflow
    powergraph_analysis(gml_output, output_dir, oog_jar, taxon_file, taxonomy_level)
  File "/shared/programs/metage2metabo/metage2metabo/m2m_analysis/graph_compression.py", line 153, in powergraph_analysis
    compression(gml_input_path, bbl_output)
  File "/shared/programs/metage2metabo/metage2metabo/m2m_analysis/graph_compression.py", line 213, in compression
    for line in powergrasp.compress_by_cc(gml_input):
  File "/shared/programs/PowerGrASP/powergrasp/routines.py", line 201, in compress_by_cc
    yield from compress(graph, cc_idx=idx, recipe=recipe_for(graph))
  File "/shared/programs/PowerGrASP/powergrasp/routines.py", line 96, in compress
    best_motifs = search_best_motifs(searchers, step, recipe=recipe_line)
  File "/shared/programs/PowerGrASP/powergrasp/routines.py", line 35, in search_best_motifs_sequentially
    motifs = MotifBatch(searcher.search(step, score_to_beat, recipe=recipe))
  File "/shared/programs/PowerGrASP/powergrasp/motif_batch.py", line 18, in __init__
    self.motifs = tuple(motifs)
  File "/shared/programs/PowerGrASP/powergrasp/searchers.py", line 123, in search
    yield from (
  File "/shared/programs/PowerGrASP/powergrasp/searchers.py", line 123, in <genexpr>
    yield from (
  File "/shared/programs/PowerGrASP/powergrasp/searchers.py", line 278, in _search
    yield from asp.solve_motif_search(step, lowerbound, upperbound,
  File "/shared/programs/PowerGrASP/powergrasp/asp.py", line 37, in multishot_motif_search
    all_models = _build_solver(step, lowerbound, upperbound, files, graph, options='--opt-mode=optN ' + options)
  File "/shared/programs/PowerGrASP/powergrasp/asp.py", line 19, in _build_solver
    models = clyngor.solve(files=tuple(files), inline=str(graph), constants=constants, stats=False, options=options)
  File "/shared/programs/clyngor/clyngor/solving.py", line 92, in solve
    raise ValueError("Options 'time_limit' and 'constants' are not "
ValueError: Options 'time_limit' and 'constants' are not handled when used with python clingo module.

This issue occurs recently (with Python 3.8.10 and the github version of powergrasp 0.8.19.dev0) and I think it is linked to the release of clyngor 0.4.1 and especially the fact the clingo python package is now a dependency of clyngor. Due to this, the clingo package is always available so the variable use_clingo_module is always set to True and leads to this error.

Putting a use_clingo_module=False in clyngor call solves the issue for me. But maybe there is a better way to handle this.

Aluriak commented 2 years ago

Your diagnostic is right ; this changes a lot for clyngor, which suddenly doesn't need a large part of its source code and will be simplifiable, once the difference between clingo module and binary will be worked out (especially, as you point it out, time limit and constants options).

For the moment, please use your fix, or call clyngor.use_clingo_binary() right after importing the clyngor package.