diff --git a/.travis.yml b/.travis.yml index 109abaf..5984205 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ matrix: install: - pip install -r requirements.txt script: - - cd viewer + - export PYTHONPATH=`pwd`/viewer - pytest after_success: - bash <(curl -s https://codecov.io/bash) diff --git a/requirements.txt b/requirements.txt index abc4f6c..3757f9f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ oblib flask flask_cors +pytest \ No newline at end of file diff --git a/viewer/__init__.py b/viewer/__init__.py index e69de29..7b6ee1d 100644 --- a/viewer/__init__.py +++ b/viewer/__init__.py @@ -0,0 +1,13 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at + +# http://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +__all__ = ['reference', 'viewer'] diff --git a/viewer/reference.py b/viewer/reference.py new file mode 100644 index 0000000..f2f324b --- /dev/null +++ b/viewer/reference.py @@ -0,0 +1,334 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at + +# http://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +""" +This is a temporary file to hold reference data until it can be incorporated into a more +permanent location (either pyoblib or solar-taxonomy). +""" + +ACRONYMS = { + "AuthorityHavingJurisdiction": "AHJ", + "CaliforniaEnergyCommission": "CEC", + "EngineeringProcurementAndConstruction": "EPC", + "FederalEnergyRegulatoryCommission": "FERC", + "GeographicInformationSystems": "GIS", + "GroundCoverageRatio": "GCR", + "GroundFaultDetectorInterrupter": "GFDI", + "LimitedLiabilityCompany": "LLC", + "LimitedPartnership": "LP", + "BatteryManagementSystem": "BMS", + "EmailAddress": "Email", + "ModelNumber": "Model", + "NominalOperatingCellTemperature": "NOCT", + "UL1741SupplementA": "UL1741SA", + "SCADASystem": "SCADA", + "PowerPurchaseAgreement": "PPA", + "PreQualification": "PreQual", + "PerformanceBasedIncentive": "PBI", + "MonthlyOperatingReport": "OpRpt", + "OperatingTemperatureRange": "OTR", + "PermissionToOperate": "PTO", + "PlacedinService": "PIS", + "PreventativeMaintenance": "PM", + "PublicUtilitiesCommission": "PUC", + "RenewableEnergy": "RE", + "RenewableEnergyCertificates": "REC", + "RenewableEnergyCredit": "REC", + "TypicalMetMonth": "TMM", + "TypicalMetYear": "TMY", + "TypicalGHIYear": "TGY", + "TypicalGHIMonth": "TGM", + "TypicalDNIYear": "TDY", + "TypicalDNIMonth": "TDM", + "InsulatedGateBipolarTransistor": "IGBT", + "GlobalHorizontalIrradiance": "GHI", + "RelattiveHumidity": "RH", + "ReferenceCell": "RefCell", + "PowerFactor": "PF", + "StandardTestCondition": "STC", + "PowerFactor": "PF", + "IncidenceAngleModifier": "IAM", + "IndependentSystemOperator": "ISO", + "InternationalElectrotechnicalCommission": "IEC", + "LongTerm": "LngTrm", + "MaximumPowerPoint": "MPPT", + "MaximumPowerPointTracker": "MPPT", + "MaximumPowerPointTracking": "MPPT" +} + +ABBREVIATIONS = { + "Accelerated": "Accel", + "Accumulated": "Accum", + "Address": "Addr", + "Address": "Addr", + "Administration": "Admin", + "Administrative": "Admin", + "Amortization": "Amort", + "Amount": "Amt", + "Approval": "Approv", + "Assignment": "Assign", + "Authority": "Auth", + "Automatic": "Auto", + "Availability": "Avail", + "Average": "Avg", + "Coefficient": "Coeff", + "Condition": "Cond", + "Configuration": "Config", + "Construction": "Constr", + "Contribution": "Contrib", + "Control": "Ctrl", + "Credits": "Cred", + "Curtailment": "Curtail", + "Degradation": "Degrad", + "Depreciation": "Deprec", + "Description": "Desc", + "Engineering": "Eng", + "Equipment": "Equip", + "Equivalent": "Equiv", + "Excluding": "Exclud", + "Expiration": "Exp", + "Facilities": "Facil", + "Features": "Feat", + "Frequency": "Freq", + "Hardware": "HW", + "Historical": "Hist", + "Identification": "ID", + "Identifier": "ID", + "Incentives": "Incent", + "Inception": "Incept", + "Including": "Incl", + "Information": "Info", + "Installation": "Install", + "Location": "Loc", + "Maintenance": "Maint", + "Management": "Mgmt", + "Manager": "Mgr", + "Manufacturer": "Mfr", + "Maximum": "Max", + "Account": "Acct", + "Acknowledgement": "Ack", + "Acquisition": "Acquis", + "Adjusted": "Adj", + "Agreement": "Agree", + "Agreements": "Agree", + "Ambient": "Amb", + "Analysis": "Anal", + "Application": "App", + "Application": "App", + "Archeological": "Archeol", + "Assessment": "Assess", + "Assessments": "Assess", + "Assumption": "Assump", + "Attribute": "Attr", + "Authorization": "Auth", + "Farenheit": "DegF", + "Celsius": "DegC", + "Certificate": "Cert", + "Certificates": "Cert", + "Certification": "Cert", + "Certifications": "Cert", + "Connection": "Connec", + "Continuing": "Cont", + "Continuous": "Cont", + "Continuous": "Cont", + "Contractor": "Contrct", + "Contribution": "Contrib", + "Control": "Ctrl", + "Counterparties": "Cntrparty", + "Counterparty": "Cntrparty", + "Decommissioning": "Decommiss", + "Document": "Doc", + "Documentation": "Doc", + "Documents": "Doc", + "Earnings": "Earn", + "Effective": "Effect", + "Commissioning": "Commiss", + "Communication": "Comm", + "Communications": "Comm", + "Company": "Co", + "Completion": "Compl", + "Component": "Cmpnt", + "Commercial": "Commerc", + "Estimate": "Est", + "Estimated": "Est", + "Estimates": "Est", + "European": "EU", + "Exception": "Except", + "Exceptions": "Except", + "Firmware": "FW", + "Formation": "Form", + "Electric": "Elec", + "Electrical": "Elec", + "Electronics": "Electr", + "Environmental": "Env", + "Expected": "Expect", + "Expire": "Exp", + "External": "Ext", + "Financial": "Fin", + "Financing": "Fin", + "Insurance": "Insur", + "Merchant": "Merch", + "Method": "Meth", + "Minimum": "Min", + "Monitoring": "Monitor", + "Mortgage": "Mortg", + "Municipal": "Muni", + "Nominal": "Nom", + "Noncurrent": "Noncurr", + "Nonoperating": "Nonop", + "Number": "Num", + "Parameters": "Param", + "Participant": "Partic", + "Password": "Pwd", + "January": "Jan", + "February": "Feb", + "March": "Mar", + "April": "Apr", + "May": "May", + "June": "Jun", + "July": "Jul", + "August": "Aug", + "September": "Sep", + "October": "Oct", + "November": "Nov", + "December": "Dec", + "Telecommunications": "Telecom", + "Temperature": "Temp", + "Temporary": "Tempor", + "Resolution": "Resol", + "Resource": "Resrc", + "Reliability": "Reliab", + "Remediation": "Remed", + "Rating": "Rtg", + "Precautionary": "Precaut", + "Prefunded": "Prefund", + "Performance": "Perf", + "Permission": "Permiss", + "Organization": "Org", + "Measures": "Meas", + "Mechanical": "Mech", + "Mechanism": "Mech", + "Member": "Mbr", + "Membership": "Mbrp", + "Month": "Mon", + "Monthly": "Mon", + "Months": "Mon", + "Obligation": "Oblig", + "Obligations": "Oblig", + "Operate": "Op", + "Operating": "Op", + "Operates": "Op", + "Operated": "Op", + "Operating": "Op", + "Operational": "Op", + "Operations": "Op", + "Operator": "Op", + "Opinion": "Opin", + "Optimal": "Opt", + "Optimization": "Opt", + "Optimized": "Opt", + "Option": "Opt", + "Options": "Opt", + "Original": "Orig", + "Origination": "Orig", + "Outstanding": "Outstng", + "Owned": "Own", + "Owner": "Own", + "Ownership": "Own", + "Payment": "Pmt", + "Payments": "Pmt", + "Percent": "Pct", + "Percentage": "Pct", + "Power": "Pwr", + "Preventative": "Prevent", + "Pricing": "Price", + "Procurement": "Procur", + "Product": "Prod", + "Production": "Prod", + "Project": "Proj", + "Projects": "Proj", + "Properties": "Props", + "Purchase": "Purch", + "Qualification": "Qualif", + "Qualifications": "Qualif", + "Qualifying": "Qualif", + "Quality": "Qual", + "Quantity": "Quant", + "Quarter": "Qtr", + "Quarterly": "Qtr", + "Receivable": "Recv", + "Receivables": "Recv", + "Receive": "Recv", + "Received": "Recv", + "Receiver": "Recv", + "Registration": "Regn", + "Regulatory": "Regl", + "Report": "Rpt", + "Reportable": "Rpt", + "Reported": "Rpt", + "Reporting": "Rpt", + "Request": "Req", + "Required": "Reqd", + "Requirements": "Reqrmnts", + "Resulting": "Rslt", + "Results": "Rslt", + "Return": "Rtn", + "Schedule": "Sched", + "Scheduling": "Sched", + "Service": "Serv", + "Services": "Serv", + "Software": "SW", + "Structural": "Struct", + "Structure": "Struct", + "Structures": "Struct", + "Subcontractor": "Subcon", + "Submission": "Submsn", + "Supplement": "Supl", + "Supplemental": "Supl", + "Supplementary": "Supl", + "Termination": "Term", + "Test": "Tst", + "Testing": "Tst", + "Tests": "Tst", + "Transaction": "Txn", + "Transmission": "Txm", + "Transportation": "Trans", + "Unavailability": "Unavail", + "Unavailable": "Unavail", + "Underwriting": "Undrwrtng", + "Warranties": "Warr", + "Warranty": "Warr", + "Emergency": "Emerg", + "Capacity": "Cap", + "Activities": "Activ", + "Accounts": "Acct", + "Attributable": "Attr", + "Funding": "Fund", + "Grounding": "Gnd", + "Independent": "Indep", + "Inspection": "Inspct", + "Instructions": "Instr", + "Interconnect": "Interconn", + "Interconnection": "Interconn", + "Internal": "Intrnl", + "Investing": "Invest", + "Investment": "Invest", + "Irradiance": "Irrad", + "Length": "Len", + "Liabilities": "Liab", + "Liability": "Liab", + "Market": "Mkt", + "Measure": "Meas", + "Measured": "Meas", + "Measurement": "Meas", + "Measurements": "Meas" +} \ No newline at end of file diff --git a/viewer/tests/test_viewer.py b/viewer/tests/test_viewer.py index 08a56e8..a5ddccd 100644 --- a/viewer/tests/test_viewer.py +++ b/viewer/tests/test_viewer.py @@ -48,3 +48,10 @@ def test_units(self): self.assertTrue("type" in data[0]) self.assertTrue("standard" in data[0]) self.assertTrue("definition" in data[0]) + + def test_references(self): + data = json.loads(viewer.references()) + self.assertEqual(305, len(data)) + self.assertTrue("type" in data[0]) + self.assertTrue("code" in data[0]) + self.assertTrue("definition" in data[0]) \ No newline at end of file diff --git a/viewer/viewer.py b/viewer/viewer.py index 2e4df0b..6a689d4 100644 --- a/viewer/viewer.py +++ b/viewer/viewer.py @@ -20,6 +20,8 @@ $ FLASK_APP=viewer.py flask run """ +import reference + import json from oblib import taxonomy, data_model, parser from flask import Flask, request, render_template @@ -174,6 +176,34 @@ def entrypoints(): print(e) return "Error occurred - try again" +@app.route('/references/', methods=['GET']) +def references(): + """Flask Read Handler for types API Endpoint""" + + print("Reference endpoint") + + try: + data = [] + for item in reference.ACRONYMS.items(): + data.append({ + "type": "Acronym", + "code": item[1], + "definition": item[0] + }) + + for item in reference.ABBREVIATIONS.items(): + data.append({ + "type": "Abbreviation", + "code": item[1], + "definition": item[0] + }) + + s = json.dumps(data) + return s + except Exception as e: + print(e) + return "Error occurred - try again" + if __name__ == "__main__": app.run(debug=True, port=5000) \ No newline at end of file diff --git a/web/src/components/Navbar.vue b/web/src/components/Navbar.vue index 9a53c6e..d839f4f 100644 --- a/web/src/components/Navbar.vue +++ b/web/src/components/Navbar.vue @@ -35,6 +35,9 @@