-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
11,249 additions
and
3 deletions.
There are no files selected for viewing
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
2,343 changes: 2,343 additions & 0 deletions
2,343
samples/artifacts/USA_MA_Boston-Logan.Intl.AP.725090_TMY3.ddy
Large diffs are not rendered by default.
Oops, something went wrong.
8,768 changes: 8,768 additions & 0 deletions
8,768
samples/artifacts/USA_MA_Boston-Logan.Intl.AP.725090_TMY3.epw
Large diffs are not rendered by default.
Oops, something went wrong.
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 @@ | ||
0.9 |
Large diffs are not rendered by default.
Oops, something went wrong.
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,5 @@ | ||
{ | ||
"wea": "BRA_PR_Curitiba.838420_INMET.epw", | ||
"model": "sample_model_grid.hbjson", | ||
"radiance-parameters": "-ab 2 -ad 512 -lw 2e-05 -dr 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 @@ | ||
pollination-io==1.0.3 |
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,116 @@ | ||
"""Run sample runs on Pollination.""" | ||
from pathlib import Path | ||
import json | ||
import datetime | ||
import time | ||
import sys | ||
import os | ||
from requests.exceptions import HTTPError | ||
|
||
from pollination_io.api.client import ApiClient | ||
from pollination_io.interactors import NewJob, Recipe | ||
from queenbee.job.job import JobStatusEnum | ||
|
||
|
||
# get environment variables | ||
api_key = os.environ['QB_POLLINATION_TOKEN'] | ||
recipe_tag = os.environ['TAG'] | ||
host = os.environ['HOST'] | ||
|
||
recipe_owner = 'ladybug-tools' | ||
recipe_name = 'pmv-comfort-map' | ||
project_owner = 'ladybug-tools' | ||
project = 'pmv-comfort-map' | ||
|
||
api_client = ApiClient(host, api_key) | ||
recipe = Recipe(recipe_owner, recipe_name, recipe_tag, client=api_client) | ||
recipe.add_to_project(f'{project_owner}/{project}') | ||
|
||
# load recipe inputs for each sample run | ||
samples_path = Path(__file__).parent.resolve().joinpath('sample_runs.json') | ||
with open(samples_path, encoding='utf-8') as samples_json: | ||
sample_runs = json.load(samples_json) | ||
|
||
# create a new job | ||
datetime_now = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') | ||
name = f'Samples (Scheduled by GitHub workflow: {datetime_now})' | ||
new_study = NewJob(project_owner, project, recipe, name=name, client=api_client) | ||
|
||
# get all unique artifacts | ||
artifacts = set() | ||
for sample_run in sample_runs: | ||
for recipe_input, value in sample_run['artifacts'].items(): | ||
input_path = Path(__file__).parent.resolve().joinpath(value) | ||
assert input_path.exists(), f'{input_path} does not exist.' | ||
artifacts.add(value) | ||
|
||
# upload unique artifacts | ||
artifacts_path = {} | ||
for artifact in artifacts: | ||
input_path = Path(__file__).parent.resolve().joinpath(artifact) | ||
artifact_path = new_study.upload_artifact(input_path) | ||
artifacts_path[artifact] = artifact_path | ||
|
||
# get recipe inputs for each run and upload artifact | ||
study_inputs = [] | ||
for sample_run in sample_runs: | ||
inputs = dict(sample_run['inputs']) | ||
for recipe_input, value in sample_run['artifacts'].items(): | ||
inputs[recipe_input] = artifacts_path[value] | ||
study_inputs.append(inputs) | ||
|
||
# add the inputs to the study | ||
new_study.arguments = study_inputs | ||
|
||
# create the study | ||
running_study = new_study.create() | ||
if host == 'https://api.staging.pollination.cloud': | ||
pollination_url = 'https://app.staging.pollination.cloud' | ||
else: | ||
pollination_url = 'https://app.pollination.cloud' | ||
job_url = f'{pollination_url}/{running_study.owner}/projects/{running_study.project}/jobs/{running_study.id}' | ||
print(job_url) | ||
|
||
# wait for 5 seconds | ||
time.sleep(5) | ||
|
||
# check status of study | ||
status = running_study.status.status | ||
http_errors = 0 | ||
while True: | ||
status_info = running_study.status | ||
print('\t# ------------------ #') | ||
print(f'\t# pending runs: {status_info.runs_pending}') | ||
print(f'\t# running runs: {status_info.runs_running}') | ||
print(f'\t# failed runs: {status_info.runs_failed}') | ||
print(f'\t# completed runs: {status_info.runs_completed}') | ||
if status in [ | ||
JobStatusEnum.pre_processing, JobStatusEnum.running, JobStatusEnum.created, | ||
JobStatusEnum.unknown | ||
]: | ||
time.sleep(15) | ||
try: | ||
running_study.refresh() | ||
except HTTPError as e: | ||
status_code = e.response.status_code | ||
print(str(e)) | ||
if status_code == 500: | ||
http_errors += 1 | ||
if http_errors > 3: | ||
# failed for than 3 times with no success | ||
raise HTTPError(e) | ||
# wait for additional 10 seconds | ||
time.sleep(10) | ||
else: | ||
http_errors = 0 | ||
status = status_info.status | ||
else: | ||
# study is finished | ||
time.sleep(2) | ||
break | ||
|
||
# return exit status | ||
if status_info.runs_failed != 0: | ||
sys.exit(1) | ||
else: | ||
sys.exit(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,11 @@ | ||
[ | ||
{ | ||
"artifacts": { | ||
"model": "artifacts/sample_model_grid.hbjson", | ||
"epw": "artifacts/USA_MA_Boston-Logan.Intl.AP.725090_TMY3.epw", | ||
"ddy": "artifacts/USA_MA_Boston-Logan.Intl.AP.725090_TMY3.ddy", | ||
"clo-value": "artifacts/clo.csv" | ||
}, | ||
"inputs": {} | ||
} | ||
] |