MLFlow how to change backend store uri from file storage to DB - mlflow

I am using mlflow tracking with file storage as backend store for a while, I have a lot of runs logged in the system.
Lately I wanted to start using the model registry but unfortunately this feature is currently supported only with DB as the backend store.
How can I change the backend store without loosing all the runs that I have already logged?
The command that I am using to run the server:
mlflow server --backend-store-uri /storage/mlflow/runs/ --default-artifact-root /storage/mlflow/artifactory/ --host 0.0.0.0 --port 5000

It's true that we need a database if want to use the model registry feature. This is how I set up (using MySQL) on my Linux machine in just a few steps:-
1)- Install MySQL in your system.
sudo apt install mysql-server
2)- Create a database to use as an MLflow backend tracking server.
CREATE DATABASE mlflow_tracking_database;
3)- Start MLflow tracking server using MySQL as a backend tracking store.
mlflow server \
--backend-store-uri mysql+pymysql://root#localhost/mlflow_tracking_database \
--default-artifact-root file:/./mlruns \
-h 0.0.0.0 -p 5000
4)- Set the MLflow tracking uri (within code section).
mlflow.set_tracking_uri("http://localhost:5000")
NOTE: In the 3rd step, the command automatically creates all the necessary tables within the database and uses MySQL as a backend store instead of a local file system.

My workaround is creating service with expected working dir:
Description=MLflow Tracking Server
Wants=network-online.target
After=network-online.target
[Service]
Restart=on-failure
RestartSec=30
StandardOutput=file:/var/log/mlflow/mlflow.log
StandardError=file:/var/log/mlflow/error.log
User=root
ExecStart=/usr/local/bin/mlflow server --host 0.0.0.0 --port 5000 --backend-store-uri sqlite:///mlflow.db --default-artifact-root /drl/artifacts
WorkingDirectory=/drl
[Install]
WantedBy=multi-user.target

mlflow server --backend-store-uri sqlite:///mlflow.db --default-artifact-root wasbs://<azure_blob_container_name>#<azure_blob_account_name>.blob.core.windows.net --host 0.0.0.0
this way, the sqlite will be automatically created

Related

How to add additional options to docker run on Azure Service App

I am trying to run docker run -i --rm -d --cap-add=SYS_ADMIN --name <azure-container> <azure-container-registry>/<image-name>:<tag>
By default the container is created using docker run -p port1:port2
I want to remove the -p option and add --cap-add=SYS_ADMIN , every time my container gets created from azure container registry using App Service.
Any help appreciated.
Regards,
Aarushi
Unfortunately, the docker command cannot be custom when you deploy your image to Azure Web App. It runs by Azure. You can add the environment variables in the App Setting, but not change the docker command.
You cannot run a container without exposing a port, on App Services. It needs to run a server process in order to become 'healthy'. You can use port 80 (default) or 8080.
Also, as Charles Xu said, you cannot add capabilities at this time.
In Service Fabric you have more port mapping options, but you should still expose a port for the liveness probe.
No cap-add support here either.

How do I make a mongodb replica set node "startup" after the server restarts?

I have 3 servers running a MongoDB replica set.
I currently start the node like this after restarting a server:
mongod --replSet "name_of_replicaset" --bind_ip localhost,this_server_hostname_in_host_file --fork --syslog --auth --keyFile "path_to_file"
The problem is that I have to do this every single time I restart a server.
I've checked online and the official documentation for MongoDB but I cannot find a way to make the server startup the node by itself.
Is there a way to have the server startup the node after it restarting?
You can do this using systemctl.
Create a service for this and enable the same via systemctl enable command. It will automatically start once you restart the server.

NiFi PutDatabaseRecord to Postgres

I have NiFi installed on Windows. On the same PC, I have a VirtualBox/Linux-based VM, on which I am running a Postgres database. The ip for the VM is 192.168.1.X, the ip/port for the database is localhost:xxxx.
NiFi/PutSFTP can put files on the VM using the VM's host ip and default SFTP port. NiFi/PutDatabaseRecord cannot insert records into the database using localhost.
Here is the question: Given the information above, how do I set up NiFi/PutDatabaseRecord to insert data directly into the Postgres database?
Thanks,
John
Easy workarounds:
Install Postgres for Windows
Install Docker on Windows and then run docker run -p 5432:5432 --name postgres -d postgres:latest

How do you start using MLflow SQL storage instead of the file system storage?

If I were getting started with MLflow, then how would I set up a database store? Is it sufficient to create a new MySQL database or a SQLite database and point MLflow to that?
I tried to set the tracking URI, but that didn't create a database if it didn't exist.
How to set up MLFlow properly
pip install the following:
PyMySQL==0.9.3
psycopg2-binary==2.8.5
werkzeug==2.0.3
mlflow
mlflow[extras]==1.14.1
Set up the artifact dir:
mkdir -p mlflow/artifacts
chmod -R 1777 mlflow
This will run a detached process in cli using SQLLite:
mlflow server --host 0.0.0.0 --backend-store-uri sqlite:///mlflow.sqlite.db --default-artifact-root './mlflow/artifacts' </dev/null &>/dev/null &
You will then be able to see the UI, fully functioning, at:
http://{{server_ip or localhost}}:5000 - If you are on a server you may have to expose the port like ufw allow 5000/tcp, or however your cloud provider wants you to do it.
Check my answer here to shut a detached mlflow process down:
How to safely shutdown mlflow ui?
You need to create database by yourself. Mlflow creates tables automatically based on defined schema. It has no control over databases.

Couchdb cartridge not responding in docker image

I successfully deployed a couchdb cartridge to wso2stratos and member get activated successfully. For the implementation of the dockerfile i used this git code. which include the below line that i have no idea why it is there! Can someone explain the below code?
RUN printf "[httpd]\nport = 8101\nbind_address = 0.0.0.0" > /usr/local/etc/couchdb/local.d/docker.ini
EXPOSE 8101
CMD ["/usr/local/bin/couchdb"]
I tried pointing http://127.0.0.1:5984/_utils/spec/run.html url and its working perfectly.
I just SSH to the docker container and start the couchdb,
root#instance-00000001:/usr/local/etc/couchdb/local.d# couchdb couchdb
Apache CouchDB 1.6.1 (LogLevel=info) is starting.
Apache CouchDB has started. Time to relax.
[info] [<0.32.0>] Apache CouchDB has started on http://0.0.0.0:8101/
Then I try to pointing the browser to http://0.0.0.0:8101/ and http://127.0.0.1:5984/_utils/index.html both of them not working.
Can someone tell me why i can't view my databases and create database window?
For your first question about what those lines do:
# Set port and address for couchdb to bind too.
# Remember these are addresses inside the container
# and not necessarily publicly available.
# See http://docs.couchdb.org/en/latest/config/http.html
RUN printf "[httpd]\nport = 8101\nbind_address = 0.0.0.0" >
/usr/local/etc/couchdb/local.d/docker.ini
# Tell docker that this port needs to be exposed.
# You still need to run -P when running container
EXPOSE 8101
# This is the command which is run automatically when container is run
CMD ["/usr/local/bin/couchdb"]
As for why you cannot access it, What does your docker run command look like, did you expose the port? i.e.
docker run -p 8101:8101 ....
Are you by any chance testing on OSX? If so try http://192.168.59.103:8101/ On OSX docker would be inside a virtual box VM as docker cannot run natively on OSX. The IP of the virtual machine can be looked up using boot2docker ip and is normally 192.168.59.103.

Resources