{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Personal Pools\n", "\n", "Launch this tutorial in a Jupyter Notebook on Binder: \n", "[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/htcondor/htcondor-python-bindings-tutorials/master?urlpath=lab/tree/Personal-Pools.ipynb)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "A Personal HTCondor Pool is an HTCondor Pool that has a single owner, who is:\n", "- The pool’s administrator.\n", "- The only submitter who is allowed to submit jobs to the pool.\n", "- The owner of all resources managed by the pool.\n", "\n", "The HTCondor Python bindings provide a submodule, `htcondor.personal`, which allows you to manage personal pools from Python.\n", "Personal pools are useful for:\n", "- Utilizing local computational resources (i.e., all of the cores on a lab server).\n", "- Created an isolated testing/development environment for HTCondor workflows.\n", "- Serving as an entrypoint to other computational resources, like annexes or flocked pools (not yet implemented)." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can start a personal pool by instantiating a `PersonalPool`.\n", "This object represents the personal pool and lets us manage its \"lifecycle\": start up and shut down.\n", "We can also use the `PersonalPool` to interact with the HTCondor pool once it has been started up.\n", "\n", "Each Personal Pool must have a unique \"local directory\", corresponding to the HTCondor configuration parameter `LOCAL_DIR`. For this tutorial, we'll put it in the current working directory so that it's easy to find.\n", "\n", "> Advanced users can configure the personal pool using the `PersonalPool` constructor. See the documentation for details on the available options." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import htcondor\n", "from htcondor.personal import PersonalPool\n", "from pathlib import Path" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "PersonalPool(local_dir=./personal-condor, state=INITIALIZED)" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pool = PersonalPool(local_dir = Path.cwd() / \"personal-condor\")\n", "pool" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "To tell the personal pool to start running, call the `start()` method:" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "PersonalPool(local_dir=./personal-condor, state=READY)" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pool.start()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "`start()` doesn't return until the personal pool is `READY`, which means that it can accept commands (e.g., job submission)." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "`Schedd` and `Collector` objects for the personal pool are available as properties on the `PersonalPool`:" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pool.schedd" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pool.collector" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "For example, we can submit jobs using `pool.schedd`:" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "ClusterID is 2\n" ] } ], "source": [ "sub = htcondor.Submit(\n", " executable = \"/bin/sleep\",\n", " arguments = \"$(ProcID)s\",\n", ")\n", "\n", "schedd = pool.schedd\n", "submit_result = schedd.submit(sub, count=10)\n", "\n", "print(f\"ClusterID is {submit_result.cluster()}\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "And we can query for the state of those jobs:" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[ ProcID = 0; ClusterID = 2; JobStatus = 1; ServerTime = 1695159761 ]\n", "[ ProcID = 1; ClusterID = 2; JobStatus = 1; ServerTime = 1695159761 ]\n", "[ ProcID = 2; ClusterID = 2; JobStatus = 1; ServerTime = 1695159761 ]\n", "[ ProcID = 3; ClusterID = 2; JobStatus = 1; ServerTime = 1695159761 ]\n", "[ ProcID = 4; ClusterID = 2; JobStatus = 1; ServerTime = 1695159761 ]\n", "[ ProcID = 5; ClusterID = 2; JobStatus = 1; ServerTime = 1695159761 ]\n", "[ ProcID = 6; ClusterID = 2; JobStatus = 1; ServerTime = 1695159761 ]\n", "[ ProcID = 7; ClusterID = 2; JobStatus = 1; ServerTime = 1695159761 ]\n", "[ ProcID = 8; ClusterID = 2; JobStatus = 1; ServerTime = 1695159761 ]\n", "[ ProcID = 9; ClusterID = 2; JobStatus = 1; ServerTime = 1695159761 ]\n" ] } ], "source": [ "for ad in pool.schedd.query(\n", " constraint = f\"ClusterID == {submit_result.cluster()}\", \n", " projection = [\"ClusterID\", \"ProcID\", \"JobStatus\"]\n", "):\n", " print(repr(ad))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can use the collector to query the state of pool:" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", " [\n", " AuthenticatedIdentity = \"condor@family\"; \n", " EffectiveQuota = 0.0; \n", " Priority = 5.000000000000000E+02; \n", " Requested = 0.0; \n", " UpdateSequenceNumber = 3; \n", " PriorityFactor = 1.000000000000000E+03; \n", " AuthenticationMethod = \"FAMILY\"; \n", " AccountingGroup = \"\"; \n", " Name = \"\"; \n", " SubtreeQuota = 0.0; \n", " IsAccountingGroup = true; \n", " MyType = \"Accounting\"; \n", " NegotiatorName = \"jovyan@fa6c829ace67\"; \n", " GroupSortKey = 0.0; \n", " ResourcesUsed = 0; \n", " ConfigQuota = 0.0; \n", " DaemonStartTime = 1695159756; \n", " BeginUsageTime = 0; \n", " LastHeardFrom = 1695159760; \n", " WeightedAccumulatedUsage = 0.0; \n", " AccumulatedUsage = 0.0; \n", " TargetType = \"none\"; \n", " WeightedResourcesUsed = 0.0; \n", " DaemonLastReconfigTime = 1695159756; \n", " SurplusPolicy = \"byquota\"; \n", " LastUsageTime = 0; \n", " LastUpdate = 1695159760\n", " ]\n", "\n", " [\n", " UpdatesLost_Collector = 0; \n", " UpdatesInitial_Collector = 1; \n", " ActiveQueryWorkers = 0; \n", " SubmitterAds = 0; \n", " RecentUpdatesLostRatio = 0.0; \n", " DetectedCpus = 16; \n", " UpdatesLost = 0; \n", " CCBReconnects = 0; \n", " MachineAdsPeak = 0; \n", " MaxJobsRunningPVM = 0; \n", " RecentUpdatesLost_Accouting = 0; \n", " RecentCCBReconnects = 0; \n", " MaxJobsRunningPipe = 0; \n", " UpdatesInitial_Accouting = 1; \n", " UpdatesInitial_Schedd = 1; \n", " StatsLastUpdateTime = 1695159757; \n", " CurrentJobsRunningLinda = 0; \n", " StatsLifetime = 1; \n", " MonitorSelfTime = 1695159756; \n", " RecentUpdatesInitial_Negotiator = 1; \n", " CurrentJobsRunningStandard = 0; \n", " MaxJobsRunningAll = 0; \n", " CondorPlatform = \"$CondorPlatform: X86_64-Ubuntu_20.04 $\"; \n", " CCBRequests = 0; \n", " MaxJobsRunningVM = 0; \n", " AddressV1 = \"{[ p=\\\"primary\\\"; a=\\\"172.17.0.2\\\"; port=46071; n=\\\"Internet\\\"; alias=\\\"fa6c829ace67\\\"; spid=\\\"collector\\\"; noUDP=true; ], [ p=\\\"IPv4\\\"; a=\\\"172.17.0.2\\\"; port=46071; n=\\\"Internet\\\"; alias=\\\"fa6c829ace67\\\"; spid=\\\"collector\\\"; noUDP=true; ]}\"; \n", " UpdatesTotal_Accouting = 1; \n", " HostsUnclaimed = 0; \n", " MaxJobsRunningJava = 0; \n", " UpdatesInitial = 4; \n", " MaxJobsRunningGrid = 0; \n", " DetectedMemory = 32180; \n", " MaxJobsRunningPVMD = 0; \n", " RecentUpdatesLostMax = 0; \n", " RecentUpdatesTotal = 4; \n", " MaxJobsRunningStandard = 0; \n", " UpdatesTotal_Negotiator = 1; \n", " RecentUpdatesInitial_Accouting = 1; \n", " CurrentJobsRunningVM = 0; \n", " RecentUpdatesLost_Negotiator = 0; \n", " RecentUpdatesLost_Collector = 0; \n", " MaxJobsRunningUnknown = 0; \n", " CurrentJobsRunningPipe = 0; \n", " RecentCCBRequestsSucceeded = 0; \n", " CurrentJobsRunningLocal = 0; \n", " RecentUpdatesInitial = 4; \n", " RunningJobs = 0; \n", " CollectorIpAddr = \"<172.17.0.2:46071?addrs=172.17.0.2-46071&alias=fa6c829ace67&noUDP&sock=collector>\"; \n", " UpdatesLost_Schedd = 0; \n", " Machine = \"fa6c829ace67\"; \n", " CCBRequestsFailed = 0; \n", " CurrentJobsRunningPVMD = 0; \n", " MyCurrentTime = 1695159756; \n", " UpdatesLostRatio = 0.0; \n", " TargetType = \"\"; \n", " MonitorSelfSecuritySessions = 2; \n", " LastHeardFrom = 1695159757; \n", " UpdateInterval = 21600; \n", " CurrentJobsRunningParallel = 0; \n", " CCBRequestsSucceeded = 0; \n", " MonitorSelfImageSize = 16092; \n", " CurrentJobsRunningScheduler = 0; \n", " CurrentJobsRunningAll = 0; \n", " MonitorSelfCPUUsage = 2.600000000000000E+01; \n", " UpdatesLost_Accouting = 0; \n", " SubmitterAdsPeak = 0; \n", " ForkQueriesFromCOLLECTOR = 2; \n", " UpdatesLost_Negotiator = 0; \n", " CurrentJobsRunningVanilla = 0; \n", " CCBEndpointsConnected = 0; \n", " CurrentJobsRunningPVM = 0; \n", " DaemonCoreDutyCycle = 4.107288524954678E-03; \n", " RecentStatsLifetime = 1; \n", " MonitorSelfRegisteredSocketCount = 2; \n", " RecentUpdatesLost = 0; \n", " RecentUpdatesInitial_Schedd = 1; \n", " MaxJobsRunningParallel = 0; \n", " RecentForkQueriesFromCOLLECTOR = 2; \n", " MaxJobsRunningLinda = 0; \n", " DroppedQueries = 0; \n", " CurrentJobsRunningUnknown = 0; \n", " HostsTotal = 0; \n", " CCBEndpointsRegistered = 0; \n", " UpdatesTotal = 4; \n", " RecentUpdatesTotal_Accouting = 1; \n", " ActiveQueryWorkersPeak = 1; \n", " MyType = \"Collector\"; \n", " MonitorSelfResidentSetSize = 10940; \n", " HostsOwner = 0; \n", " RecentUpdatesLost_Schedd = 0; \n", " RecentUpdatesTotal_Negotiator = 1; \n", " RecentCCBRequestsNotFound = 0; \n", " CondorAdmin = \"root@fa6c829ace67\"; \n", " UpdatesTotal_Collector = 1; \n", " CCBEndpointsConnectedPeak = 0; \n", " RecentCCBRequests = 0; \n", " UpdatesTotal_Schedd = 1; \n", " CCBRequestsNotFound = 0; \n", " RecentDroppedQueries = 0; \n", " MachineAds = 0; \n", " RecentUpdatesTotal_Schedd = 1; \n", " IdleJobs = 0; \n", " CCBEndpointsRegisteredPeak = 0; \n", " CurrentJobsRunningJava = 0; \n", " RecentDaemonCoreDutyCycle = 4.107288524954678E-03; \n", " CurrentJobsRunningMPI = 0; \n", " PendingQueriesPeak = 0; \n", " RecentUpdatesInitial_Collector = 1; \n", " PendingQueries = 0; \n", " UpdatesLostMax = 0; \n", " CondorVersion = \"$CondorVersion: 8.9.11 Dec 29 2020 BuildID: Debian-8.9.11-1.2 PackageID: 8.9.11-1.2 Debian-8.9.11-1.2 $\"; \n", " RecentUpdatesTotal_Collector = 1; \n", " MaxJobsRunningLocal = 0; \n", " RecentCCBRequestsFailed = 0; \n", " MaxJobsRunningVanilla = 0; \n", " Name = \"My Pool - 127.0.0.1@fa6c829ace67\"; \n", " MyAddress = \"<172.17.0.2:46071?addrs=172.17.0.2-46071&alias=fa6c829ace67&noUDP&sock=collector>\"; \n", " CurrentJobsRunningGrid = 0; \n", " MaxJobsRunningMPI = 0; \n", " HostsClaimed = 0; \n", " MaxJobsRunningScheduler = 0; \n", " UpdatesInitial_Negotiator = 1; \n", " MonitorSelfAge = 1\n", " ]\n", "\n", " [\n", " LastHeardFrom = 1695159760; \n", " LastBenchmark = 0; \n", " TotalVirtualMemory = 32952448; \n", " HasReconnect = true; \n", " has_sse4_2 = true; \n", " OpSysMajorVer = 20; \n", " has_sse4_1 = true; \n", " DaemonCoreDutyCycle = 0.0; \n", " Disk = 362403396; \n", " CondorVersion = \"$CondorVersion: 8.9.11 Dec 29 2020 BuildID: Debian-8.9.11-1.2 PackageID: 8.9.11-1.2 Debian-8.9.11-1.2 $\"; \n", " SlotTypeID = 1; \n", " Machine = \"fa6c829ace67\"; \n", " HasPerFileEncryption = true; \n", " TotalSlotGPUs = 0; \n", " TotalGPUs = 0; \n", " Activity = \"Idle\"; \n", " TotalCondorLoadAvg = 0.0; \n", " CpuCacheSize = 512; \n", " MonitorSelfCPUUsage = 7.000000000000001E+00; \n", " OpSys = \"LINUX\"; \n", " SlotType = \"Partitionable\"; \n", " UtsnameVersion = \"#1 SMP Debian 4.19.132-1 (2020-07-24)\"; \n", " AuthenticationMethod = \"FAMILY\"; \n", " CpuModelNumber = 1; \n", " MyCurrentTime = 1695159760; \n", " Name = \"slot1@fa6c829ace67\"; \n", " Unhibernate = MY.MachineLastMatchTime isnt undefined; \n", " IsWakeOnLanSupported = false; \n", " HasJobDeferral = true; \n", " UtsnameNodename = \"fa6c829ace67\"; \n", " ChildDSlotId = \n", " {\n", " }; \n", " ChildRemoteUser = \n", " {\n", " }; \n", " HasJICLocalConfig = true; \n", " DaemonStartTime = 1695159756; \n", " ChildRetirementTimeRemaining = \n", " {\n", " }; \n", " HibernationSupportedStates = \"S3,S4,S5\"; \n", " NextFetchWorkDelay = -1; \n", " TotalMemory = 32180; \n", " has_avx2 = true; \n", " HasTransferInputRemaps = true; \n", " RetirementTimeRemaining = 0; \n", " FileSystemDomain = \"fa6c829ace67\"; \n", " StartdIpAddr = \"<172.17.0.2:46071?addrs=172.17.0.2-46071&alias=fa6c829ace67&noUDP&sock=startd_326_2ff6>\"; \n", " RecentJobRankPreemptions = 0; \n", " ClockDay = 2; \n", " TotalLoadAvg = 6.800000000000000E-01; \n", " HasJobTransferPlugins = true; \n", " Cpus = 16; \n", " CondorLoadAvg = 0.0; \n", " MaxJobRetirementTime = 0; \n", " NumDynamicSlots = 0; \n", " StarterAbilityList = \"HasFileTransferPluginMethods,HasVM,HasMPI,HasFileTransfer,HasJobDeferral,HasJobTransferPlugins,HasPerFileEncryption,HasReconnect,HasTDP,HasJICLocalStdin,HasTransferInputRemaps,HasSelfCheckpointTransfers,HasJICLocalConfig\"; \n", " HardwareAddress = \"02:42:ac:11:00:02\"; \n", " ChildMemory = \n", " {\n", " }; \n", " HasTDP = true; \n", " ClockMin = 1302; \n", " AcceptedWhileDraining = false; \n", " TimeToLive = 2147483647; \n", " EnteredCurrentActivity = 1695159760; \n", " Arch = \"X86_64\"; \n", " SlotWeight = Cpus; \n", " MyType = \"Machine\"; \n", " JobRankPreemptions = 0; \n", " HasIOProxy = true; \n", " TotalSlotMemory = 32180; \n", " Requirements = START && (WithinResourceLimits); \n", " UtsnameSysname = \"Linux\"; \n", " NumPids = 0; \n", " TargetType = \"Job\"; \n", " JobUserPrioPreemptions = 0; \n", " LastFetchWorkCompleted = 0; \n", " UpdatesHistory = \"00000000000000000000000000000000\"; \n", " RecentJobUserPrioPreemptions = 0; \n", " COLLECTOR_HOST_STRING = \"127.0.0.1:0\"; \n", " PslotRollupInformation = true; \n", " ChildAccountingGroup = \n", " {\n", " }; \n", " Rank = 0.0; \n", " CpuBusyTime = 0; \n", " ExpectedMachineQuickDrainingCompletion = 1695159760; \n", " MonitorSelfResidentSetSize = 11572; \n", " MachineMaxVacateTime = 10 * 60; \n", " IsWakeOnLanEnabled = false; \n", " ChildName = \n", " {\n", " }; \n", " has_ssse3 = true; \n", " HasSelfCheckpointTransfers = true; \n", " GPUs = 0; \n", " MachineResources = \"Cpus Memory Disk Swap GPUs\"; \n", " WakeOnLanEnabledFlags = \"NONE\"; \n", " has_avx = true; \n", " ExpectedMachineGracefulDrainingBadput = 0; \n", " CurrentRank = 0.0; \n", " HasFileTransfer = true; \n", " EnteredCurrentState = 1695159760; \n", " MonitorSelfSecuritySessions = 3; \n", " HasJICLocalStdin = true; \n", " CpuBusy = ((LoadAvg - CondorLoadAvg) >= 5.000000000000000E-01); \n", " DetectedMemory = 32180; \n", " MonitorSelfTime = 1695159760; \n", " CpuFamily = 23; \n", " OpSysShortName = \"Ubuntu\"; \n", " HasVM = false; \n", " CanHibernate = true; \n", " ChildGPUs = \n", " {\n", " }; \n", " DetectedCpus = 16; \n", " MonitorSelfRegisteredSocketCount = 0; \n", " CpuIsBusy = true; \n", " SlotID = 1; \n", " OpSysLongName = \"Ubuntu 20.04.2 LTS\"; \n", " UtsnameMachine = \"x86_64\"; \n", " ExpectedMachineGracefulDrainingCompletion = 1695159760; \n", " AuthenticatedIdentity = \"condor@family\"; \n", " OpSysVer = 2004; \n", " OpSysAndVer = \"Ubuntu20\"; \n", " UpdatesSequenced = 0; \n", " HibernationState = \"NONE\"; \n", " UpdateSequenceNumber = 1; \n", " RecentJobPreemptions = 0; \n", " HibernationLevel = 0; \n", " HasMPI = true; \n", " WithinResourceLimits = (MY.Cpus > 0 && TARGET.RequestCpus <= MY.Cpus && MY.Memory > 0 && TARGET.RequestMemory <= MY.Memory && MY.Disk > 0 && TARGET.RequestDisk <= MY.Disk && (TARGET.RequestGPUs is undefined || MY.GPUs >= TARGET.RequestGPUs)); \n", " MonitorSelfImageSize = 16564; \n", " OpSysLegacy = \"LINUX\"; \n", " ChildCurrentRank = \n", " {\n", " }; \n", " LoadAvg = 6.800000000000000E-01; \n", " JobPreemptions = 0; \n", " ChildDisk = \n", " {\n", " }; \n", " Memory = 32180; \n", " MonitorSelfAge = 4; \n", " ChildRemoteOwner = \n", " {\n", " }; \n", " UpdatesLost = 0; \n", " ChildCpus = \n", " {\n", " }; \n", " ChildState = \n", " {\n", " }; \n", " TotalDisk = 362403396; \n", " TotalSlotDisk = 3.624033960000000E+08; \n", " OpSysName = \"Ubuntu\"; \n", " UpdatesTotal = 1; \n", " ChildActivity = \n", " {\n", " }; \n", " CondorPlatform = \"$CondorPlatform: X86_64-Ubuntu_20.04 $\"; \n", " HasFileTransferPluginMethods = \"box,https,gdrive,dav,davs,http,onedrive,data,ftp,file,s3\"; \n", " DaemonLastReconfigTime = 1695159756; \n", " MyAddress = \"<172.17.0.2:46071?addrs=172.17.0.2-46071&alias=fa6c829ace67&noUDP&sock=startd_326_2ff6>\"; \n", " DetectedGPUs = 0; \n", " KeyboardIdle = 1695159760; \n", " WakeOnLanSupportedFlags = \"NONE\"; \n", " State = \"Unclaimed\"; \n", " PartitionableSlot = true; \n", " JobStarts = 0; \n", " RecentDaemonCoreDutyCycle = 0.0; \n", " Start = true; \n", " UtsnameRelease = \"4.19.0-10-amd64\"; \n", " TotalSlots = 1; \n", " UidDomain = \"fa6c829ace67\"; \n", " SubnetMask = \"255.255.0.0\"; \n", " IsWakeAble = false; \n", " RecentJobStarts = 0; \n", " AddressV1 = \"{[ p=\\\"primary\\\"; a=\\\"172.17.0.2\\\"; port=46071; n=\\\"Internet\\\"; alias=\\\"fa6c829ace67\\\"; spid=\\\"startd_326_2ff6\\\"; noUDP=true; ], [ p=\\\"IPv4\\\"; a=\\\"172.17.0.2\\\"; port=46071; n=\\\"Internet\\\"; alias=\\\"fa6c829ace67\\\"; spid=\\\"startd_326_2ff6\\\"; noUDP=true; ]}\"; \n", " TotalCpus = 1.600000000000000E+01; \n", " TotalSlotCpus = 16; \n", " ChildEnteredCurrentState = \n", " {\n", " }; \n", " IsLocalStartd = false; \n", " LastFetchWorkSpawned = 0; \n", " VirtualMemory = 32952448; \n", " ExpectedMachineQuickDrainingBadput = 0; \n", " ConsoleIdle = 1695159760\n", " ]\n" ] } ], "source": [ "# get 3 random ads from the daemons in the pool\n", "for ad in pool.collector.query()[:3]:\n", " print(ad)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "When you're done using the personal pool, you can `stop()` it:" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "PersonalPool(local_dir=./personal-condor, state=STOPPED)" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pool.stop()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "`stop()`, like `start()` will not return until the personal pool has actually stopped running.\n", "The personal pool will also automatically be stopped if the `PersonalPool` object is garbage-collected, or when the Python interpreter stops running.\n", "\n", "> To prevent the pool from being automatically stopped in these situations, call the `detach()` method. The corresponding `attach()` method can be used to \"re-connect\" to a detached personal pool." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "When working with a personal pool in a script, you may want to use it as a context manager. This pool will automatically start and stop at the beginning and end of the context:" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "/home/jovyan/tutorials/another-personal-condor\n" ] } ], "source": [ "with PersonalPool(local_dir = Path.cwd() / \"another-personal-condor\") as pool: # note: no need to call start()\n", " print(pool.get_config_val(\"LOCAL_DIR\"))" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.6" } }, "nbformat": 4, "nbformat_minor": 4 }