{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Submission Systems \n", "Submission system play an important role, if you want to develop your pygromos code. Many times, they are hidden in the Simulation_runner blocks. But maybe you want to develop something, where you need direct access on the submission system? \n", "\n", "This notebook will give you some examples, how you can use the submission systems.\n", "Note that all submission systems are write in the same ways, such you can exchange them quickly.\n", "\n", "|" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from pygromos.simulations.hpc_queuing.submission_systems import local # this executes your code in your local session.\n", "from pygromos.simulations.hpc_queuing.submission_systems import lsf # this module can be used to submit to the lsf-queue (e.g. on euler)\n", "from pygromos.simulations.hpc_queuing.submission_systems import dummy # this is a dummy system, that only prints the commands\n", "from pygromos.simulations.hpc_queuing.submission_systems.submission_job import Submission_job # this class stores all data for a single job" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Local Submission\n", "\n", "This system executes the commands directly in your current session. This allows you to locally test or execute your code. Maybe if your process needs much more time, you want later to switch to a submission system for job-queueing." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "sub_local = local.LOCAL()\n", "sub_local.verbose = True" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "bash_command = \"sleep 2; echo \\\"WUHA\\\"; sleep 2\"\n", "job = Submission_job(bash_command)\n", "\n", "job_id = sub_local.submit_to_queue(job)\n", "job_id" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#This is a dummy function, to not break the code!\n", "sub_local.get_jobs_from_queue(\"FUN\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## LSF Submission\n", "\n", "The Lsf submission system allows to submit jobs to the IBM LSF-Queueing system.\n", "\n", "**Careful! This part requires a running LSF-Queueing System on your System**\n", "\n", "You can submit and kill jobs and arrays to the queue, as well as getting information from the queuing list." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#Construct system:\n", "sub_lsf = lsf.LSF(nmpi=1, job_duration = \"24:00\", max_storage=100)\n", "sub_lsf.verbose = True\n", "\n", "sub_lsf._refresh_job_queue_list_all_s = 0 #you must wait at least 1s to update job_queue list" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Queue Checking:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "sub_lsf.get_queued_jobs()\n", "sub_lsf.job_queue_list" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Submission:\n", "here you can submit jobs to the queue as bash commands" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "bash_command = \"sleep 5; echo \\\"WUHA\\\"; sleep 2\"\n", "job_name = \"Test1\"\n", "\n", "job_id = sub_lsf.submit_to_queue(Submission_job(bash_command, job_name))" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#search for the just submitted job in the queue\n", "sub_lsf.search_queue_for_jobid(job_id)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "sub_lsf.search_queue_for_jobname(\"Test1\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Submitting multiple jobs" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "bash_command = \"sleep 2; echo \\\"WUHA\\\"; sleep 2\"\n", "job_ids = []\n", "for test in range(3):\n", " job_name = \"Test\"+str(test)\n", "\n", " job_id = sub_lsf.submit_to_queue(Submission_job(bash_command, job_name))\n", " job_ids.append(job_id)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "sub_lsf.search_queue_for_jobname(\"Te\", regex=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Killing a jobs\n", "\n", "Remove a job the job queue" ] }, { "cell_type": "raw", "metadata": {}, "source": [ "sub_lsf.kill_jobs(job_ids=[job_id])" ] }, { "cell_type": "raw", "metadata": {}, "source": [ "sub_lsf.search_queue_for_jobname(\"Te\", regex=True)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "interpreter": { "hash": "b1b7b2ea43b8e767316eee98e01335d045804d2d47db68b6a5827e187ee91a7e" }, "kernelspec": { "display_name": "Python 3.9.7 ('pygro2')", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.7" } }, "nbformat": 4, "nbformat_minor": 4 }