{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Submitting jobs to DPS with R\n", "Author: Grace Llewellyn (JPL)\n", "\n", "Date: December 11, 2024\n", "\n", "Description: In this example, we show how to submit a job in an R kernel using `maap-py` and `reticulate`. We used GEDI subsetting as the example job. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Run This Notebook\n", "\n", "To access and run this tutorial within MAAP's Algorithm Development Environment (ADE), please refer to the [\"Getting started with the MAAP\"](https://docs.maap-project.org/en/latest/getting_started/getting_started.html) section of our documentation.\n", "\n", "MAAP offers an R/Python workspace with `maap-py` and `reticulate` already installed.\n", "\n", "Note: the `version` argument should be updated to match [the most recent version of the GEDI Subsetter](https://github.com/MAAP-Project/gedi-subsetter/releases). " ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "{'job_id': '9cfaebeb-a726-44c6-a07e-2754bc883854', 'status': 'success', 'machine_type': None, 'architecture': None, 'machine_memory_size': None, 'directory_size': None, 'operating_system': None, 'job_start_time': None, 'job_end_time': None, 'job_duration_seconds': None, 'cpu_usage': None, 'cache_usage': None, 'mem_usage': None, 'max_mem_usage': None, 'swap_usage': None, 'read_io_stats': None, 'write_io_stats': None, 'sync_io_stats': None, 'async_io_stats': None, 'total_io_stats': None, 'error_details': None, 'response_code': 200, 'outputs': []}\n" ] } ], "source": [ "#aoi = f\"https://maap-ops-workspace.s3.amazonaws.com/shared/{username}/langtang_np.geojson\"\n", "\n", "#for your convenience you can use this geoJSON file but if you have your own geojson, use the commented link as example format\n", "aoi <- \"https://maap-ops-workspace.s3.amazonaws.com/shared/anisbhsl/langtang_np.geojson\"\n", "\n", "# Import the R library Reitculate to interface with Python\n", "library(reticulate)\n", "# Import the Python maap-py library\n", "maap <- import(\"maap.maap\")\n", "maap_obj <- maap$MAAP()\n", "\n", "result <- maap_obj$submitJob(identifier=\"gedi-algorithm-test\",\n", " algo_id=\"gedi-subset\",\n", " version=\"0.12.0\",\n", " queue=\"maap-dps-worker-32gb\",\n", " aoi=aoi,\n", " doi=\"L4A\",\n", " lat=\"lat_lowestmode\",\n", " lon=\"lon_lowestmode\",\n", " beams=\"coverage\",\n", " columns=\"agbd, agbd_se, sensitivity, geolocation/sensitivity_a2, elev_lowestmode\",\n", " query=\"l2_quality_flag == 1 and l4_quality_flag == 1 and sensitivity > 0.95 and `geolocation/sensitivity_a2` > 0.95\",\n", " limit=\"10\",\n", " output=\"gedi_subset.gpkg\"\n", " )\n", "\n", "print(result)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "See [documentation on how check the job status and see the outputs via the Jobs UI](https://docs.maap-project.org/en/latest/system_reference_guide/jobsui.html).\n", "\n", "You can also see [this GEDI subsetter job example in Python](https://docs.maap-project.org/en/latest/science/GEDI/GEDI_L4A.html#Submit-a-Job)." ] } ], "metadata": { "kernelspec": { "display_name": "R", "language": "R", "name": "ir" }, "language_info": { "codemirror_mode": "r", "file_extension": ".r", "mimetype": "text/x-r-source", "name": "R", "pygments_lexer": "r", "version": "4.3.3" }, "vscode": { "interpreter": { "hash": "b0fa6594d8f4cbf19f97940f81e996739fb7646882a419484c72d19e05852a7e" } } }, "nbformat": 4, "nbformat_minor": 4 }