3b3ae2828a74b8c973a0e2197c7911390b728b50,recipy/log.py,,log_init,#,29

Before Change


    global RUN_ID

    // Open the database
    db = open_or_create_db()

    // Create the unique ID for this run
    guid = str(uuid.uuid4())



    // Get general metadata, environment info, etc
    run = {"unique_id": guid,
        "author": getpass.getuser(),
        "description": "",
        "inputs": [],
        "outputs": [],
        "script": scriptpath,
        "command": sys.executable,
        "environment": [platform.platform(), "python " + sys.version.split("\n")[0]],
        "date": datetime.datetime.utcnow(),
        "command_args": " ".join(cmd_args)}

    if not option_set("ignored metadata", "git"):
        try:
            repo = Repo(scriptpath, search_parent_directories=True)
            run["gitrepo"] = repo.working_dir
            run["gitcommit"] =  repo.head.commit.hexsha
            run["gitorigin"] = get_origin(repo)

            if not option_set("ignored metadata", "diff"):
                whole_diff = ""
                diffs = repo.index.diff(None, create_patch=True)
                for diff in diffs:
                    whole_diff += "\n\n\n" + diff.diff.decode("utf-8")

                run["diff"] = whole_diff
        except (InvalidGitRepositoryError, ValueError):
            // We can"t store git info for some reason, so just skip it
            pass

    // Put basics into DB
    RUN_ID = db.insert(run)

    // Print message
    if not option_set("general", "quiet"):
        print("recipy run inserted, with ID %s" % (guid))

    db.close()

    // Register exception hook so exceptions can be logged
    sys.excepthook = log_exception

After Change


    // A RUN_ID could have already been assigned.
    // This happens when a patched module was imported before recipy was
    // imported.
    if not RUN_ID:
        // Open the database
        db = open_or_create_db()

        // Create the unique ID for this run
        guid = str(uuid.uuid4())

        // Get general metadata, environment info, etc
        run = {
            "unique_id": guid,
            "author": getpass.getuser(),
            "description": "",
            "inputs": [],
            "outputs": [],
            "script": scriptpath,
            "command": sys.executable,
            "environment": [platform.platform(), "python " + sys.version.split("\n")[0]],
            "date": datetime.datetime.utcnow(),
            "command_args": " ".join(cmd_args),
            "warnings": []
        }

        if not option_set("ignored metadata", "git"):
            try:
                repo = Repo(scriptpath, search_parent_directories=True)
                run["gitrepo"] = repo.working_dir
                run["gitcommit"] = repo.head.commit.hexsha
                run["gitorigin"] = get_origin(repo)

                if not option_set("ignored metadata", "diff"):
                    whole_diff = ""
                    diffs = repo.index.diff(None, create_patch=True)
                    for diff in diffs:
                        whole_diff += "\n\n\n" + diff.diff.decode("utf-8")

                    run["diff"] = whole_diff
            except (InvalidGitRepositoryError, ValueError):
                // We can"t store git info for some reason, so just skip it
                pass

        // Put basics into DB
        RUN_ID = db.insert(run)

        // Print message
        if not option_set("general", "quiet"):
            print("recipy run inserted, with ID %s" % (guid))

        db.close()

        // Register exception hook so exceptions can be logged
        sys.excepthook = log_exception

def log_input(filename, source):
    if type(filename) is not str:
        try:
            filename = filename.name
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 3

Instances


Project Name: recipy/recipy
Commit Name: 3b3ae2828a74b8c973a0e2197c7911390b728b50
Time: 2016-03-23
Author: j.vanderzwaan@esciencecenter.nl
File Name: recipy/log.py
Class Name:
Method Name: log_init


Project Name: gooofy/zamia-speech
Commit Name: 85861ea5c5320518267405bef050a0dab933e069
Time: 2018-02-17
Author: guenter@zamia.org
File Name: phone_gen.py
Class Name:
Method Name:


Project Name: snorkel-team/snorkel
Commit Name: 8fb0987926a8e86c17ac516106b7a81c97b26505
Time: 2017-01-12
Author: stephenhbach@gmail.com
File Name: snorkel/models/meta.py
Class Name:
Method Name: set_sqlite_pragma