-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix typos. * Add schema and change kw to be kW. * Add schema tests. * Update CLI and tests. * Update reqs. * Test. * Fix path issue.
- Loading branch information
Showing
23 changed files
with
409 additions
and
99 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
from copper.chiller import * | ||
from copper.schema import * | ||
from copper.constants import LOGGING_FORMAT | ||
import sys | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
""" | ||
schema.py | ||
==================================== | ||
Validation of the CLI input files. | ||
""" | ||
|
||
import json, jsonschema, logging | ||
from copper.constants import SCHEMA_PATH | ||
from copper.constants import CHILLER_SCHEMA_PATH | ||
from copper.constants import CHILLER_GENE_SCHEMA_PATH | ||
from copper.constants import CHILLER_ACTION_SCHEMA_PATH | ||
|
||
# Load schemas | ||
schema_chiller = json.load(open(CHILLER_SCHEMA_PATH, "r")) | ||
schema_chiller_gene = json.load(open(CHILLER_GENE_SCHEMA_PATH, "r")) | ||
schema_chiller_action = json.load(open(CHILLER_ACTION_SCHEMA_PATH, "r")) | ||
schema = json.load(open(SCHEMA_PATH, "r")) | ||
|
||
# Define schema store for the validator | ||
schema_store = { | ||
"copper.chiller.schema.json": schema_chiller, | ||
"copper.chiller.generate_set_of_curves.schema.json": schema_chiller_gene, | ||
"copper.chiller.action.schema.json": schema_chiller_action, | ||
"copper.schema.json": schema, | ||
} | ||
|
||
|
||
class Schema: | ||
def __init__(self, input): | ||
self.input = input | ||
self.schema = schema | ||
self.schema_store = schema_store | ||
self.resolver = jsonschema.RefResolver.from_schema(schema, store=schema_store) | ||
Validator = jsonschema.validators.validator_for(schema) | ||
self.validator = Validator(self.schema, resolver=self.resolver) | ||
|
||
def validate(self): | ||
try: | ||
self.validator.validate(self.input) | ||
return True | ||
except: | ||
logging.critical("Input file is not valid.") | ||
return |
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
Binary file not shown.
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,26 @@ | ||
{ | ||
"$schema": "https://json-schema.org/draft-07/schema", | ||
"title": "Chiller functions", | ||
"description": "Run a function for a chiller", | ||
"definitions": { | ||
"action": { | ||
"type": "object", | ||
"properties": { | ||
"equipment": { | ||
"description": "Chiller definition", | ||
"$ref": "copper.chiller.schema.json#/definitions/chiller" | ||
}, | ||
"function_call": { | ||
"description": "Chiller-specific function call", | ||
"oneOf": [ | ||
{ | ||
"$ref": "copper.chiller.generate_set_of_curves.schema.json#/definitions/generate_set_of_curves" | ||
} | ||
] | ||
} | ||
}, | ||
"required": ["equipment", "function_call"] | ||
} | ||
}, | ||
"$ref": "copper.chiller.action.schema.json#/definitions/action" | ||
} |
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,50 @@ | ||
{ | ||
"$schema": "https://json-schema.org/draft-07/schema", | ||
"title": "Generate set of curves", | ||
"description": "Generate set of curves for chillers", | ||
"definitions": { | ||
"generate_set_of_curves": { | ||
"type": "object", | ||
"properties": { | ||
"function": { | ||
"description": "Function to be called", | ||
"type": "string", | ||
"enum": ["generate_set_of_curves"], | ||
"minLength": 1 | ||
}, | ||
"vars": { | ||
"description": "Curve modifier that will be modified to target full and part load efficiencies", | ||
"type": "array", | ||
"items": { | ||
"type": "string", | ||
"enum": ["eir-f-t", "cap-f-t", "eir-f-plr"] | ||
} | ||
}, | ||
"method": { | ||
"description": "Aggregation method used to generate the typical curve", | ||
"type": "string", | ||
"enum": ["nearest_neighbor", "average", "median"] | ||
}, | ||
"tol": { | ||
"description": "Tolerance for the optimization process", | ||
"type": "number" | ||
}, | ||
"export_path": { | ||
"description": "Path to export the generated performance curves", | ||
"type": "string" | ||
}, | ||
"export_format": { | ||
"description": "File format of the generated performance curves", | ||
"type": "string", | ||
"enum": ["idf", "json", "csv"] | ||
}, | ||
"export_name": { | ||
"description": "Name of the generated set of performance curves", | ||
"type": "string", | ||
"minLength": 1 | ||
} | ||
} | ||
} | ||
}, | ||
"$ref": "copper.chiller.generate_set_of_curves.schema.json#/definitions/generate_set_of_curves" | ||
} |
Oops, something went wrong.