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

A bit hard to find and run eland_import_hub_model on Windows #551

Closed
sakurai-youhei opened this issue Jun 26, 2023 · 2 comments · Fixed by #559
Closed

A bit hard to find and run eland_import_hub_model on Windows #551

sakurai-youhei opened this issue Jun 26, 2023 · 2 comments · Fixed by #559

Comments

@sakurai-youhei
Copy link
Member

Right after pip install eland, neither python -m eland nor eland_import-hub-model works on Windows.

C:\Users\YouheiSakurai>python -m eland
C:\Program Files\Python311\python.exe: No module named eland.__main__; 'eland' is a package and cannot be directly executed

C:\Users\YouheiSakurai>eland_import_hub_model
'eland_import_hub_model' is not recognized as an internal or external command,
operable program or batch file.
  1. python -m eland doesn't work because no of eland.__main__.
  2. eland_import-hub-model doesn't work because scripts is used instead of console_scripts in setup.py.

image

As the above picture shows, eland_import_hub_model is not executable on Windows due to no file extension like .exe.

I will open a PR to solve this hassle on Windows.

@xuanyuanbao
Copy link

I also has error。what i can do make it work?

@xuanyuanbao
Copy link

xuanyuanbao commented Dec 4, 2024

I also has error。what i can do make it work?

oh,thanks me, I have resolve this problem,it my code instead to eland_import_hub_model in shell,it works where your computer operation system is Windows。

secondly, my elasticsearch version is 8.6.0, but elasticsearch 8.7.0 also works

import elasticsearch
from pathlib import Path
from eland.ml.pytorch import PyTorchModel
from eland.ml.pytorch.transformers import TransformerModel

# Load a Hugging Face transformers model directly from the model hub
tm = TransformerModel("sentence-transformers/clip-ViT-B-32-multilingual-v1", "text_embedding")

# Export the model in a TorchScrpt representation which Elasticsearch uses
tmp_path = "models"
Path(tmp_path).mkdir(parents=True, exist_ok=True)
model_path, config, vocab_path = tm.save(tmp_path)

ca_certs_path = "../app/conf/ca.crt"
# Import model into Elasticsearch
es = elasticsearch.Elasticsearch("https://elastic:[email protected]:9200",
                                 ca_certs=ca_certs_path,
                                 verify_certs=True, timeout=300)  # 5 minute timeout

ptm = PyTorchModel(es, tm.elasticsearch_model_id())
ptm.import_model(model_path=model_path, config_path=None, vocab_path=vocab_path, config=config)

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