<commit_before>import os
from jupyterhub.spawner import Spawner
from tornado import gen
from tornado.httputil import url_concat
from tornado.httpclient import AsyncHTTPClient, HTTPError
from kubespawner.utils import request_maker, k8s_url
from urllib.parse import urlparse, urlunparse
import json
import time
import string
from traitlets import Unicode, List, Integer


class KubeSpawner(Spawner):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        # By now, all the traitlets have been set, so we can use them to compute
        # other attributes
        self.httpclient = AsyncHTTPClient()
        # FIXME: Support more than just kubeconfig
        self.request = request_maker()
        self.pod_name = self._expand_user_properties(self.pod_name_template)
        if self.hub_connect_ip:
            scheme, netloc, path, params, query, fragment = urlparse(self.hub.api_url)
            netloc = '{ip}:{port}'.format(
                ip=self.hub_connect_ip,
                port=self.hub_connect_port,
            )
            self.accessible_hub_api_url = urlunparse((scheme, netloc, path, params, query, fragment))
        else:
            self.accessible_hub_api_url = self.hub.api_url

    namespace = Unicode(
        config=True,
        help='Kubernetes Namespace to create pods in'
    )

    def _namespace_default(self):
        """
        Set namespace default to current namespace if running in a k8s cluster
        """
        ns_path = '/var/run/secrets/kubernetes.io/serviceaccount/namespace'
        if os.path.exists(ns_path):
            with open(ns_path) as f:
                return f.read().strip()
        return 'default'

    pod_name_template = Unicode(
        'jupyter-{username}-{userid}',
        config=True,
        help='Template to generate pod names. Supports: {user} for username'
    )

    hub_connect_ip = Unicode(
        "",
        config=True,
        help='IP that containers should use to contact the hub'
    )<commit_msg>Set the default for hub_connect_ip to be None, not ''<commit_after>import os
from jupyterhub.spawner import Spawner
from tornado import gen
from tornado.httputil import url_concat
from tornado.httpclient import AsyncHTTPClient, HTTPError
from kubespawner.utils import request_maker, k8s_url
from urllib.parse import urlparse, urlunparse
import json
import time
import string
from traitlets import Unicode, List, Integer


class KubeSpawner(Spawner):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        # By now, all the traitlets have been set, so we can use them to compute
        # other attributes
        self.httpclient = AsyncHTTPClient()
        # FIXME: Support more than just kubeconfig
        self.request = request_maker()
        self.pod_name = self._expand_user_properties(self.pod_name_template)
        if self.hub_connect_ip:
            scheme, netloc, path, params, query, fragment = urlparse(self.hub.api_url)
            netloc = '{ip}:{port}'.format(
                ip=self.hub_connect_ip,
                port=self.hub_connect_port,
            )
            self.accessible_hub_api_url = urlunparse((scheme, netloc, path, params, query, fragment))
        else:
            self.accessible_hub_api_url = self.hub.api_url

    namespace = Unicode(
        config=True,
        help='Kubernetes Namespace to create pods in'
    )

    def _namespace_default(self):
        """
        Set namespace default to current namespace if running in a k8s cluster
        """
        ns_path = '/var/run/secrets/kubernetes.io/serviceaccount/namespace'
        if os.path.exists(ns_path):
            with open(ns_path) as f:
                return f.read().strip()
        return 'default'

    pod_name_template = Unicode(
        'jupyter-{username}-{userid}',
        config=True,
        help='Template to generate pod names. Supports: {user} for username'
    )

    hub_connect_ip = Unicode(
        None,
        config=True,
        allow_none=True,
        help='IP that containers should use to contact the hub'
    )
{'fraction_non_alphanumeric': 0.08514271773603319, 'fraction_numerical': 0.0009758477677482313, 'mean_word_length': 2.6123348017621146, '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': '2812126', 'n_tokens_mistral': 1206, 'n_tokens_neox': 1175, 'n_words': 333}