All algorithm configuration is specified in the `./maap_runtime/<algorithm-dir-name>/algorithm_config.yaml` file.
1. Make any necessary code changes on your feature branch or main branch
Make sure that:
- The `version` matches the current Git branch.
2. Decide on a tag name that is unique (it can be a semvar version or just text). For purposes of this documentation we'll call the new tag `testing123`
- The `repository_url` is an HTTPS URL to the MAAP repository (GitHub will not work for security reasons).
- The `run_command` starts with the name of the repository (i.e., the last part of the repository URL -- probably, `fireatlas`; note, **not** the name of the current directory, the branch, or anything like that).
3. Change the `algorithm_version: testing123` line in `/maap_runtime/<algo-name>/algorithm_config.yaml` files to point to this new tag
## Registering the algorithm
1. Do at least a partial interactive test to make sure that your run script will actually run.
4. Git commit all your changes and push remotely
Debugging the MAAP DPS is tricky and time-consuming, so try to identify and squash as many bugs as you can from the ADE.
```bash
2. Commit all changes to your workspace **and push them** to the corresponding branch of the **MAAP GitLab repository**.
git add -u
The ADE will not let you register an algorithm if you have uncommitted changes.
git commit -m"updates with new tag"
However, it's easy to forget to push the changes to MAAP when debugging interactively.
git push origin <branch-name>
```
3. If you have previously registered this algorithm under the same name **and version**, delete it.
This will prevent you from accidentally running an older version of the algorithm.
5. Then tag and push your tags remotely
From the MAAP ADE, in the top settings bar, go to "DPS/MAS Operations" --> "Delete Algorithm".
Find your algorithm (**note the version!**) and select it to delete.
```bash
- Alternatively, using the MAAP Python library, you can use code like the following:
git tag -f testing123
git push origin -f testing123
```python
```
from maap.maap import MAAP
maap = MAAP(maap_host='api.ops.maap-project.org')
6. Then register your algorithm. Really the output of this step is just building a new DPS image. Either you can manually do this as talked about in the DPS docs above or automate it like in `/maap_runtim/register-all.ipynb`
print(del_result.text) # Confirm that this is code 200 and says "successfully delted job ..."
```
4. In the MAAP ADE file browser, right click on the `./maap_runtime/<algorithm-dir-name>/algorithm_config.yaml` file and click "Register as MAS Algorithm".
In the popup menu, the only option you should change is the MAAP queue; select the smallest node necessary to run your algorithm.
Submit your selection.
5. You should see a popup window with some JSON information about your algorithm.
Copy this into a plain text file for reference.
- The most useful thing in here is the job build log URL, which will look something like: `https://repo.ops.maap-project.org/root/register-job/-/jobs/817/raw`. This URL is used to track the build progress of your algorithm. You will not be able to run the latest version of your algorithm until this build is completed; this usually takes about 10-20 minutes.
- Note that depending on permissions, you may not actually have access to the build log, in which case you will just have to wait until the algorithm re-appears in the list of algorithms. You can try Python code like the following to monitor the status:
print(".", end="") # Primitive 'progress bar', to reassure you that it's still going
time.sleep(5) # Sleep for 5 seconds, then try again
print("Algorithm ready!")
```
## Running the algorithm
Only proceed with this step once you are sure the current version of your algorithm is registered and build (see previous steps).
- From the MAAP ADE interface, go to "DPS/MAS Operations" --> "Execute DPS Job".
Select your algorithm (note the version!) from the drop-down menu and proceed.
Assuming your algorithm doesn't have any inputs, you should see a popup saying this; proceed.
You'll see a final popup with the job ID -- **copy this into a plain text file before closing this window**;
you will need this job ID to check the status of your job, but once this window closes, there is no other way to retrieve the job ID (this is a MAAP bug).
- Alternatively, you can submit jobs using the MAAP Python interface, using code like the following:
```python
import time
from maap.maap import MAAP
maap = MAAP(maap_host="api.ops.maap-project.org")
alg = "eis-fire-feds-v2" # Algorithm name
version = "conus-dps-4" # Current branch
job = maap.submitJob(
identifier=f"job-{alg}_ubuntu:{version}",
username="myuser", # NOTE: Replace `myuser` with your username
algo_id=f"{alg}_ubuntu",
version=version
)
print(job)
```
You can check on the status of your job using the "DPS/MAS Operations" --> "Get DPS Job Status" menu item, or `maap.getJobStatus` Python function.
Here some code that (1) submits a MAAP DPS job; (2) continuously reports on the job's status while it's running; and (3) prints out the output in a (more) human-readable format once the job is finished.