Uploading ML Models into Elasticsearch

I am trying to upload ML Model into elasticsearch using the eland script provided in the documentation.

Installed Python, eland & Pytorch but still unable to upload.
python version : Python 3.7.9
Eland version : 8.3.0
torch version : 1.11.0

Below is the script i am executing
eland_import_hub_model --url http://localhost:9200/ --hub-model-id openai/clip-vit-large-patch14 --task-type ner --start

But facing this error 'eland_import_hub_model' is not recognized as an internal or external command,operable program or batch file.


Hey @ksaimohan2k glad to hear you're interested in uploading models with eland! It sounds like the installed eland and eland_import_hub_model script is not being found on you system. Are you on Windows or macOS or Linux? I'd recommend trying out the Docker approach as well, as it's a bit more reliable across various operating systems.

See here for instructions: GitHub - elastic/eland: Python Client and Toolkit for DataFrames, Big Data, Machine Learning and ETL in Elasticsearch

1 Like

Thank you for the quick response @joshdevins. I am actually working on windows OS.

Hi @joshdevins even in docker i am facing the same issue i am able to see in folders within path that eland_import_hub_model existed but when i am execuitng the command facing the error

C:\Users\SaiMohan\eland\bin>docker run -it --rm --network host eland_import_hub_model --url http://localhost:9200/   --hub-model-id openai/clip-vit-large-patch14  --task-type ner --start
Unable to find image 'eland_import_hub_model:latest' locally
docker: Error response from daemon: pull access denied for eland_import_hub_model, repository does not exist or may require 'docker login': denied: requested access to the resource is denied

Hey @ksaimohan2k I'm sorry for the difficulties you're facing. We acknowledge that the current process is a bit complicated and are working hard to improve the tools for model upload.

I believe the original problem you are encountering might be due to a known bug we have with eland on Windows. If you subscribe to that GitHub issue, you will get notifications about fixes.

For Docker, you have to make sure you build the container first:

$ docker build -t elastic/eland .

Was this successful?

1 Like

Yes, the build was successful. Sorry if I am wasting your time; I am a bit new to all this and am trying to catch up. Thank You for spending your valuable time.

  1. I cloned the using git git clone git@github.com:elastic/eland.git
  2. The i executed the command for build
cd /path-to-repository/eland
docker build -t elastic/eland .

After this I am getting little confused about below command like where to run it within cmd because running the container I am getting # prompt where I am facing issue.

 $ docker run -it --rm --network host \
    elastic/eland \
    eland_import_hub_model \
      --url http://host.docker.internal:9200/ \
      --hub-model-id elastic/distilbert-base-cased-finetuned-conll03-english \
      --task-type ner

Thanks for your concern and help @joshdevins .

Let's see if we can get you up and running!

The Docker container should be run from in the directory where you cloned eland. Don't include the $ in the command to run though.

1 Like

Hey @joshdevins I am running that command in directory where I cloned eland.
Sorry if my syntax is bad I am new to docker. I am attaching below error for the reference.

Thanks for you time.

I think in Windows you have to remove the \ that are separating lines in the Linux/macOS examples. If it's a Docker problem, then I'm afraid it'll be hard for me to debug remotely. I'd look around for the error string on Google and in Docker forums to see if you can get the container running.

1 Like

I tried removing \

Its sating /usr/bin/env: 'python\r': No such file or directory

Thank You

Ok, this is helpful. I think this is a bug with running on Windows. It might be possible to just do this in two steps:

docker run -it --rm --network host elastic/eland

And then when you get dropped into the container and get the Linux prompt (the #), try the second part of the command:

eland_import_hub_model --url http://host.docker.internal:9200/ --hub-model-id elastic/distilbert-base-cased-finetuned-conll03-english --task-type ner
1 Like

made the changes, still the error this error remains same. I even tried it in docker desktop terminal.


Yeah that trailing \r appears to be the problem. This looks like a Windows/Linux incompatibility for some reason in the script. This is a bit odd as the script in git doesn't have that trailing \r character. I'm not sure how to explain how this ended up. I know this works on macOS and Linux, do you possibly have access to a different machine to run this command from?

I think you might have to otherwise wait until this other bug is fixed.

1 Like

Thanks, @joshdevins, for the info. I will try it shortly with Other OS Machines.
I will try to update you using this thread.

I am even thinking of alternative methods for importing models into Elasticsearch.

Thank you for actively participating. Thanks for your valuable time.

Happy to help. Unfortunately for now, you must use eland for uploads as it also prepares the model to be used in Elasticsearch and this can't be done in any other tool for now.

We definitely recognise the difficulties with eland so we hope to also have alternative model upload tools in the future.

1 Like

Let's hope a remedy comes soon. I'll test out tasks with various Operating Systems in the interim.

Thank you for your help @joshdevins

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.