Step 5: Running your First "Hello World" Job



Page Navigation:

Β 

Β 


Confidence Level TBDΒ  This article has not been reviewed for accuracy, timeliness, or completeness. Check that this information is valid before acting on it.

Confidence Level TBDΒ  This article has not been reviewed for accuracy, timeliness, or completeness. Check that this information is valid before acting on it.

Β 

*With the OPS_USER and OPS_PASSWORD, you can use the https (e.g. https:// ) protocol to gain access to the url.

Β 

Integrating a "Hello World" Job Type

For definitions of terminology used, please refer to ourΒ terminology reference.

When installation (seeΒ Installation) and setup of your HySDS cluster (seeΒ Cluster Setup) is complete, you can start integrating job types (PGE or non-PGE) into the system. In this tutorial, we integrate our first job type which will simply echo "Hello World".

  1. On themozartinstance, create a directory for your new job type

    cd ~/mozart/ops







    mkdir hello_world













    cd hello_world







  2. Let's create the script that runs our job type. Open up a new file

    and paste the contents below









  3. and save.

  4. Set the script to be executable

    chmod 755 run_hello_world.sh

  5. Test the script by running it

    ./run_hello_world.sh

    Hello World Hello World to STDERR

  6. Now let's create the necessary files for integrating this job into your HySDS cluster. Create theΒ dockerΒ directory and cd into it

    mkdir docker

    cd docker

  7. Create a Dockerfile for your job type by opening up a new fileΒ Dockerfile.<job_type_name>

    vi Dockerfile.hello_world

    paste the following into it

    and save.

  8. Create aΒ job-specΒ file for your job type by opening up a new fileΒ job-spec.json.<job_type_name>

    paste the following into it

    and save. For more information on theΒ job-specΒ format, check outΒ Job and HySDS IO Specifications.

  9. Create aΒ hysds-ioΒ file for your job type by opening up a new fileΒ hysds-io.json.<job_type_name>

    paste the following into it

    and save. For more information on theΒ hysds-ioΒ format, check outΒ Job and HySDS IO Specifications.

  10. Change directory back up to the root of your job type directory

    and the layout of the contents should be as follows

  11. Now we create a git repository from this directory

  12. Create a new repository on github, copy the repo URL, and push your existing hello_world repository. In this example, I created a new repo under my github user account,Β https://github.com/pymonger/hello_world.git

  13. Ensure that your HySDS cluster is up and running

    If it is not running, runΒ sds start all.

  14. Now we need to configure our new job type for continuous integration and deployment. Since we're still developing this job type, we'll configure it using the master branch instead of release tags

    If jenkins needs to use an OAuth token to access the repo, specify theΒ -kΒ option and ensure thatΒ GIT_OAUTH_TOKENΒ was specified inΒ $HOME/.sds/config:

    You should have output similar to the following

    Follow these instructions to configure the webhook on github so that it can trigger rebuild and deployment.

    Note: If you run into issues like :

    you may have a jenkins-cli.jar version that does not support -http, -auth parameters. You can either get a latest jenkins-cli.jar, or can make the following change line in cluster.py to make it work:

    to:

    If the build fails with following error (aws encryption type) :

    remove the encryption type value as AES256 is default type in cluster.py:

    to:

    if your build fails with import error for python-pyasn1 or rsa:

    you may not have latest version of the packages. use pip to install them (specially in ci and factotum instances):

    yum may not install the latest version of pyasn1_modules.

  15. Navigate to yourΒ ciΒ instance (e.g. http://<your-ci-instance>:8080) to validate that the jenkins job was configured

    You should see your jenkins job named as "container-builder_<your repo name>_<branch>" (e.g. container-builder_gmanipon_hello_world_master).

  16. Verify that the jenkins job runs to completion by manually scheduling a build. The jenkins job will build the docker image, publish it to your S3 code bucket, and register the job types into you HySDS cluster. Click on the green arrow and view the console output to validate.

  17. Verify that your new job type was published to your HySDS cluster. Open up a browser and point it to yourΒ mozartΒ instance's ElasticSearch head plugin (e.g. http://<your-mozart-instance>:9200/_plugin/head)*

    Alternatively, you can query for the the "Hello World" job-spec using curl

  18. Now let's try to run our hello_world job type using the Dataset Faceted Search interface (akaΒ tosca) running on theΒ grqΒ instance. First, let's ingest a dataset so that we have at least 1 dataset in our catalog. On theΒ mozartΒ instance run

  19. Navigate to yourΒ grqΒ instance (e.g. http://<your-grq-instance>/search)* to validate that the AOI dataset was ingested

  20. Next click on the "On-Demand" button. If you don't see the "On-Demand" button, then the AOI dataset wasn't ingested correctly. Otherwise, a modal titled "On-Demand (Process Results)" should pop up as below

    Enter the value "test" into the "Tag" field, select "Hello World [master]" for the "Action" field, and select "job_worker-small" for the "Queue" field (should already be selected because it is the "recommended-queue" based on our job-spec.json.hello_world that we composed earlier). You can leave the "Priority" field at "0" for now

    Click on "Process Now".

  21. You will then get another modal providing you with a link to the HySDS Resource Management interface (akaΒ figaro) for the job you just submitted. Click on the link to open upΒ figaro. If the link doesn't open up correctly, there may be a routing issue with the private vs. public IP address in theΒ toscaΒ configuration. Alternately, navigate to yourΒ mozartinstance (e.g. http://<your-mozart-instance>/figaro)* to view your job. Click on the "Queued" button to facet down to the jobs that are in a "job-queued" state

    For advanced users, navigate to the RabbitMQ Admin interface (e.g. http://<your-mozart-instance>:15672/#/queues) running on yourΒ mozartΒ instance to view the queued jobs and tasks

    It will be stuck in theΒ job-queuedΒ because there are no workers configured to process jobs from the "job_worker-small" queue.

  22. Let's configure yourΒ factotumΒ instance to start up a worker that will pull jobs from the "job_worker-small" queue. What we will do is copy the default supervisord.conf template for factotum toΒ ~/.sds/files, and modify it to include start up ofΒ celeryΒ workers for theΒ job_worker-smallΒ queue:

    Edit theΒ supervisord.conf.factotumΒ file

    append the following lines to the bottom of the file and save

  23. Since there are no jobs running in your cluster, we can safely update the factotum instance

    Check the status ofΒ supervisordΒ on factotum

    We're ready to update if it shows

    Finally update and start up factotum:

    RerunΒ sds status factotumΒ to verify that your new worker forΒ job_worker-smallΒ isΒ RUNNING

  24. Navigate to yourΒ mozartΒ instance (e.g. http://<your-mozart-instance>/figaro)* to view your job again. Click on the "Started" button to facet down to the jobs that are in a "job-started" state

    When the job is finished executing, you should have a job that is in a "job-completed" state

  25. Click on the "work directory" link to view the live work directory on factotum. All STDOUT output will go into theΒ _stdout.txtΒ file and all STDERR output will go into theΒ _stderr.txt. Here's whatΒ _stdout.txtΒ should show

    and what theΒ _stderr.txtΒ should show

    Note:

    If you run into issues like:

    it could be due to permission issue in aws. Check the permission tab in 'grfn-v2-ops-product-bucket' to ensure you have the same configuration, specially, the policy file (dont forget to edit the bucket name in your policy file). Also download the index.html file from there and add to your bucket (do necessary edits to reflect your bucket)

Β 

That's it! Congratulations, you've integrated a new job type into your HySDS cluster and successfully executed it.

Next Steps

Now that you've integrated your first job type, continue on toΒ Step 5: Integrating a "Hello World" Dataset TypeΒ to integrate a dataset produced by this job type.






Related Articles:

Related Articles:

Have Questions? Ask a HySDS Developer:

Anyone can join our public Slack channel to learn more about HySDS. JPL employees can join #HySDS-Community

JPLers can also ask HySDS questions at Stack Overflow Enterprise

Β 

Search HySDS Wiki

Page Information:

Page Information:

Was this page useful?

Yes No

Contribution History:

Subject Matter Expert:

@Gerald Manipon

@Hook Hua

Find an Error?

Is this document outdated or inaccurate? Please contact the assigned Page Maintainer:

@Lan Dang



Note: JPL employees can also get answers to HySDS questions at Stack Overflow Enterprise: