Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
1 change: 0 additions & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
hide:
- navigation
- toc
title: Title
template: home.html
---
<style>
Expand Down
10 changes: 5 additions & 5 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ channels:
dependencies:
- python>=3.9,<3.12
- mkdocs-material-extensions==1.1.1
- jinja2==3.1.2
- jinja2==3.1.3
- pytest==7.4.0
- pytest-mock==3.11.1
- pytest-cov==4.1.0
Expand All @@ -37,15 +37,15 @@ dependencies:
- azure-mgmt-storage==21.0.0
- boto3==1.28.2
- pyodbc==4.0.39
- fastapi==0.103.2
- fastapi==0.110.0
- httpx==0.24.1
- pyspark>=3.3.0,<3.6.0
- delta-spark>=2.2.0,<3.1.0
- grpcio>=1.48.1
- grpcio-status>=1.48.1
- googleapis-common-protos>=1.56.4
- openjdk==11.0.15
- openai==0.27.8
- openai==1.13.3
- mkdocs-material==9.3.1
- mkdocstrings==0.22.0
- mkdocstrings-python==1.4.0
Expand All @@ -67,14 +67,14 @@ dependencies:
- ecmwf-api-client==1.6.3
- netCDF4==1.6.4
- black==24.1.0
- joblib==1.3.2
- pip:
- databricks-sdk==0.20.0
- dependency-injector==4.41.0
- azure-functions==1.15.0
- azure-mgmt-eventgrid==10.2.0
- nest_asyncio==1.5.6
- hvac==1.1.1
- langchain==0.0.291
- langchain==0.1.11
- build==0.10.0
- deltalake==0.10.1
- trio==0.22.1
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
"grpcio>=1.48.1",
"grpcio-status>=1.48.1",
"googleapis-common-protos>=1.56.4",
"langchain==0.0.291",
"openai==0.27.8",
"langchain==0.1.11",
"openai==1.13.3",
"pydantic==2.4.2",
]

Expand Down
21 changes: 10 additions & 11 deletions src/api/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
# Do not include azure-functions-worker as it may conflict with the Azure Functions platform
azure-functions==1.15.0
fastapi==0.103.2
nest_asyncio==1.5.6
azure-functions==1.18.0
fastapi==0.110.0
pydantic==2.4.2
# turbodbc==4.11.0
pyodbc==4.0.39
importlib_metadata>=1.0.0
databricks-sql-connector==3.1.0
azure-identity==1.12.0
azure-identity==1.15.0
oauthlib>=3.2.2
pandas>=2.0.1,<3.0.0
numpy==1.23.5
jinja2==3.1.2
pytz==2022.6
semver==3.0.0
numpy==1.26.4
jinja2==3.1.3
pytz==2024.1
semver==3.0.2
xlrd==2.0.1
packaging==23.1
packaging==23.2
grpcio>=1.48.1
grpcio-status>=1.48.1
googleapis-common-protos>=1.56.4
langchain==0.0.291
openai==0.27.8
langchain==0.1.11
openai==1.13.3
pyjwt==2.8.0
4 changes: 1 addition & 3 deletions src/api/v1/circular_average.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from typing import Union
from src.api.FastAPIApp import api_v1_router
from fastapi import HTTPException, Depends, Body
import nest_asyncio

from src.sdk.python.rtdip_sdk.queries.time_series import circular_average
from src.api.v1.models import (
BaseQueryParams,
Expand All @@ -34,8 +34,6 @@
)
from src.api.v1.common import common_api_setup_tasks, json_response

nest_asyncio.apply()


def circular_average_events_get(
base_query_parameters,
Expand Down
4 changes: 1 addition & 3 deletions src/api/v1/circular_standard_deviation.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import numpy as np
from src.api.FastAPIApp import api_v1_router
from fastapi import HTTPException, Depends, Body
import nest_asyncio

from src.sdk.python.rtdip_sdk.queries.time_series import circular_standard_deviation
from src.api.v1.models import (
BaseQueryParams,
Expand All @@ -35,8 +35,6 @@
)
from src.api.v1.common import common_api_setup_tasks, json_response

nest_asyncio.apply()


def circular_standard_deviation_events_get(
base_query_parameters,
Expand Down
4 changes: 1 addition & 3 deletions src/api/v1/interpolate.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from src.api.FastAPIApp import api_v1_router
from fastapi import HTTPException, Depends, Body
import nest_asyncio

from src.sdk.python.rtdip_sdk.queries.time_series import interpolate
from src.api.v1.models import (
BaseQueryParams,
Expand All @@ -35,8 +35,6 @@
)
from src.api.v1.common import common_api_setup_tasks, json_response

nest_asyncio.apply()


def interpolate_events_get(
base_query_parameters,
Expand Down
4 changes: 1 addition & 3 deletions src/api/v1/interpolation_at_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from typing import Union
from src.api.FastAPIApp import api_v1_router
from fastapi import HTTPException, Depends, Body
import nest_asyncio

from src.sdk.python.rtdip_sdk.queries.time_series import interpolation_at_time
from src.api.v1.models import (
BaseQueryParams,
Expand All @@ -32,8 +32,6 @@
)
from src.api.v1.common import common_api_setup_tasks, json_response

nest_asyncio.apply()


def interpolation_at_time_events_get(
base_query_parameters,
Expand Down
6 changes: 2 additions & 4 deletions src/api/v1/latest.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@


import logging
from fastapi import Query, HTTPException, Depends, Body
import nest_asyncio
from fastapi import HTTPException, Depends, Body

from src.sdk.python.rtdip_sdk.queries.time_series import latest
from src.api.v1.models import (
BaseQueryParams,
Expand All @@ -30,8 +30,6 @@
from src.api.v1.common import common_api_setup_tasks, json_response
from src.api.FastAPIApp import api_v1_router

nest_asyncio.apply()


def latest_retrieval_get(
query_parameters, metadata_query_parameters, limit_offset_parameters, base_headers
Expand Down
6 changes: 2 additions & 4 deletions src/api/v1/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import logging
from fastapi import Query, HTTPException, Depends, Body
import nest_asyncio
from fastapi import HTTPException, Depends, Body

from src.sdk.python.rtdip_sdk.queries import metadata
from src.api.v1.models import (
BaseQueryParams,
Expand All @@ -28,8 +28,6 @@
from src.api.v1.common import common_api_setup_tasks, json_response
from src.api.FastAPIApp import api_v1_router

nest_asyncio.apply()


def metadata_retrieval_get(
query_parameters, metadata_query_parameters, limit_offset_parameters, base_headers
Expand Down
2 changes: 1 addition & 1 deletion src/api/v1/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ class HTTPError(BaseModel):
detail: str

class Config:
schema_extra = (
json_schema_extra = (
{
"example": {"detail": "HTTPException raised."},
},
Expand Down
4 changes: 1 addition & 3 deletions src/api/v1/raw.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import logging
import numpy as np
from fastapi import HTTPException, Depends, Body
import nest_asyncio

from src.sdk.python.rtdip_sdk.queries.time_series import raw
from src.api.v1.models import (
BaseHeaders,
Expand All @@ -30,8 +30,6 @@
from src.api.v1.common import common_api_setup_tasks, json_response
from src.api.FastAPIApp import api_v1_router

nest_asyncio.apply()


def raw_events_get(
base_query_parameters,
Expand Down
4 changes: 1 addition & 3 deletions src/api/v1/resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from typing import Union
from src.api.FastAPIApp import api_v1_router
from fastapi import HTTPException, Depends, Body
import nest_asyncio

from src.sdk.python.rtdip_sdk.queries.time_series import resample
from src.api.v1.models import (
BaseQueryParams,
Expand All @@ -34,8 +34,6 @@
)
from src.api.v1.common import common_api_setup_tasks, json_response

nest_asyncio.apply()


def resample_events_get(
base_query_parameters,
Expand Down
4 changes: 1 addition & 3 deletions src/api/v1/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

import logging
from fastapi import HTTPException, Depends, Body
import nest_asyncio

from src.sdk.python.rtdip_sdk.queries.sql.sql_query import SQLQueryBuilder
from src.api.v1.models import (
AuthQueryParams,
Expand All @@ -29,8 +29,6 @@
from src.api.v1.common import common_api_setup_tasks, json_response
from src.api.FastAPIApp import api_v1_router

nest_asyncio.apply()


def sql_get(
base_query_parameters,
Expand Down
3 changes: 0 additions & 3 deletions src/api/v1/summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

import logging
from fastapi import HTTPException, Depends, Body
import nest_asyncio
from src.sdk.python.rtdip_sdk.queries.time_series import summary
from src.api.v1.models import (
BaseHeaders,
Expand All @@ -31,8 +30,6 @@
from src.api.v1.common import common_api_setup_tasks, json_response
from src.api.FastAPIApp import api_v1_router

nest_asyncio.apply()


def summary_events_get(
base_query_parameters,
Expand Down
3 changes: 0 additions & 3 deletions src/api/v1/time_weighted_average.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from typing import Union
from src.api.FastAPIApp import api_v1_router
from fastapi import HTTPException, Depends, Body
import nest_asyncio
from src.sdk.python.rtdip_sdk.queries.time_series import time_weighted_average
from src.api.v1.models import (
BaseQueryParams,
Expand All @@ -33,8 +32,6 @@
)
from src.api.v1.common import common_api_setup_tasks, json_response

nest_asyncio.apply()


def time_weighted_average_events_get(
base_query_parameters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from langchain.chat_models import ChatOpenAI
from langchain import SQLDatabase
from langchain.agents import create_sql_agent
from langchain.agents.agent_toolkits import SQLDatabaseToolkit
from langchain_community.chat_models import ChatOpenAI
from langchain_community.utilities.sql_database import SQLDatabase
from langchain_community.agent_toolkits import create_sql_agent
from langchain_community.agent_toolkits import SQLDatabaseToolkit
from langchain.agents.agent_types import AgentType
import logging

Expand Down Expand Up @@ -144,7 +144,9 @@ def execute(self, query: str) -> None:
logging.exception("error while executing the query")
raise e

def fetch_all(self) -> list:
def fetch_all(
self,
) -> list:
"""
Gets all rows of a query.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ def _time_weighted_average_query(parameters_dict: dict) -> str:
",fill_step AS (SELECT *, {{ step }} AS Step FROM fill_value) "
"{% endif %}"
",interpolate AS (SELECT *, CASE WHEN `Step` = false AND `{{ status_column }}` IS NULL AND `{{ value_column }}` IS NULL THEN lag(`{{ timestamp_column }}`) OVER ( PARTITION BY `{{ tagname_column }}` ORDER BY `{{ timestamp_column }}` ) ELSE NULL END AS `Previous_{{ timestamp_column }}`, CASE WHEN `Step` = false AND `{{ status_column }}` IS NULL AND `{{ value_column }}` IS NULL THEN lag(`Fill_{{ value_column }}`) OVER ( PARTITION BY `{{ tagname_column }}` ORDER BY `{{ timestamp_column }}` ) ELSE NULL END AS `Previous_Fill_{{ value_column }}`, "
"lead(`{{ timestamp_column }}`) OVER ( PARTITION BY `{{ tagname_column }}` ORDER BY `{{ timestamp_column }}` ) AS `Next_{{ timestamp_column }}`, CASE WHEN `Step` = false AND `Status` IS NULL AND `{{ value_column }}` IS NULL THEN lead(`Fill_{{ value_column }}`) OVER ( PARTITION BY `{{ tagname_column }}` ORDER BY `{{ timestamp_column }}` ) ELSE NULL END AS `Next_Fill_{{ value_column }}`, CASE WHEN `Step` = false AND `{{ status_column }}` IS NULL AND `{{ value_column }}` IS NULL THEN `Previous_Fill_{{ value_column }}` + ( (`Next_Fill_{{ value_column }}` - `Previous_Fill_{{ value_column }}`) * ( ( unix_timestamp(`{{ timestamp_column }}`) - unix_timestamp(`Previous_{{ timestamp_column }}`) ) / ( unix_timestamp(`Next_{{ timestamp_column }}`) - unix_timestamp(`Previous_{{ timestamp_column }}`) ) ) ) ELSE NULL END AS `Interpolated_{{ value_column }}`, coalesce(`Interpolated_{{ value_column }}`, `Fill_{{ value_column }}`) as `Event_{{ value_column }}` FROM fill_step )"
"lead(`{{ timestamp_column }}`) OVER ( PARTITION BY `{{ tagname_column }}` ORDER BY `{{ timestamp_column }}` ) AS `Next_{{ timestamp_column }}`, CASE WHEN `Step` = false AND `{{ status_column }}` IS NULL AND `{{ value_column }}` IS NULL THEN lead(`Fill_{{ value_column }}`) OVER ( PARTITION BY `{{ tagname_column }}` ORDER BY `{{ timestamp_column }}` ) ELSE NULL END AS `Next_Fill_{{ value_column }}`, CASE WHEN `Step` = false AND `{{ status_column }}` IS NULL AND `{{ value_column }}` IS NULL THEN `Previous_Fill_{{ value_column }}` + ( (`Next_Fill_{{ value_column }}` - `Previous_Fill_{{ value_column }}`) * ( ( unix_timestamp(`{{ timestamp_column }}`) - unix_timestamp(`Previous_{{ timestamp_column }}`) ) / ( unix_timestamp(`Next_{{ timestamp_column }}`) - unix_timestamp(`Previous_{{ timestamp_column }}`) ) ) ) ELSE NULL END AS `Interpolated_{{ value_column }}`, coalesce(`Interpolated_{{ value_column }}`, `Fill_{{ value_column }}`) as `Event_{{ value_column }}` FROM fill_step )"
",twa_calculations AS (SELECT `{{ tagname_column }}`, `{{ timestamp_column }}`, `Window{{ timestamp_column }}`, `Step`, `{{ status_column }}`, `{{ value_column }}`, `Previous_{{ timestamp_column }}`, `Previous_Fill_{{ value_column }}`, `Next_{{ timestamp_column }}`, `Next_Fill_{{ value_column }}`, `Interpolated_{{ value_column }}`, `Fill_{{ status_column }}`, `Fill_{{ value_column }}`, `Event_{{ value_column }}`, lead(`Fill_{{ status_column }}`) OVER (PARTITION BY `{{ tagname_column }}` ORDER BY `{{ timestamp_column }}`) AS `Next_{{ status_column }}` "
', CASE WHEN `Next_{{ status_column }}` = "Good" OR (`Fill_{{ status_column }}` = "Good" AND `Next_{{ status_column }}` != "Good") THEN lead(`Event_{{ value_column }}`) OVER (PARTITION BY `{{ tagname_column }}` ORDER BY `{{ timestamp_column }}`) ELSE `{{ value_column }}` END AS `Next_{{ value_column }}_For_{{ status_column }}` '
', CASE WHEN `Fill_{{ status_column }}` = "Good" THEN `Next_{{ value_column }}_For_{{ status_column }}` ELSE 0 END AS `Next_{{ value_column }}` '
Expand Down