Skip to content
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

Debugging tests #75

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions buildstockbatch/postprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,7 @@ def upload_results(aws_conf, output_dir, results_dir, buildstock_csv_filename):
s3_prefix_output = s3_prefix + "/" + output_folder_name + "/"

s3 = boto3.resource("s3")
print(f"In upload_results: {s3_bucket}")
bucket = s3.Bucket(s3_bucket)
n_existing_files = len(list(bucket.objects.filter(Prefix=s3_prefix_output)))
if n_existing_files > 0:
Expand All @@ -643,6 +644,7 @@ def upload_results(aws_conf, output_dir, results_dir, buildstock_csv_filename):
def upload_file(filepath, s3key=None):
full_path = filepath if filepath.is_absolute() else parquet_dir.joinpath(filepath)
s3 = boto3.resource("s3")
print(f"In upload_file: {s3_bucket}")
bucket = s3.Bucket(s3_bucket)
if s3key is None:
s3key = Path(s3_prefix_output).joinpath(filepath).as_posix()
Expand Down
1 change: 1 addition & 0 deletions buildstockbatch/sample_one_county.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
- County and PUMA depends only on the ASHRAE climate zone
- Each County+PUMA fall entirely in one climate zone
"""

import argparse
import csv
import os
Expand Down
4 changes: 2 additions & 2 deletions buildstockbatch/test/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def test_upload_files(mocker, basic_residential_project_file):
return_value={"Crawler": {"State": "READY", "LastCrawl": {"Status": "SUCCEEDED"}}}
)
mocked_boto3.client = MagicMock(return_value=mocked_glueclient)
mocked_boto3.resource().Bucket().objects.filter.side_effect = [[], ["a", "b", "c"]]
mocked_boto3.resource("s3").Bucket(s3_bucket).objects.filter.side_effect = [[], ["a", "b", "c"]]
project_filename, results_dir = basic_residential_project_file(upload_config)
buildstock_csv_path = (
Path(results_dir).parent
Expand All @@ -160,7 +160,7 @@ def test_upload_files(mocker, basic_residential_project_file):
files_uploaded = []
crawler_created = False
crawler_started = False
for call in mocked_boto3.mock_calls[2:] + mocked_boto3.client().mock_calls:
for call in mocked_boto3.mock_calls + mocked_boto3.client().mock_calls:
call_function = call[0].split(".")[-1] # 0 is for the function name
if call_function == "resource":
assert call[1][0] in ["s3"] # call[1] is for the positional arguments
Expand Down
2 changes: 1 addition & 1 deletion buildstockbatch/test/test_docker_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def test_get_epws_to_download():
}

epws = DockerBatchBase.get_epws_to_download(sim_dir, jobs_d)
assert epws == set(["weather/G0100970.epw", "weather/G0100830.epw"])
assert epws == set(["weather/G2500210.epw", "weather/G2601390.epw"])


def test_run_simulations(basic_residential_project_file):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Building,Bedroom,Location,Vintage,State,Insulation Wall,Insulation Slab,Zipcode,County
1,1,AL_Mobile-Rgnl.AP.722230,<1950,CO,Good Option,None,36608,County1
2,3,AL_Mobile-Rgnl.AP.722230,1940s,CO,Good Option,None,36601,County1
3,2,AL_Mobile-Rgnl.AP.722230,2010s,VA,Good Option,None,36602,County1
3,2,AL_Mobile-Rgnl.AP.722230,2010s,VA,Good Option,None,36602,County2
4,1,AL_Mobile-Rgnl.AP.722230,2000s,VA,Good Option,None,36603,County2
5,2,AL_Mobile-Rgnl.AP.722230,1970s,VA,Good Option,None,36604,County2
5,2,AL_Mobile-Rgnl.AP.722230,1970s,VA,Good Option,None,36604,County3
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ Vintage 2000s
Vintage 2010s
State VA
State CO
County County1 weather_station_epw_filepath=weather/G0100970.epw
County County2 weather_station_epw_filepath=weather/G0100830.epw
County County1 weather_station_epw_filepath=weather/G2500210.epw
County County2 weather_station_epw_filepath=weather/G2601210.epw
County County3 weather_station_epw_filepath=weather/G2601390.epw
Bedroom 1
Bedroom 2
Bedroom 3
Expand Down
Loading