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

Summary endpoint revision and updates #584

Draft
wants to merge 23 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
741fd94
add summary by run uuids endpoint
rathod-b Sep 20, 2023
90c8923
add portfolio_uuid to APIMeta
rathod-b Oct 6, 2023
ffa3e0e
Merge branch 'summary_by_run_uuids' into summary-endpoint-updates
rathod-b Nov 21, 2023
66358fc
Update summary endpoint and rm unused endpoint
rathod-b Nov 21, 2023
b1bfb3a
fix merge migrations
rathod-b Nov 28, 2023
b61791e
Merge remote-tracking branch 'origin/develop' into summary-endpoint-u…
rathod-b Feb 27, 2024
69a26e3
Merge branch 'develop' into summary-endpoint-updates
rathod-b Feb 28, 2024
ad1776c
should fix migration issues
rathod-b Feb 28, 2024
ac06c14
Merge branch 'develop' into summary-endpoint-updates
rathod-b Mar 7, 2024
f97a3c6
Merge branch 'develop' into summary-endpoint-updates
rathod-b Mar 15, 2024
72e2d5d
Delete 0053_apimeta_portfolio_uuid.py
rathod-b Mar 15, 2024
9cca70e
Merge branch 'develop' into summary-endpoint-updates
rathod-b Mar 19, 2024
d21d738
Create 0055_apimeta_portfolio_uuid.py
rathod-b Mar 21, 2024
7549c3d
Update views.py
rathod-b Mar 28, 2024
275842d
Merge branch 'develop' into summary-endpoint-updates
rathod-b Apr 11, 2024
915339a
Update views.py
rathod-b Apr 11, 2024
3d5ac5f
fix migration issues
rathod-b Apr 11, 2024
b353fbc
add endpoint to unlink runs from portfolio
rathod-b May 7, 2024
24298ac
Update views.py
rathod-b May 8, 2024
e58a9aa
Update views.py
rathod-b May 8, 2024
0d30ac2
Merge branch 'develop' into summary-endpoint-updates
rathod-b Aug 2, 2024
1f63b51
push minor summary updates
rathod-b Aug 25, 2024
4f5403b
Update views.py
rathod-b Aug 29, 2024
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
4 changes: 2 additions & 2 deletions reo/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,11 @@ class UnexpectedError(REoptError):

__name__ = 'UnexpectedError'

def __init__(self, exc_type, exc_value, exc_traceback, task='', run_uuid='', user_uuid='', message=None):
def __init__(self, exc_type, exc_value, exc_traceback, task='', run_uuid='', user_uuid='', portfolio_uuid='', message=None):
debug_msg = "exc_type: {}; exc_value: {}; exc_traceback: {}".format(exc_type, exc_value, exc_traceback)
if message is None:
message = "Unexpected Error."
super(UnexpectedError, self).__init__(task=task, name=self.__name__, run_uuid=run_uuid, user_uuid=user_uuid,
super(UnexpectedError, self).__init__(task=task, name=self.__name__, run_uuid=run_uuid, user_uuid=user_uuid, portfolio_uuid=portfolio_uuid,
message=message, traceback=debug_msg)


Expand Down
13 changes: 13 additions & 0 deletions reoptjl/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,16 @@ def obj_create(self, bundle, **kwargs):
else:
webtool_uuid = None

if 'portfolio_uuid' in bundle.data.keys():

if type(bundle.data['portfolio_uuid']) == str:
if len(bundle.data['portfolio_uuid']) == len(run_uuid):
portfolio_uuid = bundle.data['portfolio_uuid']
else:
portfolio_uuid = ''
else:
portfolio_uuid = None

meta = {
"run_uuid": run_uuid,
"api_version": 3,
Expand All @@ -110,6 +120,9 @@ def obj_create(self, bundle, **kwargs):

if api_key != "":
bundle.data['APIMeta']['api_key'] = api_key

if portfolio_uuid is not None:
bundle.data['APIMeta']['portfolio_uuid'] = portfolio_uuid

log.addFilter(UUIDFilter(run_uuid))

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Generated by Django 4.0.7 on 2024-08-20 16:09

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('reoptjl', '0060_processheatloadinputs_addressable_load_fraction_and_more'),
]

operations = [
migrations.CreateModel(
name='PortfolioUnlinkedRuns',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('portfolio_uuid', models.UUIDField()),
('user_uuid', models.UUIDField()),
('run_uuid', models.UUIDField(unique=True)),
],
),
migrations.AddField(
model_name='apimeta',
name='portfolio_uuid',
field=models.TextField(blank=True, default='', help_text='The unique ID of a portfolio (set of associated runs) created by the REopt Webtool. Note that this ID can be shared by several REopt API Scenarios and one user can have one-to-many portfolio_uuid tied to them.'),
),
migrations.AlterField(
model_name='apimeta',
name='reopt_version',
field=models.TextField(blank=True, default='', help_text='Version number of the Julia package for REopt that is used to solve the problem.', null=True),
),
]
17 changes: 17 additions & 0 deletions reoptjl/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,12 @@ class APIMeta(BaseModel, models.Model):
default="",
help_text="NREL Developer API key of the user"
)
portfolio_uuid = models.TextField(
blank=True,
default="",
help_text=("The unique ID of a portfolio (set of associated runs) created by the REopt Webtool. Note that this ID can be shared by "
"several REopt API Scenarios and one user can have one-to-many portfolio_uuid tied to them.")
)

class UserUnlinkedRuns(models.Model):
run_uuid = models.UUIDField(unique=True)
Expand All @@ -196,6 +202,17 @@ def create(cls, **kwargs):
obj.save()
return obj

class PortfolioUnlinkedRuns(models.Model):
portfolio_uuid = models.UUIDField(unique=False)
user_uuid = models.UUIDField(unique=False)
run_uuid = models.UUIDField(unique=True)

@classmethod
def create(cls, **kwargs):
obj = cls(**kwargs)
obj.save()
return obj

class UserProvidedMeta(BaseModel, models.Model):
"""
User provided values that are not necessary for running REopt
Expand Down
3 changes: 3 additions & 0 deletions reoptjl/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@
re_path(r'^user/(?P<user_uuid>[0-9a-f-]+)/summary/?$', views.summary),
re_path(r'^user/(?P<user_uuid>[0-9a-f-]+)/summary_by_chunk/(?P<chunk>[0-9]+)/?$', views.summary_by_chunk),
re_path(r'^user/(?P<user_uuid>[0-9a-f-]+)/unlink/(?P<run_uuid>[0-9a-f-]+)/?$', views.unlink),
re_path(r'^user/(?P<user_uuid>[0-9a-f-]+)/unlink_from_portfolio/(?P<portfolio_uuid>[0-9a-f-]+)/(?P<run_uuid>[0-9a-f-]+)/?$', views.unlink_from_portfolio),
re_path(r'^ghp_efficiency_thermal_factors/?$', views.ghp_efficiency_thermal_factors),
re_path(r'^peak_load_outage_times/?$', views.peak_load_outage_times),
re_path(r'^invalid_urdb/?$', reoviews.invalid_urdb),
re_path(r'^schedule_stats/?$', reoviews.schedule_stats),
re_path(r'^get_existing_chiller_default_cop/?$', views.get_existing_chiller_default_cop),
re_path(r'^summary_by_runuuids/?$', views.summary_by_runuuids),
re_path(r'^link_run_to_portfolios/?$', views.link_run_uuids_to_portfolio_uuid)
]
Loading
Loading