Skip to content

Doesn't seem to work "offline" #512

@mjones07

Description

@mjones07

With no internet connection, the library reaches out to check if there's and update (see below) even when the package is installed locally. I feel like I'm missing a setting to stop it from trying to update, but I can't find it.

import argostranslate.package

from argostranslate import translate


package_path = pathlib.Path(
    "~/.local/share/argos-translate/packages/translate-en_es-1_0.argosmodel"
)

argostranslate.package.install_from_path(package_path)


source_lang = "en"
target_lang = "es"

translation = translate.get_translation_from_codes(source_lang, target_lang)
print(translation)

print(translate.translate("hello", "en", "es"))
Traceback (most recent call last):
  File "/Users/matthew.j.jones/venv-argos/lib/python3.10/site-packages/urllib3/connection.py", line 204, in _new_conn
    sock = connection.create_connection(
  File "/Users/matthew.j.jones/venv-argos/lib/python3.10/site-packages/urllib3/util/connection.py", line 60, in create_connection
    for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
  File "/opt/homebrew/Cellar/python@3.10/3.10.13_2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/socket.py", line 955, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 8] nodename nor servname provided, or not known

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/matthew.j.jones/venv-argos/lib/python3.10/site-packages/urllib3/connectionpool.py", line 787, in urlopen
    response = self._make_request(
  File "/Users/matthew.j.jones/venv-argos/lib/python3.10/site-packages/urllib3/connectionpool.py", line 488, in _make_request
    raise new_e
  File "/Users/matthew.j.jones/venv-argos/lib/python3.10/site-packages/urllib3/connectionpool.py", line 464, in _make_request
    self._validate_conn(conn)
  File "/Users/matthew.j.jones/venv-argos/lib/python3.10/site-packages/urllib3/connectionpool.py", line 1093, in _validate_conn
    conn.connect()
  File "/Users/matthew.j.jones/venv-argos/lib/python3.10/site-packages/urllib3/connection.py", line 759, in connect
    self.sock = sock = self._new_conn()
  File "/Users/matthew.j.jones/venv-argos/lib/python3.10/site-packages/urllib3/connection.py", line 211, in _new_conn
    raise NameResolutionError(self.host, self, e) from e
urllib3.exceptions.NameResolutionError: HTTPSConnection(host='raw.githubusercontent.com', port=443): Failed to resolve 'raw.githubusercontent.com' ([Errno 8] nodename nor servname provided, or not known)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/matthew.j.jones/venv-argos/lib/python3.10/site-packages/requests/adapters.py", line 644, in send
    resp = conn.urlopen(
  File "/Users/matthew.j.jones/venv-argos/lib/python3.10/site-packages/urllib3/connectionpool.py", line 841, in urlopen
    retries = retries.increment(
  File "/Users/matthew.j.jones/venv-argos/lib/python3.10/site-packages/urllib3/util/retry.py", line 535, in increment
    raise MaxRetryError(_pool, url, reason) from reason  # type: ignore[arg-type]
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='raw.githubusercontent.com', port=443): Max retries exceeded with url: /stanfordnlp/stanza-resources/main/resources_1.10.0.json (Caused by NameResolutionError("HTTPSConnection(host='raw.githubusercontent.com', port=443): Failed to resolve 'raw.githubusercontent.com' ([Errno 8] nodename nor servname provided, or not known)"))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/matthew.j.jones/argos_test.py", line 49, in <module>
    print(translate.translate("hello", "en", "es"))
  File "/Users/matthew.j.jones/venv-argos/lib/python3.10/site-packages/argostranslate/translate.py", line 731, in translate
    return translation.translate(q)
  File "/Users/matthew.j.jones/venv-argos/lib/python3.10/site-packages/argostranslate/translate.py", line 64, in translate
    return self.hypotheses(input_text, num_hypotheses=1)[0].value
  File "/Users/matthew.j.jones/venv-argos/lib/python3.10/site-packages/argostranslate/translate.py", line 328, in hypotheses
    translated_paragraph = self.underlying.hypotheses(
  File "/Users/matthew.j.jones/venv-argos/lib/python3.10/site-packages/argostranslate/translate.py", line 201, in hypotheses
    apply_packaged_translation(
  File "/Users/matthew.j.jones/venv-argos/lib/python3.10/site-packages/argostranslate/translate.py", line 451, in apply_packaged_translation
    sentences = sentencizer.split_sentences(input_text)
  File "/Users/matthew.j.jones/venv-argos/lib/python3.10/site-packages/argostranslate/sbd.py", line 160, in split_sentences
    doc = self.lazy_pipeline()(text)
  File "/Users/matthew.j.jones/venv-argos/lib/python3.10/site-packages/argostranslate/sbd.py", line 149, in lazy_pipeline
    self.stanza_pipeline = stanza.Pipeline(
  File "/Users/matthew.j.jones/venv-argos/lib/python3.10/site-packages/stanza/pipeline/core.py", line 208, in __init__
    download_resources_json(self.dir,
  File "/Users/matthew.j.jones/venv-argos/lib/python3.10/site-packages/stanza/resources/common.py", line 459, in download_resources_json
    request_file(
  File "/Users/matthew.j.jones/venv-argos/lib/python3.10/site-packages/stanza/resources/common.py", line 157, in request_file
    download_file(url, temppath, proxies, raise_for_status)
  File "/Users/matthew.j.jones/venv-argos/lib/python3.10/site-packages/stanza/resources/common.py", line 119, in download_file
    r = requests.get(url, stream=True, proxies=proxies)
  File "/Users/matthew.j.jones/venv-argos/lib/python3.10/site-packages/requests/api.py", line 73, in get
    return request("get", url, params=params, **kwargs)
  File "/Users/matthew.j.jones/venv-argos/lib/python3.10/site-packages/requests/api.py", line 59, in request
    return session.request(method=method, url=url, **kwargs)
  File "/Users/matthew.j.jones/venv-argos/lib/python3.10/site-packages/requests/sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
  File "/Users/matthew.j.jones/venv-argos/lib/python3.10/site-packages/requests/sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
  File "/Users/matthew.j.jones/venv-argos/lib/python3.10/site-packages/requests/adapters.py", line 677, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='raw.githubusercontent.com', port=443): Max retries exceeded with url: /stanfordnlp/stanza-resources/main/resources_1.10.0.json (Caused by NameResolutionError("HTTPSConnection(host='raw.githubusercontent.com', port=443): Failed to resolve 'raw.githubusercontent.com' ([Errno 8] nodename nor servname provided, or not known)"))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions