-
Notifications
You must be signed in to change notification settings - Fork 3
Add orchestrator #58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jnation3406
wants to merge
208
commits into
main
Choose a base branch
from
add_orchestrator
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add orchestrator #58
Changes from all commits
Commits
Show all changes
208 commits
Select commit
Hold shift + click to select a range
8c64641
Skeleton of orchestrator entrypoint
cb86ef1
added total scheduled time metric
DaGinYus 8606a1b
added total scheduled count metric
DaGinYus 053ba64
move metric functions to a separate file
DaGinYus 6d42329
added functions for getting the data we want, implemented binning by …
DaGinYus 7ca823e
small comments and modifications to record_metrics function
DaGinYus 98c5e14
available_time
5daaad5
available_time
0737f96
time capping function for filtering metrics (WIP)
DaGinYus 29dca71
available time
6d1505c
Some changes for supporting running the scheduler simulator
3f372da
draft airmass metrics
b357c1d
merge in branch and change record_metrics signature
89ad3cf
fixed bugs in metrics to get a runnable program
DaGinYus 25d4c96
added documentation
DaGinYus 9873cfd
updated to reflect renamed function in metrics.py
DaGinYus e3a4882
michael
926da49
finished ideal average airmass calculation
DaGinYus 59a2efd
idk
c12a14d
this is what i want
4d702aa
fix merge conflicts
e89b460
add get midpoint airmass
d153bff
skeleton of planned tests for scheduler simulator metrics
DaGinYus 049f8ee
Merge branch 'add_orchestrator' of github.com:observatorycontrolsyste…
DaGinYus 7ed5110
fixed file and began moving things into a class
DaGinYus 1ae4a07
midpoint airmasses
1ddbf3c
fix merge conflicts and add midpoint airmasses
fc2c961
fix build issues
8de30d5
test bin filler function
DaGinYus 634ccc5
percent of function was deleted on accident during merge resolution
DaGinYus 78ac01f
Merge branch 'add_orchestrator' of github.com:observatorycontrolsyste…
DaGinYus 6d4f036
test binning function, counter function, and aggregators
DaGinYus fc134f4
moved some functions around
DaGinYus 8495dc4
merge conflict fix
d31fb3d
Merge branch 'add_orchestrator' of github.com:observatorycontrolsyste…
58eb001
tested airmass metrics and debugged
c190f0b
migrate airmass data to a json file
DaGinYus 1563bf1
ignore rapid response if there are no rr scheduler results
DaGinYus 9a2b3f0
migrate
a83fbce
fixed reservation.request
d6fa06c
fixed reservation.request
2dd0d20
fixed reservation.request
e84b796
some style fixes
22c9512
some refactoring into a class for metrics
DaGinYus e337186
resolve merge conflicts
DaGinYus 0d2f55c
tests for refactored code
DaGinYus 040ac35
Add code to submit metrics to opensearch
039d1f4
updated orchestrator to work with current iteration of metrics
DaGinYus 9a48a88
resolve merge conflicts
DaGinYus 6e739e9
merged too fast, missed some bugs
DaGinYus c29460e
refactoring airmasses metrics into the metrics calculator class
5031653
add tests for averaging multiple airmasses
qingzewu e9030b1
upload another airmass mock data for testing
qingzewu a75bb3a
delete the parameters passed in for airmasses functions
qingzewu 781950a
deleted debug prints
qingzewu 524ef2b
reworked binning function
DaGinYus e89db58
fix merge conflicts
DaGinYus b2cc024
updated to only request from observe portal once
DaGinYus 17d997f
Store off normal and rr scheduling inputs for accesibility in metrics
c2ffbbd
Store the input reservations within the scheduler results too
7deb153
add documentation for airmass metrics calculation functions
qingzewu ee0a305
update percent scheduled logic to reflect actual scheduler input
DaGinYus 0b1de91
updated binning function to bin additional data
DaGinYus 3700fcc
updated binning function to handle floats
DaGinYus 47bb974
add different metrics for midpoint airmass and resolve merge conflicts
qingzewu 55feb90
merge airmass metrics into one function call
qingzewu 65c6cca
metrics code cleaning
qingzewu 87eb7d6
merge and clean up airmass function
DaGinYus 4ac744b
minor edit in binning test
DaGinYus 88be215
merged too fast (again) sadface
DaGinYus 2555585
merge conflict resolve
qingzewu 3ac3ed3
test
qingzewu e334ad6
remove emacs autosave file
DaGinYus c728c10
finished updating airmass metrics testings
qingzewu 827332f
Merge branch 'add_orchestrator' of github.com:observatorycontrolsyste…
qingzewu 4bb8bf1
small speed optimizations and additional priority metrics
DaGinYus 104a76c
fix merge conflicts
DaGinYus 8cff4e4
wip data caching using redis, tried to test but ran out of storage sp…
DaGinYus 4604f95
bugfix for caching the wrong object type
DaGinYus 11fcaaf
reenable sending to opensearch after testing
DaGinYus a60a2d1
fixed redis cache error
qingzewu 5e8f516
Merge branch 'add_orchestrator' of github.com:observatorycontrolsyste…
qingzewu f44e948
Merge branch 'add_orchestrator' of github.com:observatorycontrolsyste…
DaGinYus 28152a0
add documentation for airmass data
qingzewu cef09c4
Add configdb overrides for simulation
320cfde
Merge branch 'add_orchestrator' of github.com:observatorycontrolsyste…
2dcd4d4
Merge branch 'feature/optimize_airmass' of github.com:observatorycont…
99a2320
Fix the missing redis instance
a7acaeb
fixed request group attribute error
DaGinYus be7cb98
Fix rs_target serizliation
ddd3317
Fix error in single target airmasses
2d8382a
fix dict values list
b2376a7
bugfixes in airmass optimization caching
DaGinYus fdd9c98
Merge branch 'optimize_airmass_in_orchestrator' of github.com:observa…
DaGinYus 11c9ca5
fixed incorrect total count for priorities
DaGinYus 071f419
changed airmass weighting to be an environment variable
DaGinYus 448ed76
fixed type error in airmass weighting coefficient
DaGinYus 03fafbd
plotting functions for airmass coefficient data
DaGinYus b177bb1
remove emacs autosave
DaGinYus 5e327cb
update to include worst airmass data, optimizations to midpoint airma…
DaGinYus 052940b
Merge branch 'optimize_airmass_in_orchestrator' of github.com:observa…
DaGinYus f7f3baf
implemented image export and cleaned up chart labels
DaGinYus 3005922
moved helper functions to plotutils
DaGinYus b71e88c
add plot effective priority
qingzewu c6c6c9d
uniform scaling for histograms
DaGinYus 324f3d8
small documentation updates and optimizations
DaGinYus 572f0f8
no longer dumps all the metrics to the log
DaGinYus 730ad09
changed optimization_type back to default from 'AIRMASS'
DaGinYus 5dec6e8
Merge branch 'optimize_airmass_in_orchestrator' of github.com:observa…
DaGinYus 84b5fe0
added basic cli interface
DaGinYus 7f4486c
fixed ploting effective priority
qingzewu cb81051
Merge branch 'optimize_airmass_in_orchestrator' of github.com:observa…
qingzewu f98b071
updated master plotting file, can be turned into example code
DaGinYus a1bc9d3
update to include raw duration and priority data
DaGinYus dbbe618
priority duration scatter plot for with/withou duration
qingzewu 00e9774
fixed unscheduled duration data
DaGinYus bde8e80
Merge branch 'optimize_airmass_in_orchestrator' of github.com:observa…
DaGinYus 22d1dc2
plot the priority duration scatterplot
qingzewu b9638a6
Merge branch 'optimize_airmass_in_orchestrator' of github.com:observa…
qingzewu 9458288
fixed priorities
DaGinYus fcdea71
Merge branch 'optimize_airmass_in_orchestrator' of github.com:observa…
DaGinYus 96b1283
added functionality to store raw data, improved documentation
DaGinYus f53b548
heat map for priority duration
qingzewu 67705f5
fill feature added to binning function
DaGinYus 7102b9f
minor change to fill functionality
DaGinYus 5eef112
oops, broke something, changing it back
DaGinYus d5e8045
Merge branch 'optimize_airmass_in_orchestrator' of github.com:observa…
qingzewu 3aa78bc
updated documentation and slightly modified binning function behavior
DaGinYus 75364d8
changed default binning behavior
DaGinYus 3c9750c
minor updates to binning test
DaGinYus bff610b
Merge branch 'optimize_airmass_in_orchestrator' of github.com:observa…
qingzewu 9736d7e
heatmap
qingzewu 49f478a
priority duration
qingzewu 3de1ab3
heatmap
qingzewu 15bc9fa
add timing decorators to time our metrics runtime
qingzewu b392fe6
add timing decorators to time our metrics runtime
qingzewu ba5d27a
slew distance calculations
DaGinYus 84be11b
added new plot for effective priority binned data
DaGinYus 074a7e9
Merge branch 'optimize_airmass_in_orchestrator' of github.com:observa…
DaGinYus f824110
add slew distance to orchestrator
DaGinYus 629f7ec
update to handle non sidereal targets
DaGinYus 2036de4
wip restructure for more user friendly code
DaGinYus af0fa05
merge plots
qingzewu 97b6518
working UI for plotting program
DaGinYus 098fe31
Merge branch 'optimize_airmass_in_orchestrator' of github.com:observa…
DaGinYus 3e134fb
updated documentation
DaGinYus e231050
updated documentation, small change to barplotting function
DaGinYus ce444ec
fixed bug with duration aggregation
DaGinYus 8debc40
small naming change
DaGinYus 88cc546
ported some more functions from plot_all
DaGinYus e6fa334
plot func
qingzewu c362f32
plot func
qingzewu 91c32d0
added window duration calculation
DaGinYus d2f0e40
more airmass plots
DaGinYus f19a680
bugfix for misindented break statement, slight input cleaning
DaGinYus fc47c2c
small modification to error handling, renamed plot_barplot to plot_mu…
DaGinYus 72ba3c1
simulation
qingzewu 6457e7c
plot input durations
qingzewu 083f2e1
stacked sched/unsched requests
qingzewu 54e1ebc
add heatmap plots
qingzewu 5125204
change to 300 dpi
DaGinYus 29de01c
move to new airmass tests
DaGinYus 40b7abe
fix merge conflicts
DaGinYus 975cee2
update plots
qingzewu c579d29
minor update on plotfuncs
qingzewu ad6432f
small fix to titles and titlesizes
DaGinYus e4c87fb
modified title sizes to be bigger
DaGinYus 19522a0
remove old plotting files, they have been integrated into plotfuncs
DaGinYus 976e48b
Merge branch 'optimize_airmass_in_orchestrator' of github.com:observa…
DaGinYus 40a0ea4
removed old plotting file
DaGinYus 7223030
fixed some line plot things
DaGinYus abe8f1a
minor changes
qingzewu d11129d
Merge branch 'optimize_airmass_in_orchestrator' of github.com:observa…
qingzewu dac07b9
fixed whitespace issues
DaGinYus 43a9ed9
began writing readme
DaGinYus 1cff1b7
modified env variables and 'show all' behavior
DaGinYus 168ac8d
minor change to the way input data is handled
DaGinYus 2046f0b
finished first draft of readme
DaGinYus af270d5
update datasets
qingzewu 1290c6e
pass copy instead of reference
qingzewu 7d984f0
few updates to the orchestrator readme
ae66c15
Merge branch 'document_orchestrator' of github.com:observatorycontrol…
2480132
fixed utilization calculation
DaGinYus e23d982
Merge branch 'document_orchestrator' of github.com:observatorycontrol…
DaGinYus e5362db
updated error handling and masked useless opensearch warning messages
DaGinYus 8f17d74
small rewordings
DaGinYus 26280af
changed wording for opensearch env variable
DaGinYus abc8672
updated documentation and fixed trailing whitespace
DaGinYus ea63cbb
updated documentation
DaGinYus 74c279b
merge in some readme changes
aefb704
fix for airmass optimization
e6ce825
divide by zero bugfix
DaGinYus c12c975
broke plots into sections
DaGinYus 7abc28d
modified binning option
DaGinYus 020a1f3
changed comment for clarity
DaGinYus 841c176
Merge branch 'main' of github.com:observatorycontrolsystem/adaptive_s…
7d2b9d0
Merge pull request #56 from observatorycontrolsystem/document_orchest…
jnation3406 6f1dc1d
Merge branch 'main' of github.com:observatorycontrolsystem/adaptive_s…
a8d2810
Merge branch 'feature/optimize_airmass' of github.com:observatorycont…
b9b2dbb
Merge branch 'add_orchestrator' into optimize_airmass_in_orchestrator
jnation3406 7278c68
Merge pull request #57 from observatorycontrolsystem/optimize_airmass…
jnation3406 7e68ce1
Merge branch 'add_orchestrator' of github.com:observatorycontrolsyste…
DaGinYus 0277784
is bad
DaGinYus 20ead84
cache by request in redis instead of one big dict
DaGinYus 86e9e9c
pep8 fixes and import renaming for clarity
DaGinYus dbae293
forgot to save the file haha
DaGinYus 040a199
fix merge conflict
DaGinYus 67bba5a
final commit of Michael; adapted input requests plot to fit new test …
qingzewu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -22,7 +22,7 @@ class ConfigDBInterface(SendMetricMixin): | |
| """ | ||
|
|
||
| def __init__(self, configdb_url, telescope_classes, telescopes_file='data/telescopes.json', | ||
| active_instruments_file='data/active_instruments.json'): | ||
| active_instruments_file='data/active_instruments.json', overrides=None): | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The changes in this file all pertain to being able to override configdb values with a dict provided (which can be read in from a simple json file in the simulation orchestrator) |
||
| self.configdb_url = configdb_url | ||
| if not self.configdb_url.endswith('/'): | ||
| self.configdb_url += '/' | ||
|
|
@@ -31,11 +31,28 @@ def __init__(self, configdb_url, telescope_classes, telescopes_file='data/telesc | |
| self.active_instruments_file = active_instruments_file | ||
| self.active_instruments = None | ||
| self.telescope_info = None | ||
| self.overrides = overrides | ||
| self.update_configdb_structures() | ||
|
|
||
| def update_configdb_structures(self): | ||
| self.update_telescope_info() | ||
| self.apply_overrides_to_telescopes() | ||
| self.update_active_instruments() | ||
| self.apply_overrides_to_instruments() | ||
|
|
||
| def apply_overrides_to_telescopes(self): | ||
| if self.overrides: | ||
| for telescope in self.overrides.get('telescopes', {}).keys(): | ||
| if telescope in self.telescope_info and 'status' in self.overrides['telescopes'][telescope]: | ||
| self.telescope_info[telescope]['status'] = self.overrides['telescopes'][telescope]['status'] | ||
|
|
||
| def apply_overrides_to_instruments(self): | ||
| if self.overrides and self.overrides.get('instruments', {}): | ||
| for instrument in self.active_instruments: | ||
| if instrument['code'] in self.overrides['instruments']: | ||
| instrument['state'] = self.overrides['instruments'][instrument['code']].get('state', instrument['state']) | ||
| if instrument['instrument_type']['code'] in self.overrides['instruments']: | ||
| instrument['state'] = self.overrides['instruments'][instrument['instrument_type']['code']].get('state', instrument['state']) | ||
|
|
||
| def update_active_instruments(self): | ||
| try: | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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,63 @@ | ||
| # Adaptive Scheduler Simulator Orchestrator | ||
|
|
||
| The orchestrator allows for running the adaptive scheduler in a simulated environment in order to facilitate testing. | ||
| It allows the user to dump input request data to the [Observation Portal](https://github.com/observatorycontrolsystem/observation-portal) | ||
| which is then passed to the scheduler. The orchestrator runs the scheduler and passes off the scheduler result to a | ||
| metric calculation file, which calculates metrics to send to an OpenSearch database. Work is still being done to enable the | ||
| orchestrator to step through a time range and run the scheduler repeatedly on different points of the input data. | ||
|
|
||
| ## Overview of Metrics | ||
| The available metrics center around priority distributions, utilization, and miscellaneous data including airmass data | ||
| and slew distance. Certain metrics sent to OpenSearch are pre-binned by priority level. To get the best understanding of | ||
| the data structures, inspect the raw JSON in OpenSearch directly. | ||
|
|
||
| ## Prerequisites | ||
| * Python 3.9 | ||
| * A running [Configuration Database](https://github.com/observatorycontrolsystem/configdb) with instruments | ||
| * A running [Observation Portal](https://github.com/observatorycontrolsystem/observation-portal) with requests | ||
| * A running OpenSearch with index created to store scheduler simulation results | ||
|
|
||
| ## Environment Variables | ||
| Consult the adaptive scheduler README for general environment variables related to the scheduler. Additional environment | ||
| variables specific to the orchestrator are as follows: | ||
| | Variable | Description | Default | | ||
| |----------------------------------|---------------------------------------------------------------------------------------------|-------------------------| | ||
| | `SIMULATION_RUN_ID` | The run ID of the scheduler. This will be saved as `simulation_id` in OpenSearch | `1` | | ||
| | `SIMULATION_START_TIME` | The simulation start time, which allows the orchestrator to step through a time range (WIP) | `2022-06-23` | | ||
| | `SIMULATION_END_TIME` | The end time of the time range. This should match the start time if only a single run is desired. | `2022-06-23` | | ||
| | `SIMULATION_TIME_STEP_MINUTES` | The time step in minutes for the time range (WIP) | `60` | | ||
| | `SIMULATION_AIRMASS_COEFFICIENT` | The airmass optimization weighting value | `0.1` | | ||
| | `SIMULATION_OPENSEARCH_INDEX` | The OpenSearch index where metrics will be saved to to | `scheduler-simulations` | | ||
| | `OPENSEARCH_URL` | OpenSearch endpoint (needed for the plotting interface) | _`Empty_string`_ | | ||
| | | | | | ||
|
|
||
| ## How to Run | ||
| When running in a Docker container, the entry point can be modified to point to the orchestrator instead of the scheduler, | ||
| e.g. `sh -c "sleep 20s; simulation-orchestrator"`. The twenty second wait time is to ensure all the relevant services (configdb, redis, etc.) are | ||
| spun up and available. Otherwise, run the orchestrator locally on a machine with `poetry run simulation-orchestrator` | ||
|
|
||
| ## Simulation Process | ||
| The general workflow for running a scheduler simulation is as follows: | ||
| 1. Make changes to the adaptive scheduler. If running with Docker, build the image using the suggested build command in the adaptive scheduler README. | ||
| 2. If necessary, adjust the `metrics.py` file to conform with the tests you are running, such as adjusting binning for priority values. | ||
| 3. Modify environment variables accordingly, making sure to set and verify the run ID. | ||
| 4. Run the orchestrator. | ||
|
|
||
| ## Plotting | ||
| A plotting interface is included with the simulator to facilitate data visualization. The interface features OpenSearch searching by | ||
| either OpenSearch ID or `simulation_id`, the ability to save plots in various formats, and zsh-style TAB autocompletion. | ||
| Note that the environment variable `OPENSEARCH_URL` must be set on whatever machine you are running the plots from. | ||
| To use the plotting interface, run `python -m adaptive_scheduler.simulation.plots` | ||
| (`-h` to show the available command line arguments). | ||
|
|
||
| ## Creating Your Own Plots | ||
| The plotting framework provides a `Plot` class defined in `plotutils.py` to help initialize plots and get data from OpenSearch. | ||
| `Plot` is initialized with a user-defined plotting function to generate the plot, the plot title, and either a single string or a list | ||
| of strings. It searches the `_id` or `simulation_id` field in OpenSearch for the strings and plots the data. To write your own plotting | ||
| functions, follow the example functions in `plotfuncs.py`. Plotting functions should take in either a list of datasets | ||
| or a single dataset (to match the initialization in `plots.py`). The plot title should be passed into the plotting function as well. | ||
| This title is used to generate the descriptions for the command-line interface of the plotting framework. | ||
|
|
||
| The plot creation process is as simple as: | ||
| 1. Creating a function (e.g. `plot_my_plot`) in `plotfuncs.py` | ||
| 2. Adding the plot to the list of plots in `plots.py`, e.g. `Plot(plotfuncs.plot_my_plot, 'My Plot Title', 'some-data-id')` |
Empty file.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just so the interns could build the container without full priviledges - we can remove this comment