Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

%load_ext autoreload
%autoreload 2
import mycode.vap as vap
# The goal is to make a warmup-less search handler
# Now let's prepare another application package with the new search chain
from vespa.package import ServicesConfiguration, ApplicationPackage, Schema, Document, Field
from vespa.configuration.services import services, container, document_api, search, chain, searcher, \
    document_processing, content, documents, document, redundancy, handler, binding

doc_schema = Schema(
    name="doc",
    document=Document(
        fields=[Field(name="id", type="int", indexing=["attribute"]),]
    )
)

application_package = ApplicationPackage(
    name='test',
    schema=[doc_schema],
    services_config=ServicesConfiguration(
        application_name="test",
        services_config=services(
            container(
                document_api(),
                document_processing(),
                search(),
                handler(
                    # binding('http://*/foo/'),
                    bundle="warmup-bundle",
                    id='lt.jocas.examples.FooBar'
                    # id="com.yahoo.search.handler.NoWarmupSearchHandler",
                ),
                id="test_container",
                version="1.0"
            ),
            content(
                redundancy(1),
                documents(
                    document(type="doc", mode="index"),
                ),
                id="test_content",
                version="1.0"
            )
        )
    )
)
# Package into a bundle jar
!(cd ../examples/warmup-bundle && mvn -f pom.xml package)
# There should be a file `../examples/warmup-bundle/target/warmup-bundle-0.0.1-deploy.jar`
!ls -alh ../examples/warmup-bundle/target/warmup-bundle-0.0.1-deploy.jar
[INFO] Scanning for projects...
[INFO] 
[INFO] ------------------< lt.jocas.examples:warmup-bundle >-------------------
[INFO] Building warmup-bundle 0.0.1
[INFO]   from pom.xml
[INFO] --------------------------[ container-plugin ]--------------------------
[WARNING] Ignoring incompatible plugin version 4.0.0-beta-1: The plugin org.apache.maven.plugins:maven-resources-plugin:4.0.0-beta-1 requires Maven version 4.0.0-beta-3
[INFO] Latest version of plugin org.apache.maven.plugins:maven-resources-plugin failed compatibility check
[INFO] Looking for compatible RELEASE version of plugin org.apache.maven.plugins:maven-resources-plugin
[INFO] Selected plugin org.apache.maven.plugins:maven-resources-plugin:3.3.1
[WARNING] Ignoring incompatible plugin version 4.0.0-beta-2: The plugin org.apache.maven.plugins:maven-install-plugin:4.0.0-beta-2 requires Maven version 4.0.0-rc-2
[INFO] Latest version of plugin org.apache.maven.plugins:maven-install-plugin failed compatibility check
[INFO] Looking for compatible RELEASE version of plugin org.apache.maven.plugins:maven-install-plugin
[WARNING] Ignoring incompatible plugin version 4.0.0-beta-1: The plugin org.apache.maven.plugins:maven-install-plugin:4.0.0-beta-1 requires Maven version 4.0.0-beta-3
[INFO] Selected plugin org.apache.maven.plugins:maven-install-plugin:3.1.4
[WARNING] Ignoring incompatible plugin version 4.0.0-beta-2: The plugin org.apache.maven.plugins:maven-deploy-plugin:4.0.0-beta-2 requires Maven version 4.0.0-rc-2
[INFO] Latest version of plugin org.apache.maven.plugins:maven-deploy-plugin failed compatibility check
[INFO] Looking for compatible RELEASE version of plugin org.apache.maven.plugins:maven-deploy-plugin
[WARNING] Ignoring incompatible plugin version 4.0.0-beta-1: The plugin org.apache.maven.plugins:maven-deploy-plugin:4.0.0-beta-1 requires Maven version 4.0.0-beta-3
[INFO] Selected plugin org.apache.maven.plugins:maven-deploy-plugin:3.1.4
[INFO] 
[INFO] --- vespa-bundle:8.588.8:generateSources (default-generateSources) @ warmup-bundle ---
[WARNING] Did not find either container or container-dev artifact in project dependencies, using default version '8.588.8' of the config class plugin.
[INFO] 
[INFO] --- resources:3.3.1:resources (default-resources) @ warmup-bundle ---
[INFO] skip non existing resourceDirectory /Users/dainius.jocas/p/lab/examples/warmup-bundle/src/main/resources
[INFO] 
[INFO] --- compiler:3.11.0:compile (default-compile) @ warmup-bundle ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- resources:3.3.1:testResources (default-testResources) @ warmup-bundle ---
[INFO] skip non existing resourceDirectory /Users/dainius.jocas/p/lab/examples/warmup-bundle/src/test/resources
[INFO] 
[INFO] --- compiler:3.11.0:testCompile (default-testCompile) @ warmup-bundle ---
[INFO] No sources to compile
[INFO] 
[INFO] --- surefire:3.5.4:test (default-test) @ warmup-bundle ---
[INFO] No tests to run.
[INFO] 
[INFO] --- vespa-bundle:8.588.8:generate-osgi-manifest (default-generate-osgi-manifest) @ warmup-bundle ---
[WARNING] This project defines packages that are also defined in provided scoped dependencies (overlapping packages are strongly discouraged): [com.yahoo.search.handler]
[WARNING] This project uses packages that are not part of Vespa's public api: [ai.vespa.metrics, com.yahoo.container.core, com.yahoo.container.handler.threadpool, com.yahoo.container.logging, com.yahoo.language.provider]
[INFO] 
[INFO] --- vespa-bundle:8.588.8:assemble-container-plugin (default-assemble-container-plugin) @ warmup-bundle ---
[INFO] Building jar: /Users/dainius.jocas/p/lab/examples/warmup-bundle/target/warmup-bundle-0.0.1-without-dependencies.jar
[INFO] Building jar: /Users/dainius.jocas/p/lab/examples/warmup-bundle/target/warmup-bundle-0.0.1-deploy.jar
[INFO] 
[INFO] --- vespa-app:8.588.8:packageApplication (default) @ warmup-bundle ---
[INFO] Copying bundle to application: warmup-bundle-0.0.1-deploy.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  3.084 s
[INFO] Finished at: 2025-10-21T22:38:11+03:00
[INFO] ------------------------------------------------------------------------
-rw-r--r--@ 1 dainius.jocas  staff    39M Oct 21 22:38 ../examples/warmup-bundle/target/warmup-bundle-0.0.1-deploy.jar
from pathlib import Path

# Currently, pyvespa provides no way to add bundle jars nicely into VAP
# So, we need to do a little dance and add it manually.

tmp_vap_folder = '_tmp'
application_package.to_files(Path(tmp_vap_folder))

vap.add_bundles(
    application_root=tmp_vap_folder,
    bundles=['../examples/warmup-bundle/target/warmup-bundle-0.0.1-deploy.jar']
)

from vespa.deployment import VespaDocker

# In case running colima on macos run the following
# !sudo ln -sf $HOME/.colima/default/docker.sock /var/run/docker.sock
vespa_docker = VespaDocker(
    container_image="vespaengine/vespa:8.596.20",
)

client = vespa_docker.deploy_from_disk(
    application_name='warmup',
    application_root=Path(tmp_vap_folder),
)
Waiting for configuration server, 0/60 seconds...
Waiting for configuration server, 5/60 seconds...
Waiting for application to come up, 0/300 seconds.
Waiting for application to come up, 5/300 seconds.
Waiting for application to come up, 10/300 seconds.
Application is up!
Finished deployment.
def compile_deploy():
    a = !(cd ../examples/warmup-bundle && mvn -f pom.xml package)
    tmp_vap_folder = '_tmp'
    application_package.to_files(Path(tmp_vap_folder))
    vap.add_bundles(
        application_root=tmp_vap_folder,
        bundles=['../examples/warmup-bundle/target/warmup-bundle-0.0.1-deploy.jar']
    )
    vap.redeploy_from_disk(
        docker=vespa_docker,
        application_root=tmp_vap_folder
    )
compile_deploy()
Deploy status code: 200