# Resultbag Management {attr}`resultbag.management ` provides advanced methods to maintain a {term}`Resultbag` and connect it to solve execution. Use the read operations on the [Resultbag](index.md) page for normal result analysis. These methods can add, replace, inspect, and delete {term}`Resultbag entries `. Resultbag entries are stored as versioned dictionaries. A dictionary stores named values. The management {meth}`get_result ` and {meth}`items() ` operations expose that stored data. Use {meth}`resultbag.get_results ` to return selected entries as current solve results. See the [Manage resultbag entries tutorial](../tutorials/resultbag/management.md) for a runnable workflow that uses stored dictionaries without a project. ## Add And Inspect Entries Use {term}`project keys` and an optional {term}`JCMT pattern` to identify one {term}`Resultbag` entry. ```python resultbag.management.add( keys={"material": "Si", "radius": 0.5}, result=result, log=None, jcmt_pattern="mie", ) resultbag.management.check_result( {"material": "Si", "radius": 0.5}, jcmt_pattern="mie", ) resultbag.management.get_result( {"material": "Si", "radius": 0.5}, jcmt_pattern="mie", ) resultbag.management.get_log( {"material": "Si", "radius": 0.5}, jcmt_pattern="mie", ) ``` {meth}`resultbag.management.add ` adds or replaces the entry identified by the project keys and JCMT pattern. {meth}`resultbag.management.check_result ` returns `True` when the exact entry exists. {meth}`resultbag.management.get_result ` returns one stored result dictionary. Use {meth}`resultbag.get_results ` when you need normal result selection. Use {meth}`resultbag.management.get_log ` to retrieve the stored execution log. Resultbags created by older interfaces can be opened for maintenance and reset. Accessing their old result entries raises an unsupported-format error. ## Manage Attempt Logs Attempt logs store diagnostics for repeated solve attempts. The attempt index starts at `0`. {meth}`resultbag.management.get_attempt_logs ` returns the logs in ascending attempt index order. ```python resultbag.management.add_attempt_log( keys={"radius": 0.5}, attempt_index=0, payload={"status": "failed"}, ) logs = resultbag.management.get_attempt_logs({"radius": 0.5}) resultbag.management.clear_attempt_logs({"radius": 0.5}) ``` Use {meth}`add_attempt_log ` to store diagnostics and {meth}`clear_attempt_logs ` to remove them. ## Remove And Reset Entries ```python resultbag.management.remove_result( {"radius": 0.5}, jcmt_pattern="mie", ) resultbag.management.remove( filter_function=lambda project_keys: project_keys.get("material") == "Si" ) resultbag.management.reset() ``` {meth}`resultbag.management.remove_result ` removes one Resultbag entry and its attempt logs. {meth}`resultbag.management.remove ` removes every entry for which the {term}`filter function` returns `True`. It also removes suffix versions and attempt logs for those entries. {meth}`resultbag.management.reset() ` removes all stored entries and attempt logs but keeps Resultbag metadata. ## Check Source Files Resultbag source-file checks use stored file hashes. Use these operations when you need to check whether the project inputs still match the stored Resultbag metadata. ```python resultbag.management.set_source_files(["project.jcmp", "layout.jcm"]) matches = resultbag.management.check_source_files( ["project.jcmp", "layout.jcm"] ) resultbag.management.ignore_source_files() ``` {meth}`resultbag.management.set_source_files ` raises {class}`InvalidConfigurationError ` when a path is missing or is not a regular file. {meth}`resultbag.management.check_source_files ` returns `False` when the current files do not match the stored hashes. It also returns `False` when no source-file metadata exists. {meth}`resultbag.management.ignore_source_files() ` turns off the source-file comparison and makes the check return `True`. ## Execution Integration These methods support solve execution. Normal user code does not need to call them. The execution methods are {meth}`bind_job `, {meth}`store_job_result `, and {meth}`release_job `. ```python resultbag.management.bind_job( keys={"radius": 0.5}, job_id=job_id, jcmt_pattern="mie", ) resultbag.management.store_job_result( job_id=job_id, result=result, log=log, ) resultbag.management.release_job(job_id) ``` See the [Resultbag API](../reference/resultbag.md) for generated management signatures and method descriptions.