d6f5a000bf5ff84b45185b2875cea604d0a9cf80,scripts/ai2_internal/resume_daemon.py,,main,#Any#,207

Before Change


    connection = sqlite3.connect(db_path)

    // TODO(brendanr): Just do this automatically?
    if args.action is Action.install:
        create_table(connection)
        current_crontab = subprocess.check_output(["crontab", "-l"], universal_newlines=True)
        full_path = os.path.abspath(__file__)
        // Execute this script every ten minutes. We set the PATH to that used
        // to run this install step to make sure that we have access to python3
        // and beaker.
        cron_line = (
            f"*/10 * * * * bash -c "export PATH={os.environ["PATH"]};"
            f" {full_path} --action=resume --random-delay-seconds=60"\n"
        )
        new_crontab = current_crontab + cron_line
        subprocess.run(["crontab", "-"], input=new_crontab, encoding="utf-8")
    elif args.action is Action.start:
        assert args.experiment_id
        start_autoresume(connection, args.experiment_id, args.max_resumes)
    elif args.action is Action.stop:
        assert args.experiment_id
        stop_autoresume(connection, args.experiment_id)
    elif args.action is Action.resume:
        beaker = BeakerWrapper()
        resume(connection, beaker)
    else:
        raise Exception(f"Unaccounted for action {args.action}")
    connection.close()


if __name__ == "__main__":

After Change


    cursor.execute(
        "SELECT name FROM sqlite_master WHERE type="table" AND name="active_experiments""
    )
    tables = cursor.fetchall()
    if not tables:
        create_table(connection)

    // Modify the crontab if needed.
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 4

Instances


Project Name: allenai/allennlp
Commit Name: d6f5a000bf5ff84b45185b2875cea604d0a9cf80
Time: 2019-10-18
Author: brendanr@allenai.org
File Name: scripts/ai2_internal/resume_daemon.py
Class Name:
Method Name: main


Project Name: probcomp/bayeslite
Commit Name: 0dd4c9216789e9c558e1d7ac82a36306efd773e3
Time: 2017-04-27
Author: fsaad@mit.edu
File Name: src/metamodels/cgpm_metamodel.py
Class Name: CGPM_Metamodel
Method Name: _engine


Project Name: probcomp/bayeslite
Commit Name: 507cf257bc195742af09b8990e77b13f4a10ab42
Time: 2017-06-17
Author: fsaad@mit.edu
File Name: src/metamodels/cgpm_metamodel.py
Class Name: CGPM_Metamodel
Method Name: initialize_models