{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "(code-archive)=\n", "# Using code from archives or file shares" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**In this section**\n", "- [Archive URL options](#archive-url-options)\n", "- [Run from zip using the CLI](#run-from-zip-using-the-cli)\n", "- [Using code from Git](#using-code-from-Git)\n", "- [Using code from file share](#using-code-from-file-share)\n", "- [Inject parameters into command line](#inject-parameters-into-command-line)\n", "- [Execute non-Python code](#execute-non-Python-code)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Archive URL options\n", "* Git, for example: git://github.com/mlrun/something.git#master\n", "* Zip/Tar archives, for example: https://github.com/mlrun/mlrun/raw/run-cli/examples/archive.zip\n", "* File share, for example: `/User/mycode` (requires adding a file share to the function) \n", "\n", "The archive is set as the working dir for the function and the file/params to execute should be set using the `command` parameter (with the relative path inside the archive)." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Run from zip using the CLI" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "> 2021-06-15 11:52:45,847 [warning] Failed resolving version info. Ignoring and using defaults\n", "> 2021-06-15 11:52:48,460 [warning] Unable to parse server or client version. Assuming compatible: {'server_version': '0.6.4', 'client_version': 'unstable'}\n", "> 2021-06-15 11:52:48,469 [info] starting run tst1 uid=ce4a3eab42ff43e0885d82ec27762949 DB=http://mlrun-api:8080\n", "> 2021-06-15 11:52:48,612 [info] Job is running in the background, pod: tst1-6zpsv\n", "> 2021-06-15 11:52:51,885 [info] extracting source from https://github.com/mlrun/mlrun/raw/development/examples/archive.zip to /mlrun/code\n", "Run: tst1 (uid=ce4a3eab42ff43e0885d82ec27762949)\n", "my line\n", "got text: some text\n", "> 2021-06-15 11:52:51,957 [info] run executed, status=completed\n", "final state: completed\n", "> 2021-06-15 11:52:54,715 [info] run executed, status=completed\n" ] } ], "source": [ "!python -m mlrun run --name tst1 --watch --source https://github.com/mlrun/mlrun/raw/development/examples/archive.zip --handler handler --image mlrun/mlrun myfunc.py" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Using code from Git" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "> 2021-06-15 11:58:59,002 [info] starting run archive-my_func uid=0b6195fbf1844880a829d61505bd9a38 DB=http://mlrun-api:8080\n", "> 2021-06-15 11:58:59,468 [info] Job is running in the background, pod: archive-my-func-8frkp\n", "> 2021-06-15 11:59:02,726 [info] extracting source from git://github.com/mlrun/ci-demo.git#master to /mlrun/code\n", "Run: archive-my_func (uid=0b6195fbf1844880a829d61505bd9a38)\n", "Params: p1=1, p2=a-string\n", "> 2021-06-15 11:59:02,764 [info] running function\n", "> 2021-06-15 11:59:02,797 [info] run executed, status=completed\n", "final state: completed\n" ] }, { "data": { "text/html": [ "\n", "
project | \n", "uid | \n", "iter | \n", "start | \n", "state | \n", "name | \n", "labels | \n", "inputs | \n", "parameters | \n", "results | \n", "artifacts | \n", "
---|---|---|---|---|---|---|---|---|---|---|
default | \n", "\n", " | 0 | \n", "Jun 15 11:59:02 | \n", "completed | \n", "archive-my_func | \n", "v3io_user=admin kind=job owner=admin host=archive-my-func-8frkp framework=sklearn | \n",
" \n", " | \n", " | accuracy=2 loss=3 | \n",
" \n", " |
project | \n", "uid | \n", "iter | \n", "start | \n", "state | \n", "name | \n", "labels | \n", "inputs | \n", "parameters | \n", "results | \n", "artifacts | \n", "
---|---|---|---|---|---|---|---|---|---|---|
default | \n", "\n", " | 0 | \n", "Apr 27 13:09:04 | \n", "completed | \n", "archive-handler | \n", "v3io_user=admin kind=job owner=admin host=archive-handler-74crq | \n",
" \n", " | \n", " | accuracy=6 loss=12 | \n",
" file_result | \n",
"