Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Download failed" Error #380

Open
tomere9 opened this issue Dec 28, 2023 · 0 comments
Open

"Download failed" Error #380

tomere9 opened this issue Dec 28, 2023 · 0 comments

Comments

@tomere9
Copy link

tomere9 commented Dec 28, 2023

tl;dr:

  1. Problem in downloading the language package programmatically by the library -> raises a runtime error: "Download failed for..."
  2. Another possible problem: the language packages names that the library expects are different that the names of the downloaded packages.

Elaborated:
I tried copying the example code for Python, supplied in the main GitHub page:

import argostranslate.package
import argostranslate.translate

from_code = "en"
to_code = "es"

# Download and install Argos Translate package
argostranslate.package.update_package_index()
available_packages = argostranslate.package.get_available_packages()
package_to_install = next(
    filter(
        lambda x: x.from_code == from_code and x.to_code == to_code, available_packages
    )
)
argostranslate.package.install_from_path(package_to_install.download())

# Translate
translatedText = argostranslate.translate.translate("Hello World", from_code, to_code)
print(translatedText)
# '¡Hola Mundo!'

and now I get an error: "Download failed for English → Spanish."

I tried to debug it, and it seems that there is a strange behavior when attempting to install the language package:
When I looked at this line:
argostranslate.package.install_from_path(package_to_install.download())
and then inside the 'download()' method, I saw that the method tries to find a path 'filepath' to the en->es package:

filename = argospm_package_name(self) + ".argosmodel"
...
filepath = settings.downloads_dir / filename

and it didn't find this 'filepath', and so it calls the 'get_from' method to download the data:
data = networking.get_from(self.links)
yet it returned data = None, and that's what raised the error.

I then looked into the 'get_from' method, where it seems to attempt downloading the missing en->es package from the links supplied in the arguments, and it somehow fails to do that by its own. However, when I open the "https://..." link in my browser , the browser succeeds to install the package (in my user downloads folder...). So it is not clear why the package couldn't be installed automatically at the first place.

That is my main problem, as it prevents even the sample script from working, but further investigation reveals another problem:

When I looked at the name of the downloaded package, it was: 'translate-en_es-1_0.argosmodel', but looking back at the filename that the 'download()' method tried to find, it was directed to a package named 'translate-en_es.argosmodel' - so even after downloading the package to the right folder, the 'filepath' won't be found, as the downloaded package's name is different than the searched one. From what I understand this lead to installing the package every time the function is called, even if there is a relevant package already installed (but with an unexpected name to the script).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant