Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into AH/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
haneslinger committed Jan 17, 2024
2 parents 732b83e + 418e9c0 commit 32065a3
Show file tree
Hide file tree
Showing 37 changed files with 543 additions and 223 deletions.
2 changes: 2 additions & 0 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"auditlog",
"auth",
"autogenerated",
"automodule",
"aws",
"AWS",
"backend",
Expand Down Expand Up @@ -54,6 +55,7 @@
"casted",
"cb",
"CEJST",
"celerybeat",
"cfg",
"changelog",
"checkbox",
Expand Down
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
.DS_Store
.cache
.coverage
.cspell.txt
.DS_Store
.env
.hypothesis
.idea
.project
.pydevproject
.python-version
.coverage
.vscode
coverage.protractor.json
.vscode
*~
*~$*
*.ipynb
*.pyc
*.swp
*.swo
Expand All @@ -25,7 +26,6 @@ pkgs/newrelic-1\.6\.0\.13\.tar\.gz
chromedriver.log
ipython_input_log_history
.ipython_input_log_history
*.ipynb
**/ipython_input_log_history
web_root/csvs/*
web_root/uploads/*
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SEED Platform™, Copyright (c) 2017, 2023 Alliance for Sustainable Energy, LLC, and other contributors.
SEED Platform™, Copyright (c) 2017, 2024 Alliance for Sustainable Energy, LLC, and other contributors.
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted
Expand Down
4 changes: 1 addition & 3 deletions bin/protractor_start_server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ echo "run e2e tests"
./node_modules/protractor/bin/protractor seed/static/seed/tests/protractor-tests/protractorConfigCoverage.js
# echo "install coverall merge stuffs"
# gem install coveralls-lcov
# pip install coveralls-merge
# echo "run lcov to coveralls json"
# coveralls-lcov -v -n protractorReports/lcov.info > coverage.protractor.json
# echo "merge and post coveralls"
# coveralls-merge coverage.protractor.json
# echo "upload to coveralls"
8 changes: 5 additions & 3 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@
templates_path = ['_templates']

# Location of word list.
spelling_word_list_filename = '../../.cspell.json'
# convert the spelling list to a text file and save
open('../../.cspell.txt', 'w').write('\n'.join(json.load(open('../../.cspell.json'))['words']))
spelling_word_list_filename = '../../.cspell.txt'

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
Expand All @@ -71,7 +73,7 @@

# General information about the project.
project = 'SEED Platform'
copyright = '2017, 2023, Alliance for Sustainable Energy, LLC, and other contributors.'
copyright = '2017, 2024, Alliance for Sustainable Energy, LLC, and other contributors.'
author = 'Alliance for Sustainable Energy, LLC, and other contributors.'

# The version info for the project you're documenting, acts as replacement for
Expand All @@ -91,7 +93,7 @@
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
language = 'en'

# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
Expand Down
2 changes: 1 addition & 1 deletion docs/source/docker.rst
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ Ubuntu server 18.04 or newer with a m5ad.xlarge (if using in Production instance
Deploying with Docker
^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^^

The preferred way to deploy with Docker is using docker swarm and docker stack.
Look at the `deploy.sh script`_ for implementation details.
Expand Down
8 changes: 4 additions & 4 deletions docs/source/kubernetes_deployment.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ Helm
Helm organizes all of your Kubernetes deployment, service, and volume yml files into "charts" that can be deployed, managed, and published with simple commands.
To install Helm:

* `Windows eksctl https://kubernetes.io/docs/tasks/tools/install-kubectl/#install-kubectl-on-windows`_
* `Windows eksctl <https://kubernetes.io/docs/tasks/tools/install-kubectl/#install-kubectl-on-windows>`_
* Mac (with Homebrew) :code:`brew install helm`

EKS Control (AWS Specific)
^^^^^^^^^^^^^^^^^^^^^^^^^^
EKSCtl is a command line tool to manage Elastic Kubernetes clusters on AWS. If not using AWS, then disregard this section.

* `Windows <https://www.stacksimplify.com/aws-eks/eks-cluster/install-aws-eksctl-kubectl-cli/#step-02-02-windows-10-install-and-configure-kubectl>`_
* `Windows eksctl config <https://www.stacksimplify.com/aws-eks/eks-cluster/install-aws-eksctl-kubectl-cli/#step-02-02-windows-10-install-and-configure-kubectl>`_
* Mac (with Homebrew) :code:`brew install eksctl`

To launch a cluster on using EKSCts, run the following command in the terminal (assuming adequate permissions for the user). Also make sure to replace items in the `<>` brackets.
Expand Down Expand Up @@ -161,7 +161,7 @@ This chart contains the deployment specification for the Celery container to con
value: <super-secret-password> # must match db-postgres-deployment.yaml and web-celery-deployment.yaml
bsyncr-deployment.yaml
**************************
**********************
This chart contains the deployment specification for the bsyncr analysis server. Request a NOAA token from `this website <https://www.ncdc.noaa.gov/cdo-web/token>`_.

.. code-block:: yaml
Expand Down Expand Up @@ -239,7 +239,7 @@ The command below will restart the pods and re-pull the docker images.
Other Resources
---------------
Common kubectl actions can be found `here <https://kubernetes.io/docs/reference/kubectl/cheatsheet/>`_
Common kubectl actions can be found `on the kubernetes website <https://kubernetes.io/docs/reference/kubectl/cheatsheet/>`_


.. _AWS: https://docs.aws.amazon.com/eks/latest/userguide/create-cluster.html
Expand Down
4 changes: 1 addition & 3 deletions docs/source/migrations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,7 @@ Max OSX
Version 2.5.2
-------------

- There are no manual migrations that are needed. The `./manage.py migrate` command may take awhile
to run since the migration requires the recalculation of all the normalized addresses to parse
bldg correct and to cast the result as a string and not a bytestring.
- There are no manual migrations that are needed. The `./manage.py migrate` command may take awhile to run since the migration requires the recalculation of all the normalized addresses to parse bldg correct and to cast the result as a string and not a bytestring.

Version 2.5.1
-------------
Expand Down
8 changes: 0 additions & 8 deletions docs/source/modules/seed.rst
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,6 @@ Token Generator
:undoc-members:
:show-inheritance:

URLs
----

.. automodule:: seed.urls
:members:
:undoc-members:
:show-inheritance:

Utils
-----

Expand Down
16 changes: 0 additions & 16 deletions docs/source/modules/seed.utils.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,6 @@ Buildings
:undoc-members:
:show-inheritance:

Constants
---------

.. automodule:: seed.utils.constants
:members:
:undoc-members:
:show-inheritance:

Mappings
--------

.. automodule:: seed.utils.mapping
:members:
:undoc-members:
:show-inheritance:

Organizations
-------------

Expand Down
25 changes: 12 additions & 13 deletions requirements/test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,28 @@ psutil==5.6.7
# python testing
Faker==0.9.3
mock==2.0.0
coveralls-merge==0.0.3
vcrpy==4.2.1
pytest==7.2.0
pytest-django==4.5.2
pytest==7.4.4
pytest-django==4.7.0
# Lock urllib3 to v1 until vcrpy supports it
urllib3<2

# static code analysis
flake8==3.8.1
pycodestyle==2.6.0
pre-commit==2.19.0
flake8==7.0.0
pycodestyle==2.11.1
pre-commit==3.6.0

# documentation and spelling
Sphinx==4.0.2
sphinxcontrib-spelling==4.3.0
sphinx_rtd_theme==0.4.3
docutils==0.17.1
Sphinx==7.2.6
sphinxcontrib-spelling==8.0.0
sphinx_rtd_theme==2.0.0
docutils==0.20.1

# property-based testing
hypothesis==6.12.0
hypothesis==6.94.0

# For running the server
uWSGI==2.0.22; sys_platform != "win32"
uWSGI==2.0.23; sys_platform != "win32"

# static type checking
mypy==1.0.0
mypy==1.8.0
11 changes: 5 additions & 6 deletions seed/audit_template/audit_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,24 +59,23 @@ def get_submission(self, audit_template_submission_id: int, report_format: str =
Args:
audit_template_submission_id (int): value of the "Submission ID" as seen on Audit Template
report_format (str, optional): Report format, either `xml` or `pdf`. Defaults to 'pdf'.
report_format (str, optional): Report format, either `json`, `xml`, or `pdf`. Defaults to 'pdf'.
Returns:
requests.response: Result from Audit Template website
"""
# supporting 'PDF' and 'XML' formats only for now
# supporting 'JSON', PDF', and 'XML' formats only for now
token, message = self.get_api_token()
if not token:
return None, message

# validate format
if report_format.lower() not in ['xml', 'pdf']:
if report_format.lower() not in ['json', 'xml', 'pdf']:
report_format = 'pdf'

# set headers
headers = {'accept': 'application/pdf'}
if report_format.lower() == 'xml':
headers = {'accept': 'application/xml'}
accept_type = 'application/' + report_format.lower()
headers = {'accept': accept_type}

url = f'{self.API_URL}/rp/submissions/{audit_template_submission_id}.{report_format}?token={token}'
try:
Expand Down
4 changes: 2 additions & 2 deletions seed/data_importer/meters_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,11 +461,11 @@ class with the data.
# check which (if any) meter readings are provided
# there can be more than one reading type per row (e.g., both electricity
# and natural gas in the same row)
provided_reading_types = []
provided_reading_types = set()
for field in raw_data[0].keys():
for header_string in Meter.ENERGY_TYPE_BY_HEADER_STRING.keys():
if field.startswith(header_string):
provided_reading_types.append(field)
provided_reading_types.add(field)
continue

if not provided_reading_types:
Expand Down
21 changes: 21 additions & 0 deletions seed/migrations/0211_auto_20240109_1348.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Generated by Django 3.2.23 on 2024-01-09 21:48

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('seed', '0210_natural_sort'),
]

operations = [
migrations.RemoveConstraint(
model_name='derivedcolumn',
name='unique_name_for_organization',
),
migrations.AddConstraint(
model_name='derivedcolumn',
constraint=models.UniqueConstraint(fields=('organization', 'name', 'inventory_type'), name='unique_name_for_organization'),
),
]
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def set_analysis_ali(apps, schema_editor):
replaces = [('seed', '0211_auto_add_props_to_tree'), ('seed', '0212_auto_20230623_1556'), ('seed', '0213_analysis_access_level_instance')]

dependencies = [
('seed', '0210_natural_sort'),
('seed', '0211_auto_20240109_1348'),
('orgs', '0029_auto_20230413_1250'),
]

Expand Down
2 changes: 1 addition & 1 deletion seed/models/derived_columns.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ class DerivedColumn(models.Model):
class Meta:
constraints = [
models.UniqueConstraint(
fields=['organization', 'name'], name='unique_name_for_organization'
fields=['organization', 'name', 'inventory_type'], name='unique_name_for_organization'
)
]

Expand Down
13 changes: 12 additions & 1 deletion seed/serializers/meter_readings.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from typing import Tuple

import dateutil.parser
from django.core.exceptions import ValidationError
from django.db import connection
from django.utils.timezone import make_aware
from psycopg2.extras import execute_values
Expand Down Expand Up @@ -54,6 +55,17 @@ def create(self, validated_data) -> list[MeterReading]:

return updated_readings

def validate(self, data):
# duplicate start and end date pairs will cause sql errors
date_pairs = set()
for datum in data:
date_pair = (datum.get('start_time'), datum.get('end_time'))
if date_pair in date_pairs:
raise ValidationError('Error: Each reading must have a unique combination of start_time end end_time.')
date_pairs.add(date_pair)

return data


class MeterReadingSerializer(serializers.ModelSerializer):
class Meta:
Expand Down Expand Up @@ -95,7 +107,6 @@ def create(self, validated_data) -> MeterReading:

# Convert tuple to MeterReading for response
updated_reading = MeterReading(**{field: result[i] for i, field in enumerate(meter_fields)})

return updated_reading

def to_representation(self, obj):
Expand Down
Loading

0 comments on commit 32065a3

Please sign in to comment.