MLflow - Serving model by reference to model registry - mlflow

I'm having an issue to serve a model with reference to model registry. According to help, the path should look like this:
models:/model_name/stage
When I type in terminal:
mlflow models serve -m models:/ml_test_model1/Staging --no-conda -h 0.0.0.0 -p 5003
I got the error:
mlflow.exceptions.MlflowException: Not a proper models:/ URI: models:/ml_test_model1/Staging/MLmodel. Models URIs must be of the form 'models:/<model_name>/<version or stage>'.
Model is registered and visible in db and server.
If I put absolute path, it works (experiment_id/run_id/artifacts/model_name).
mlflow version: 1.4
Python version: 3.7.3
Is it matter of some environmental settings or something different?

That style of referencing model artefacts is fixed from mlflow v1.5 (Bug Fix).
You'll need to run mlflow db upgrade <db uri> to refresh your schemas before restarting your mlflow server.
You may find listing registered models helpful:
<server>:<port>/api/2.0/preview/mlflow/registered-models/list

setting the env solved this for me:
export MLFLOW_TRACKING_URI=http://localhost:5000
mlflow models serve models:/my_clf_model/Staging -p 1234 -h 0.0.0.0 --no-conda

Related

Mlflow - empty artifact folder

All,
I started the mlflow server as below. I do see the backend store containing the expected metadata. However, the artifact folder is empty despite many runs.
> mlflow server --backend-store-uri mlflow_db --default-artifact-root
> ./mlflowruns --host 0.0.0.0 --port 5000
The mlflow ui has the below message for the artifacts section:
No Artifacts Recorded
Use the log artifact APIs to store file outputs from MLflow runs.
What am I doing wrong?
Thanks,
grajee
Turns out that
"--backend-store-uri mlflow_db" was pointing to D:\python\Pythonv395\Scripts\mlflow_db
and
"--default-artifact-root ./mlflowruns" was pointing to D:\DataEngineering\MlFlow\Wine Regression\mlflowruns which is the project folder.
I was able to point both the output to one folder with the following syntax
file:/D:/DataEngineering/MlFlow/Wine Regression
In case you want to log artifacts to your server with local file system as object storage, you should specify --serve-artifact --artifact-destination file:/path/to/your/desired/location instead of just a vanilla path.

How to fix 'incorrect artifact/model path on HDFS showing on MLflow server'

I run a mlflow server with the following command using mlflow, version 1.2.0
mlflow server --host myhost -p myport --backend-store-uri mysql://user#localhost/mlflow --default-artifact-root hdfs://myhost/user/myid/mlflow_test
I run the experiment from MLflow tutorial quickstart https://www.mlflow.org/docs/latest/quickstart.html
the command:
mlflow run sklearn_elasticnet_wine -P alpha=0.5 --no-conda
the code to log the model is
mlflow.sklearn.log_model(lr, "model")
in
https://github.com/mlflow/mlflow/blob/master/examples/sklearn_elasticnet_wine/train.py
I visit the server by webbrowser myhost: myport and check the run I ran.
I successfully get the ran info by myhost: myport/#/experiments/0/runs/run_id
in this page, i found that the first layer (model directory) path is correct. that is, run_id/artifacts/model
correct path
but once I click the MLmodel file under model folder, the path get wrong:
I expect to see run_id/artifacts/model/MLmodel
but actually it was run_id/artifacts/MLmodel
wrong path

Rasa chatbot : Retrieving conversation data

I am trying to build a chatbot using RASA. For now, I am running my chatbot locally on a Ubuntu shell. I'd like to be able to retrieve my conversation data ; from RASA's documentation, it seems to be possible, but the documentation only addresses the case when the bot is running on a http server : link
You can add a Mongo or Redis tracker store which stores all the conversations data in a database. Do so by adding a section like this to your endpoint configuration:
tracker_store:
store_type: mongod
url: <url to your mongo instance, e.g. mongodb://localhost:27017>
db: <name of the db within your mongo instance, e.g. rasa>
username: <username used for authentication>
password: <password used for authentication>
Then specify this file with --endpoints when you run Rasa Core, e.g.
python -m rasa_core.run -d models --endpoints endpoints.yml
The alternative would be to run Rasa Core with the exposed Rest API, e.g.
python -m rasa_core.run -d models --enable-api
Then you can access the conversations with HTTP requests as documented here, e.g.:
curl --request GET \
--url http://localhost:5005/conversations/<sender_id>/tracker

Import and add index to mongodb on a Dokku install

I have a recently deployed app on an Ubuntu server using Dokku. This is a Node.js app with a Mongodb database.
For the site to work properly I need to to load geojson file in the database. On my development machine this was done from the ubuntu command line using the mongoimport command. I can't figure out how to do this in Dokku.
I also need to add a geospatial index. This was done from the mongo console on my development machine. I also cant figure out how to do that on the Dokku install.
Thanks a lot #Jonathan. You helped me solve this problem. Here is what I did.
I used mongodump on my local machine to create a backup file of the database. It defaulted to a .bson file.
I uploaded that file to my remote server. On the remote server I put the bson file inside a folder called "dump". Then tarred that folder. I initially used the -z flag out of habit but mongo/dokku didn't like the gzip. So I used tar with no compression like so:
tar -cvf dump.tar dump
next I ran the dokku mongo import command:
$dokku mongo:import mongo_claims < dump.tar
2016-03-05T18:04:17.255+0000 building a list of collections to restore from /tmp/tmp.6S378QKhJR/dump dir
2016-03-05T18:04:17.270+0000 restoring mongo_claims.docs4 from /tmp/tmp.6S378QKhJR/dump/docs4.bson
2016-03-05T18:04:20.729+0000 [############............] mongo_claims.docs4 22.3 MB/44.2 MB (50.3%)
2016-03-05T18:04:22.821+0000 [########################] mongo_claims.docs4 44.2 MB/44.2 MB (100.0%)
2016-03-05T18:04:22.822+0000 no indexes to restore
2016-03-05T18:04:22.897+0000 finished restoring mongo_claims.docs4 (41512 documents)
2016-03-05T18:04:22.897+0000 done
That did the trick. My site immediately had all the data.
mongodump will export all the data + indexes from an existing database.
https://docs.mongodb.org/manual/reference/program/mongodump/
Then mongorestore will restore a mongodump with indexes to an existing database.
https://docs.mongodb.org/manual/reference/program/mongorestore/
mongorestore recreates indexes recorded by mongodump.
You can do both commands from you dev machine to the Dokku database.
Importing works well, but since you mentionned mongo console, it's nice to know that you can also connect to your Mongo instance if you use https://github.com/dokku/dokku-mongo's mongo:list and mongo:connect...
E.g.:
root#somewhere:~# dokku mongo:list
NAME VERSION STATUS EXPOSED PORTS LINKS
mydb mongo:3.2.1 running 1->2->3->4->5 mydb
root#somewhere:~# dokku mongo:connect mydb
MongoDB shell version: 3.2.1
connecting to: mydb
> db
mydb
Mongo shell!
> exit
bye
For dokku v0.5.0+ and dokku-mongo v1.7.0+
Use mongodump to export your data into an archive:
mongodump --db mydb --gzip --archive=mydb.archive
Use dokku:import to import your data from an archive
dokku mongo:import mydb < mydb.archive

Connection to Django default failed

So i'm using Pycharm and have installed the Django framework and Postgres. When I initially setup the default Django DB to point to the Postgres database everything works fine.
The problem occurs if I make any changes to a table, meaning the table structure, then try to synchronize the database in Pycharm I'm getting an error message saying "Django default - Connection to Django default failed:"
Here is my setup:
OSX Maverick
Postgres 9.3
Django 1.5
Pycharm 3
Python 3.3
Any assistance someone can give is greatly appreciated!
It looks like Django can't connect to Postgres. You might just need to tweak your settings.py file to make sure you have the correct postgres DB info in there.
In any event here is a more complete guide:
To get django working with Pycharm
Make sure you have followed how to install django correctly
https://docs.djangoproject.com/en/dev/topics/install/
2.go to the project drop down box and click edit configuration
then make sure
host = 127.0.0.1
port = 8000
make sure it is using python 3.x.x as the interpreter rather than python 2.x
In Pycharm go to Preferences —> Django
make sure it is enabled
and then:
Django Project Root connects to the root of your project (usually where manage.py is)
Settings points to your settings.py file inside your project
Manage script points to manage.py
make sure you have installed psycopg2
if you are using python3 that means using pip3 not pip (pip is for python 2.x)
pip3 install psycopg2
Edit your settings.py file as below
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'polls',
'USER': 'lms',
'PASSWORD': '',
'HOST': '', #note an empty string means localhost
'PORT': '5432',
'OPTIONS': {
'autocommit': True,
}
}
}
note the default postgres port is 5432 - if it is not connecting using that check this post:
postgresql port confusion 5433 or 5432?
this may also be useful:
http://marcinkubala.wordpress.com/2013/11/11/postgresql-on-os-x-mavericks/

Resources