Skip to content

Commit 316cb35

Browse files
authored
Merge pull request #6 from IBM/docs
Docs
2 parents b0b486c + 4581482 commit 316cb35

File tree

7 files changed

+220
-112
lines changed

7 files changed

+220
-112
lines changed

README.md

Lines changed: 44 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
* D = (X,y) is a dataset derived from f,
2525
* x* is the true optimum of f in O (minimum or maximum).
2626

27-
The testing framework feeds your algorithm constraints and data (O,D) and collects its predicted optimum. The algorithm's predicted optimal value can then be compared to the true optimal value f(x*). By comparing the two over multiple randomly generated optimization problems, `doframework` produces a **prediction profile** for your algorithm.
27+
`doframework` feeds your algorithm constraints and data (O,D) and collects its predicted optimum. The algorithm's predicted optimal value can then be compared to the true optimal value f(x*). By comparing the two over multiple randomly generated optimization problems, `doframework` produces a **prediction profile** for your algorithm.
2828

2929
`doframework` integrates with your algorithm (written in Python).
3030

@@ -40,7 +40,7 @@ The testing framework feeds your algorithm constraints and data (O,D) and collec
4040

4141
`doframework` can run either locally or remotely. For optimal performance, run it on a Kubernetes cluster. Cloud configuration is currently available for AWS and IBM Cloud [OpenShift](https://docs.openshift.com/ "RedHat OpenShift Documentation") clusters.
4242

43-
The framework relies on Cloud Object Storage (COS) to interact with simulation products. Configuration is currently available for [AWS](https://aws.amazon.com/s3/ "AWS S3") or [IBM COS](https://www.ibm.com/cloud/object-storage "IBM Cloud Object Storage").
43+
The framework uses storage (local or S3) to interact with simulation products. Configuration is currently available for [AWS](https://aws.amazon.com/s3/ "AWS S3") or [IBM Cloud Object Storage COS](https://www.ibm.com/cloud/object-storage "IBM Cloud Object Storage").
4444

4545
# Install
4646

@@ -52,14 +52,23 @@ $ pip install doframework
5252

5353
# Configs
5454

55-
COS specifications are provided in a `configs.yaml`.
55+
Storage specifications are provided in a `configs.yaml`. You'll find examples under `./configs/*`.
5656

57-
The `configs.yaml` includes the list of source and target bucket names (under `s3:buckets`). Credentials are added under designated fields.
58-
59-
Currently, two cloud service providers are available under `s3:cloud_service_provider`: `aws` and `ibm`.
60-
61-
`s3:endpoint_url` is optional for AWS.
57+
The `configs.yaml` includes the list of source and target bucket names (under `buckets`). If necessary, S3 credentials are added under designated fields.
6258

59+
Here is the format of the `configs.yaml` either for local storage
60+
```
61+
local:
62+
buckets:
63+
inputs: '<inputs-folder>'
64+
inputs_dest: '<inputs-dest-folder>'
65+
objectives: '<objectives-folder>'
66+
objectives_dest: '<objectives-dest-folder>'
67+
data: '<data-folder>'
68+
data_dest: '<data-dest-folder>'
69+
solutions: '<solutions-folder>'
70+
```
71+
or S3
6372
```
6473
s3:
6574
buckets:
@@ -75,19 +84,20 @@ s3:
7584
endpoint_url: 'https://xxx.xxx.xxx'
7685
region: 'xx-xxxx'
7786
cloud_service_provider: 'aws'
78-
7987
```
80-
**Bucket names above must be distinct**.
88+
Currently, two S3 providers are available under `s3:cloud_service_provider`: either `aws` or `ibm`. The `endpoint_url` is _optional_ for AWS.
89+
90+
**Bucket / folder names must be distinct**.
8191

8292
# Inputs
8393

8494
`input.json` files provide the necessary metadata for the random genration of optimization problems.
8595

86-
`doframework` will run end to end, once `input.json` files are uploaded to `<inputs_bucket>`.
96+
`doframework` will run end to end, once `input.json` files are uploaded to `<inputs-bucket>` / `<inputs-folder>`.
8797

88-
The jupyter notebook `./notebooks/inputs.ipynb` allows you to automatically generate input files and upload them to `<inputs_bucket>`.
98+
The jupyter notebook `./notebooks/inputs.ipynb` allows you to automatically generate input files and upload them to `<inputs-bucket>`.
8999

90-
Here is an example of an input file (see input samples `input_basic.json` and `input_all.json` under `./inputs`).
100+
Here is an example of an input file (see input samples `input_basic.json` under `./inputs`).
91101

92102

93103
```
@@ -102,24 +112,22 @@ Here is an example of an input file (see input samples `input_basic.json` and `i
102112
},
103113
},
104114
"omega" : {
105-
"ratio": 0.8,
106-
"scale": 0.01
115+
"ratio": 0.8
107116
},
108117
"data" : {
109118
"N": 750,
110119
"noise": 0.01,
111120
"policy_num": 2,
112121
"scale": 0.4
113122
},
114-
"input_file_name": "input.json"
123+
"input_file_name": "input_basic.json"
115124
}
116125
```
117126

118127
`f:vertices:num`: number of vertices in the piece-wise linear graph of f.<br>
119-
`f:vertices:range`: f domain will be inside this box range.<br>
128+
`f:vertices:range`: f domain will be inside this range.<br>
120129
`f:values:range`: range of f values.<br>
121130
`omega:ratio`: vol(O) / vol(dom(f)) >= ratio.<br>
122-
`omega:scale`: scale of jitter when sampling feasibility regions (as a ratio of domain diameter).<br>
123131
`data:N`: number of data points to sample.<br>
124132
`data:noise`: response variable noise.<br>
125133
`data:policy_num`: number of centers in Gaussian mix distribution of data.<br>
@@ -129,11 +137,11 @@ It's a good idea to start experimenting on low-dimensional problems.
129137

130138
# User App Integration
131139

132-
Your algorithm will be integrated together with `doframework` once it is decorated with `doframework.resolve`.
140+
Your algorithm will be integrated into `doframework` once it is decorated with `doframework.resolve`.
133141

134-
A `doframework` experiment runs with `doframework.run()`. The `run()` utility accepts the decorated model and a path to the `configs.yaml`.
142+
A `doframework` experiment runs with `doframework.run()`. The `run()` utility accepts the decorated model and an absolute path to the `configs.yaml`.
135143

136-
Here is an example user application `module.py`.
144+
Here is an example a user application `module.py`.
137145

138146
```
139147
import doframework as dof
@@ -148,10 +156,13 @@ if __name__ == '__main__':
148156
dof.run(alg, 'configs.yaml', objectives=5, datasets=3, **kwargs)
149157
```
150158

151-
The testing framework supports the following inputs to your algorithm:
159+
`doframework` provides the following inputs to your algorithm:
152160

153161
`data`: 2D np.array with features X = data[ : , :-1] and response variable y = data[ : ,-1].<br>
154162
`constraints`: linear constraints as a 2D numpy array A. A data point x satisfies the constraints when A[ : , :-1]*x + A[ : ,-1] <= 0.<br>
163+
164+
It feeds your algorithm additional inputs in kwargs:
165+
155166
`lower_bound`: lower bound per feature variable.<br>
156167
`upper_bound`: upper bound per feature variable.<br>
157168
`init_value`: optional initial value.<br>
@@ -160,26 +171,28 @@ The `run()` utility accepts the arguments:
160171

161172
`objectives`: number of objective targets to generate per input file.<br>
162173
`datasets`: number of datasets to generate per objective target.<br>
163-
`feasibility_regions`: number of feasibility regions to generate per objective and dataset.<br>
164174
`distribute`: True to run distributively, False to run sequentially.<br>
165-
`logger`: True to see logs, False otherwise.<br>
175+
`logger`: True to see `doframework` logs, False otherwise.<br>
166176
`after_idle_for`: stop running when event stream is idle after this many seconds.<br>
177+
`alg_num_cpus`: number of CPUs to dedicate to your algorithm on each optimization task.<br>
178+
`data_num_cpus`: number of CPUs to dedicate to data generation (useful in high dimensions).
179+
167180

168181
# Algorithm Prediction Profile
169182

170-
Once you are done running a `doframework` experiment, run the notebook `notebooks/profile.ipynb`. It will fetch the relevant experiment products from the target COS buckets and produce the algorithm's prediction profile and prediction probabilities.
183+
Once you are done running a `doframework` experiment, run the notebook `notebooks/profile.ipynb`. It will fetch the relevant experiment products from the target buckets and produce the algorithm's prediction profile and prediction probabilities.
171184

172-
`doframework` produces three types of experiment products files:
185+
`doframework` produces three types of experiment product files:
173186

174187
* `objective.json`: containing information on (f,O,x*)
175188
* `data.csv`: containing the dataset the algorithm accepts as input
176189
* `solution.json`: containing the algorithm's predicted optimum
177190

178-
See sample files under `./outputs`/
191+
See sample files under `./outputs`.
179192

180193
# Kubernetes Cluster
181194

182-
To run `doframework` on a K8S cluster, make sure you are on the cluster's local `kubectl` context. Log into your cluster, if necessary (applicable to OpenShift, see doc).
195+
To run `doframework` on a K8S cluster, make sure you are on the cluster's local `kubectl` context. Log into your cluster, if necessary (applicable to OpenShift, see `./doc/openshift.md`).
183196

184197
You can check your local `kubectl` context and change it if necessary with
185198
```
@@ -189,7 +202,7 @@ $ kubectl config use-context cluster_name
189202
>> Switched to context "cluster_name".
190203
```
191204

192-
Now `cd` into your project's folder and run the setup bash script `doframework-setup.sh`. The setup script will generate the cluster configuration file `doframework.yaml` in your project's folder. The setup script requires the absolute path to your `configs.yaml`. Otherwise, it assumes a file `configs.yaml` is located under your project's folder. Running the setup script will establish the `ray` cluster.
205+
Now `cd` into your project's folder and run the setup bash script `doframework-setup.sh`. The setup script will generate the cluster configuration file `doframework.yaml` in your project's folder. The setup script requires the absolute path to your `configs.yaml`. Running the setup `.sh` script will establish the `ray` cluster.
193206

194207
```
195208
$ cd <user_project_folder>
@@ -220,7 +233,7 @@ $ ray submit doframework.yaml module.py
220233

221234
# Ray Cluster
222235

223-
To observe the `ray` dashboard, connect to `http://localhost:8265` in your browser. See the OpenShift doc for OpenShift-specific instructions.
236+
To observe the `ray` dashboard, connect to `http://localhost:8265` in your browser. See `./doc/openshift.md` for OpenShift-specific instructions.
224237

225238
Some useful health-check commands:
226239

@@ -276,5 +289,5 @@ $ ray submit doframework.yaml doframework_example.py --configs configs.yaml
276289
```
277290
[NOTE: we are using the path to the `configs.yaml` that was mounted on cluster nodes under `$HOME`.]
278291

279-
Make sure to upload input json files to `<inputs_bucket>` once you run `doframework_example.py`.
292+
Make sure to upload input json files to `<inputs-bucket>` / `<inputs-folder>` once you run `doframework_example.py`.
280293

configs/aws_configs.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
s3:
2+
buckets:
3+
inputs: ''
4+
inputs_dest: ''
5+
objectives: ''
6+
objectives_dest: ''
7+
data: ''
8+
data_dest: ''
9+
solutions: ''
10+
aws_secret_access_key: ''
11+
aws_access_key_id: ''
12+
region: ''
13+
cloud_service_provider: 'aws'

configs/dir_configs.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,4 @@ local:
66
objectives_dest: ''
77
data: ''
88
data_dest: ''
9-
solutions: ''
10-
solutions_dest: ''
9+
solutions: ''

configs/ibm_configs.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
s3:
2+
buckets:
3+
inputs: ''
4+
inputs_dest: ''
5+
objectives: ''
6+
objectives_dest: ''
7+
data: ''
8+
data_dest: ''
9+
solutions: ''
10+
aws_secret_access_key: ''
11+
aws_access_key_id: ''
12+
endpoint_url: ''
13+
region: ''
14+
cloud_service_provider: 'ibm'

docs/ocl_lab.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<!--
2+
# Copyright IBM Corporation 2022
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
-->
16+
17+
# AAAI 2023 OCL Lab Instructions
18+
19+
Here are the installation instructions for participants of the OCL Lab.
20+
21+
## `doframework` Installation
22+
23+
We recommend installing `doframework` on a designated Python 3.8.0 environment. `doframework` has many dependancies that may override package versions in your current Python environment.
24+
25+
For example, if you're using `pyenv` in combination with `virtualenv` as your Python environment manager, you can type the following in your terminal
26+
```
27+
$ pyenv virtualenv 3.8.0 dof
28+
$ pyenv local dof
29+
```
30+
[Here](https://realpython.com/intro-to-pyenv/#virtual-environments-and-pyenv "pyenv and virtualenv") is a good source on `pyenv` and `virtualenv` by Logan Jones.
31+
32+
Now that you've set up a dedicated Python environment, simply install
33+
```
34+
$ pip install doframework
35+
```
36+
Run a simple sanity check with
37+
```
38+
$ python
39+
>>> import doframework
40+
>>> exit()
41+
```
42+
The import command may take a while. Once it's finished (successfully, hopefully) you can exit.
43+
44+
## `doframework` Clonning
45+
46+
We will be running `doframework` Jupyter Notebooks as well as using other `doframework` material. Therefore, we'll clone a local copy of `doframework`. From your terminal, run
47+
48+
```
49+
$ git clone https://github.com/IBM/doframework.git
50+
```
51+
To launch the OCL lab Jupyter Notebooks, we'll need to add `jupyter` to our new Python environment
52+
```
53+
$ pip install jupyter
54+
```
55+
Note that `jupyter` does not come with `doframework`. We want to keep `doframework` light for cloud distribution. Once we're done installing `jupyter`, let's launch the OCL Lab notebooks
56+
```
57+
$ cd doframework/notebooks
58+
$ jupyter notebook
59+
```
60+
Now we can begin ...

doframework/api.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import os
2-
import yaml
31
import json
42
from io import StringIO
53
from collections import namedtuple

0 commit comments

Comments
 (0)