Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Lance Drane <dranelt@ornl.gov>
- Loading branch information
Lance Drane
committed
Feb 29, 2024
1 parent
6f02737
commit 6df92a5
Showing
24 changed files
with
215 additions
and
73 deletions.
There are no files selected for viewing
Empty file.
13 changes: 13 additions & 0 deletions
13
examples-proposed/001-helloworld/helloworld/hello_driver.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from ipsframework import Component | ||
|
||
|
||
class hello_driver(Component): | ||
def __init__(self, services, config): | ||
super().__init__(services, config) | ||
print('Created %s' % (self.__class__)) | ||
|
||
def step(self, timestamp=0.0): | ||
print('hello_driver: beginning step call') | ||
worker_comp = self.services.get_port('WORKER') | ||
self.services.call(worker_comp, 'step', 0.0) | ||
print('hello_driver: finished step call') |
10 changes: 10 additions & 0 deletions
10
examples-proposed/001-helloworld/helloworld/hello_worker.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from ipsframework import Component | ||
|
||
|
||
class hello_worker(Component): | ||
def __init__(self, services, config): | ||
super().__init__(services, config) | ||
print('Created %s' % (self.__class__)) | ||
|
||
def step(self, timestamp=0.0): | ||
print('Hello from hello_worker') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/usr/bin/env python3 | ||
from setuptools import setup, find_packages | ||
|
||
setup( | ||
name="helloworld", | ||
version="1.0.0", | ||
install_requires=["ipsframework"], | ||
packages=find_packages(), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Examples | ||
|
||
This directory is meant to showcase concrete code examples on how to use the IPS framework. | ||
|
||
## Running the examples | ||
|
||
1) Make sure your environment has the `ipsframework` dependency installed. (To run from the repository, you can run `pip install -e .`) | ||
2) Change directory into the specific folder (i.e. `001-hello-world`) | ||
3) Run `ips.py --config config.conf --platform platform.conf` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
SIM_NAME = dask_example | ||
SIM_ROOT = $PWD | ||
LOG_FILE = log | ||
LOG_LEVEL = INFO | ||
SIMULATION_MODE = NORMAL | ||
|
||
[PORTS] | ||
NAMES = DRIVER WORKER | ||
[[DRIVER]] | ||
IMPLEMENTATION = driver | ||
|
||
[[WORKER]] | ||
IMPLEMENTATION = dask_worker | ||
|
||
[driver] | ||
CLASS = DRIVER | ||
SUB_CLASS = | ||
NAME = Driver | ||
NPROC = 1 | ||
BIN_PATH = | ||
INPUT_FILES = | ||
OUTPUT_FILES = | ||
SCRIPT = $PWD/driver.py | ||
|
||
[dask_worker] | ||
CLASS = DASK_WORKER | ||
SUB_CLASS = | ||
NAME = DaskWorker | ||
NPROC = 1 | ||
BIN_PATH = | ||
INPUT_FILES = | ||
OUTPUT_FILES = | ||
SCRIPT = $PWD/dask_worker.py | ||
EXECUTABLE = $PWD/sleep |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import copy | ||
from time import sleep | ||
from ipsframework import Component | ||
|
||
|
||
def myFun(*args): | ||
print(f"myFun({args[0]})") | ||
sleep(float(args[0])) | ||
return 0 | ||
|
||
|
||
class DaskWorker(Component): | ||
def step(self, timestamp=0.0): | ||
cwd = self.services.get_working_dir() | ||
self.services.create_task_pool('pool') | ||
|
||
duration = 0.5 | ||
self.services.add_task('pool', 'binary', 1, cwd, self.EXECUTABLE, duration) | ||
self.services.add_task('pool', 'function', 1, cwd, myFun, duration) | ||
self.services.add_task('pool', 'method', 1, cwd, copy.copy(self).myMethod, duration) | ||
|
||
ret_val = self.services.submit_tasks('pool', | ||
use_dask=True, | ||
dask_nodes=1) | ||
print('ret_val =', ret_val) | ||
exit_status = self.services.get_finished_tasks('pool') | ||
print('exit_status = ', exit_status) | ||
|
||
def myMethod(self, *args): | ||
print(f"myMethod({args[0]})") | ||
sleep(float(args[0])) | ||
return 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from ipsframework import Component | ||
|
||
|
||
class Driver(Component): | ||
def step(self, timestamp=0.0): | ||
worker_comp = self.services.get_port('WORKER') | ||
self.services.call(worker_comp, 'step', 0.0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
MPIRUN = eval | ||
NODE_DETECTION = manual | ||
CORES_PER_NODE = 1 | ||
SOCKETS_PER_NODE = 1 | ||
NODE_ALLOCATION_MODE = shared | ||
HOST = localhost | ||
SCRATCH = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"code": "DASK_WORKER__DaskWorker", | ||
"eventtype": "IPS_LAUNCH_DASK_TASK", | ||
"walltime": "2.33", | ||
"comment": "task_name = method, Target = myMethod(0.5)", | ||
} | ||
{ | ||
"code": "DASK_WORKER__DaskWorker", | ||
"eventtype": "IPS_LAUNCH_DASK_TASK", | ||
"walltime": "2.33", | ||
"comment": "task_name = function, Target = myFun(0.5)", | ||
} | ||
{ | ||
"code": "DASK_WORKER__DaskWorker", | ||
"eventtype": "IPS_LAUNCH_DASK_TASK", | ||
"walltime": "2.33", | ||
"state": "Running", | ||
"comment": "task_name = binary, Target = sleep 0.5", | ||
} | ||
{ | ||
"code": "DASK_WORKER__DaskWorker", | ||
"eventtype": "IPS_TASK_END", | ||
"walltime": "2.83", | ||
"comment": "task_name = method, elapsed time = 0.50s", | ||
} | ||
{ | ||
"code": "DASK_WORKER__DaskWorker", | ||
"eventtype": "IPS_TASK_END", | ||
"walltime": "2.83", | ||
"comment": "task_name = function, elapsed time = 0.50s", | ||
} | ||
{ | ||
"code": "DASK_WORKER__DaskWorker", | ||
"eventtype": "IPS_TASK_END", | ||
"walltime": "2.85", | ||
"state": "Running", | ||
"comment": "task_name = binary, elapsed time = 0.52s", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
echo /bin/sleep $1 | ||
/bin/sleep $1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.