<commit_before>import os
import sys
import time
import functools

from . import schema

# Third-party dependencies
import pymongo
from bson.objectid import ObjectId

self = sys.modules[__name__]
self._client = None
self._database = None
self._collection = None
self._uri = os.getenv("MINDBENDER_MONGO", "mongodb://localhost:27017")
self._is_installed = False
self._is_activated = False
self._timeout = int(os.getenv("MINDBENDER_TIMEOUT", 1000))


def install():
    if self._is_installed:
        return

    self._client = pymongo.MongoClient(
        self._uri, serverSelectionTimeoutMS=self._timeout)
    self._database = self._client["mindbender"]

    for retry in range(3):
        try:
            t1 = time.time()
            self._client.server_info()

        except Exception:
            print("Retrying..")
            time.sleep(1)
            self._timeout *= 1.5

        else:
            break

    else:
        raise IOError("ERROR: Couldn't connect to %s in "
                      "less than %.3f ms" % (self._uri, self._timeout))

    print("Connected to server, delay %.3f s" % (time.time() - t1))
    self._is_installed = True


def activate_project(project):
    try:
        # Support passing dictionary object
        project = project["name"]
    except TypeError:<commit_msg>Add `active_project()` to `io.py`<commit_after>import os
import sys
import time
import functools

from . import schema

# Third-party dependencies
import pymongo
from bson.objectid import ObjectId

self = sys.modules[__name__]
self._client = None
self._database = None
self._collection = None
self._uri = os.getenv("MINDBENDER_MONGO", "mongodb://localhost:27017")
self._is_installed = False
self._is_activated = False
self._timeout = int(os.getenv("MINDBENDER_TIMEOUT", 1000))


def install():
    if self._is_installed:
        return

    self._client = pymongo.MongoClient(
        self._uri, serverSelectionTimeoutMS=self._timeout)
    self._database = self._client["mindbender"]

    for retry in range(3):
        try:
            t1 = time.time()
            self._client.server_info()

        except Exception:
            print("Retrying..")
            time.sleep(1)
            self._timeout *= 1.5

        else:
            break

    else:
        raise IOError("ERROR: Couldn't connect to %s in "
                      "less than %.3f ms" % (self._uri, self._timeout))

    print("Connected to server, delay %.3f s" % (time.time() - t1))
    self._is_installed = True


def active_project():
    """Return the name of the active project collection."""
    return self._collection.name


def activate_project(project):
    try:
        # Support passing dictionary object
        project = project["name"]
    except TypeError:
{'fraction_non_alphanumeric': 0.10738987986894795, 'fraction_numerical': 0.012377138696760102, 'mean_word_length': 2.634920634920635, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6152802', 'n_tokens_mistral': 851, 'n_tokens_neox': 804, 'n_words': 212}