<jupyter_start><jupyter_text>Deploy Vespa apps to Docker> Python API to deploy Vespa applications to Docker containers. This tutorial illustrate how to deploy a Vespa application to a Docker container in your local machine. It is required to have Docker installed in the machine you are running this tutorial from. For that reason we cannot run this tutorial in Google Colab as Docker is not available on their standard runtime machines.  Application package API We first create a `Document` instance containing the `Field`s that we want to store in the app. In this case we will keep the application simple and only feed a unique `id`, `title` and `body` of the MS MARCO documents.<jupyter_code>from vespa.package import Document, Field

document = Document(
    fields=[
        Field(name = "id", type = "string", indexing = ["attribute", "summary"]),
        Field(name = "title", type = "string", indexing = ["index", "summary"], index = "enable-bm25"),
        Field(name = "body", type = "string", indexing = ["index", "summary"], index = "enable-bm25")        
    ]
)<jupyter_output><empty_output><jupyter_text>The complete `Schema` of our application will be named `msmarco` and contains the `Document` instance that we defined above, the default `FieldSet` indicates that queries will look for matches by searching both in the titles and bodies of the documents. The default `RankProfile` indicates that all the matched documents will be ranked by the `nativeRank` expression involving the title and the body of the matched documents.<jupyter_code>from vespa.package import Schema, FieldSet, RankProfile

msmarco_schema = Schema(
    name = "msmarco", 
    document = document, 
    fieldsets = [FieldSet(name = "default", fields = ["title", "body"])],
    rank_profiles = [RankProfile(name = "default", first_phase = "nativeRank(title, body)")]
)<jupyter_output><empty_output><jupyter_text>Once the `Schema` is defined, all we have to do is to create our msmarco `ApplicationPackage`:<jupyter_code>from vespa.package import ApplicationPackage

app_package = ApplicationPackage(name = "msmarco", schema=msmarco_schema)<jupyter_output><empty_output><jupyter_text>At this point, `app_package` contains all the relevant information required to create our MS MARCO text search app. We now need to deploy it.  Deploy to a Docker container For the following to work you need to run this from a machine with Docker installed. We first create a `VespaDocker` instance based on the application package.<jupyter_code>from vespa.package import VespaDocker

vespa_docker = VespaDocker(application_package=app_package)<jupyter_output><empty_output><jupyter_text>We then call the `deploy` method and specify a `disk_folder`. Behind the scenes, `pyvespa` will write the Vespa config files and store them in the `disk_folder`, it will then run a Vespa engine Docker container and deploy those config files in the container.<jupyter_code>app = vespa_docker.deploy(disk_folder="/Users/username/sample_application")<jupyter_output><empty_output><jupyter_text>The app variable above will hold a `Vespa` instance that will be used to connect and interact with our text search application. We can see the deployment message returned by the Vespa engine:<jupyter_code>app.deployment_message<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.07799274486094317, 'fraction_numerical': 0.0012091898428053204, 'mean_word_length': 5.5395256916996045, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '117563', 'license': 'Apache-2.0', 'n_tokens_mistral': 913, 'n_tokens_neox': 873, 'n_words': 391, 'path': 'python/vespa/docs/sphinx/source/create-and-deploy-vespa-docker.ipynb', 'repo_name': 'srikanthnampelli/vespa', 'size': '3308'}