label-studio icon indicating copy to clipboard operation
label-studio copied to clipboard

Deploy offline

Open turkeymz opened this issue 2 years ago • 10 comments

Same as https://github.com/heartexlabs/label-studio/issues/3940#event-8919569453

The server can't deploy in offline env? Suggest using default values if unable to access the external network.

turkeymz avatar Apr 04 '23 03:04 turkeymz

Please show full logs.

makseq avatar Apr 04 '23 03:04 makseq

Please show full logs. Thanks for your reply. Here is the full logs

# label-studio -b --data-dir /home/jxbd/labelstudio/mydata -p 5008 --host 0.0.0.0 --password jxbd123  --username admin start

=> Database and media directory: /root/.local/share/label-studio
=> Static URL is set to: /static/
=> Database and media directory: /root/.local/share/label-studio
=> Static URL is set to: /static/
Starting new HTTPS connection (1): pypi.org:443
Can't get latest version
Traceback (most recent call last):
  File "/root/.local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 703, in urlopen
    httplib_response = self._make_request(
  File "/root/.local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 386, in _make_request
    self._validate_conn(conn)
  File "/root/.local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 1042, in _validate_conn
    conn.connect()
  File "/root/.local/lib/python3.8/site-packages/urllib3/connection.py", line 414, in connect
    self.sock = ssl_wrap_socket(
  File "/root/.local/lib/python3.8/site-packages/urllib3/util/ssl_.py", line 449, in ssl_wrap_socket
    ssl_sock = _ssl_wrap_socket_impl(
  File "/root/.local/lib/python3.8/site-packages/urllib3/util/ssl_.py", line 493, in _ssl_wrap_socket_impl
    return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
  File "/usr/local/python3/lib/python3.8/ssl.py", line 500, in wrap_socket
    return self.sslsocket_class._create(
  File "/usr/local/python3/lib/python3.8/ssl.py", line 1040, in _create
    self.do_handshake()
  File "/usr/local/python3/lib/python3.8/ssl.py", line 1309, in do_handshake
    self._sslobj.do_handshake()
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/python3/lib/python3.8/site-packages/requests/adapters.py", line 440, in send
    resp = conn.urlopen(
  File "/root/.local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 787, in urlopen
    retries = retries.increment(
  File "/root/.local/lib/python3.8/site-packages/urllib3/util/retry.py", line 550, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/root/.local/lib/python3.8/site-packages/urllib3/packages/six.py", line 769, in reraise
    raise value.with_traceback(tb)
  File "/root/.local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 703, in urlopen
    httplib_response = self._make_request(
  File "/root/.local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 386, in _make_request
    self._validate_conn(conn)
  File "/root/.local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 1042, in _validate_conn
    conn.connect()
  File "/root/.local/lib/python3.8/site-packages/urllib3/connection.py", line 414, in connect
    self.sock = ssl_wrap_socket(
  File "/root/.local/lib/python3.8/site-packages/urllib3/util/ssl_.py", line 449, in ssl_wrap_socket
    ssl_sock = _ssl_wrap_socket_impl(
  File "/root/.local/lib/python3.8/site-packages/urllib3/util/ssl_.py", line 493, in _ssl_wrap_socket_impl
    return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
  File "/usr/local/python3/lib/python3.8/ssl.py", line 500, in wrap_socket
    return self.sslsocket_class._create(
  File "/usr/local/python3/lib/python3.8/ssl.py", line 1040, in _create
    self.do_handshake()
  File "/usr/local/python3/lib/python3.8/ssl.py", line 1309, in do_handshake
    self._sslobj.do_handshake()
urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/python3/lib/python3.8/site-packages/label_studio/core/utils/common.py", line 339, in get_latest_version
    response = requests.get(pypi_url, timeout=10).text
  File "/usr/local/python3/lib/python3.8/site-packages/requests/api.py", line 75, in get
    return request('get', url, params=params, **kwargs)
  File "/usr/local/python3/lib/python3.8/site-packages/requests/api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/python3/lib/python3.8/site-packages/requests/sessions.py", line 529, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/python3/lib/python3.8/site-packages/requests/sessions.py", line 645, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/python3/lib/python3.8/site-packages/requests/adapters.py", line 501, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))
Traceback (most recent call last):
  File "/usr/local/python3/bin/label-studio", line 8, in <module>
    sys.exit(main())
  File "/usr/local/python3/lib/python3.8/site-packages/label_studio/server.py", line 296, in main
    _setup_env()
  File "/usr/local/python3/lib/python3.8/site-packages/label_studio/server.py", line 40, in _setup_env
    application = get_wsgi_application()
  File "/usr/local/python3/lib/python3.8/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
    django.setup(set_prefix=False)
  File "/usr/local/python3/lib/python3.8/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/usr/local/python3/lib/python3.8/site-packages/django/apps/registry.py", line 114, in populate
    app_config.import_models()
  File "/usr/local/python3/lib/python3.8/site-packages/django/apps/config.py", line 301, in import_models
    self.models_module = import_module(models_module_name)
  File "/usr/local/python3/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 843, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/usr/local/python3/lib/python3.8/site-packages/django/contrib/auth/models.py", line 3, in <module>
    from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
  File "/usr/local/python3/lib/python3.8/site-packages/django/contrib/auth/base_user.py", line 48, in <module>
    class AbstractBaseUser(models.Model):
  File "/usr/local/python3/lib/python3.8/site-packages/django/db/models/base.py", line 122, in __new__
    new_class.add_to_class('_meta', Options(meta, app_label))
  File "/usr/local/python3/lib/python3.8/site-packages/django/db/models/base.py", line 326, in add_to_class
    value.contribute_to_class(cls, name)
  File "/usr/local/python3/lib/python3.8/site-packages/django/db/models/options.py", line 207, in contribute_to_class
    self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
  File "/usr/local/python3/lib/python3.8/site-packages/django/utils/connection.py", line 15, in __getattr__
    return getattr(self._connections[self._alias], item)
  File "/usr/local/python3/lib/python3.8/site-packages/django/utils/connection.py", line 62, in __getitem__
    conn = self.create_connection(alias)
  File "/usr/local/python3/lib/python3.8/site-packages/django/db/utils.py", line 204, in create_connection
    backend = load_backend(db['ENGINE'])
  File "/usr/local/python3/lib/python3.8/site-packages/django/db/utils.py", line 111, in load_backend
    return import_module('%s.base' % backend_name)
  File "/usr/local/python3/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/usr/local/python3/lib/python3.8/site-packages/django/db/backends/sqlite3/base.py", line 73, in <module>
    check_sqlite_version()
  File "/usr/local/python3/lib/python3.8/site-packages/django/db/backends/sqlite3/base.py", line 68, in check_sqlite_version
    raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: SQLite 3.9.0 or later is required (found 3.7.17).
Sentry is attempting to send 2 pending error messages
Waiting up to 2 seconds
Press Ctrl-C to quit

turkeymz avatar Apr 04 '23 06:04 turkeymz

It seems LS works as expected, just ignore this error message.

makseq avatar Apr 06 '23 01:04 makseq

It seems LS works as expected, just ignore this error message.

But LS can't ignore this error.When this error occurs, LS will automatically stop the thread. It seems that LS calling pypi.org is just getting the version. Is there any way to make LS stop calling pypi.org and deploy offline?

turkeymz avatar Apr 07 '23 03:04 turkeymz

If you set env variable LABEL_STUDIO_LATEST_VERSION_CHECK=False this check will be skipped

farioas avatar Apr 10 '23 12:04 farioas

Sorry, I was wrong, seems it can be deployed offline

turkeymz avatar Apr 11 '23 00:04 turkeymz

If you set env variable LABEL_STUDIO_LATEST_VERSION_CHECK=False this check will be skipped

This does not seem to do anything.

While I can deploy label-studio offline, it is incredibly slow because so many operations result in this check, which tries to connect to a url until it fails a few times. Is this deprecated? Is there a different way to turn this behavior off?

Adamits avatar Jun 17 '24 23:06 Adamits

The code related to version check is here: https://github.com/HumanSignal/label-studio/blob/develop/label_studio/core/utils/common.py#L394

If LABEL_STUDIO_LATEST_VERSION_CHECK set to False it will exit the function.

farioas avatar Jun 21 '24 09:06 farioas

It's also not working for me.

I did some digging and I found the variable LABEL_STUDIO_LATEST_VERSION_CHECK in the base settings file (https://github.com/HumanSignal/label-studio/blob/develop/label_studio/core/settings/base.py#L523) but it looks like it's hard coded to always be True.

wfoglema avatar Jun 26 '24 16:06 wfoglema

/jira create

Workflow run Jira issue TRIAG-632 is created

farioas avatar Jun 26 '24 19:06 farioas