-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated examples, split into standalone directories, fixed pylint issues
- Loading branch information
dittmar
committed
Aug 5, 2024
1 parent
71864cd
commit b361084
Showing
25 changed files
with
168 additions
and
67 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
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
File renamed without changes.
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,12 +1,18 @@ | ||
FROM registry.disy.net/docker-hub-proxy/library/python:3.11.0-slim | ||
FROM python:3.11-slim | ||
|
||
RUN mkdir /service | ||
RUN mkdir /service/logs | ||
COPY ./requirements.txt /service/requirements.txt | ||
COPY ./extension /service/extension | ||
WORKDIR /service | ||
|
||
RUN apt-get update && apt-get -y upgrade | ||
RUN pip install -r requirements.txt | ||
RUN apt-get update && apt-get upgrade -y \ | ||
&& apt-get install -y --no-install-recommends \ | ||
build-essential \ | ||
gcc \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
RUN pip install --no-cache-dir -r requirements.txt | ||
|
||
CMD ["gunicorn", "-w", "4", "-b", ":8080", "--chdir", "extension", "example_extensions:analytics_service()", "--access-logfile", "../logs/access.log"] |
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,33 @@ | ||
"""Example module for running a disy Cadenza analytics extension that | ||
will show a (static) image in disy Cadenza""" | ||
import pandas as pd | ||
|
||
import cadenzaanalytics as ca | ||
|
||
|
||
def calculation_echo_analytics_function(metadata: ca.RequestMetadata, data: pd.DataFrame): | ||
return ca.CsvResponse(data, metadata.get_columns_by_attribute_group()['any_data']) | ||
|
||
|
||
any_attribute_group = ca.AttributeGroup( | ||
name="any_data", | ||
print_name="Any attribute", | ||
# any except geometry, these cannot be mixed to make it clear when a geometry or a related | ||
# non-geometry attribute is wanted from the user | ||
data_types=[ca.DataType.STRING, ca.DataType.INT64, ca.DataType.FLOAT64, ca.DataType.ZONEDDATETIME], | ||
min_attributes=1 | ||
) | ||
|
||
calculation_echo_extension = ca.CadenzaAnalyticsExtension( | ||
relative_path="calculation-echo-extension", | ||
analytics_function=calculation_echo_analytics_function, | ||
print_name="Example Echo Calculation Extension", | ||
extension_type=ca.ExtensionType.CALCULATION, | ||
attribute_groups=[any_attribute_group] | ||
) | ||
|
||
analytics_service = ca.CadenzaAnalyticsExtensionService() | ||
analytics_service.add_analytics_extension(calculation_echo_extension) | ||
|
||
if __name__ == '__main__': | ||
analytics_service.run_development_server(5005) |
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,7 @@ | ||
# --extra-index-url https://test.pypi.org/simple | ||
Flask>=2.2.5 | ||
Flask-Cors>=3.0.10 | ||
gunicorn>=20.1.0 | ||
requests-toolbelt>=1.0.0 | ||
pandas>=2.0.2 | ||
cadenzaanalytics |
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,2 @@ | ||
**/__pycache__ | ||
*.py[cod] |
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,18 @@ | ||
FROM python:3.11-slim | ||
|
||
RUN mkdir /service | ||
RUN mkdir /service/logs | ||
COPY ./requirements.txt /service/requirements.txt | ||
COPY ./extension /service/extension | ||
WORKDIR /service | ||
|
||
RUN apt-get update && apt-get upgrade -y \ | ||
&& apt-get install -y --no-install-recommends \ | ||
build-essential \ | ||
gcc \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
RUN pip install --no-cache-dir -r requirements.txt | ||
|
||
CMD ["gunicorn", "-w", "4", "-b", ":8080", "--chdir", "extension", "example_extensions:analytics_service()", "--access-logfile", "../logs/access.log"] |
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,7 @@ | ||
# --extra-index-url https://test.pypi.org/simple | ||
Flask>=2.2.5 | ||
Flask-Cors>=3.0.10 | ||
gunicorn>=20.1.0 | ||
requests-toolbelt>=1.0.0 | ||
pandas>=2.0.2 | ||
cadenzaanalytics |
This file was deleted.
Oops, something went wrong.
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,2 @@ | ||
**/__pycache__ | ||
*.py[cod] |
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,18 @@ | ||
FROM python:3.11-slim | ||
|
||
RUN mkdir /service | ||
RUN mkdir /service/logs | ||
COPY ./requirements.txt /service/requirements.txt | ||
COPY ./extension /service/extension | ||
WORKDIR /service | ||
|
||
RUN apt-get update && apt-get upgrade -y \ | ||
&& apt-get install -y --no-install-recommends \ | ||
build-essential \ | ||
gcc \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
RUN pip install --no-cache-dir -r requirements.txt | ||
|
||
CMD ["gunicorn", "-w", "4", "-b", ":8080", "--chdir", "extension", "example_extensions:analytics_service()", "--access-logfile", "../logs/access.log"] |
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,34 @@ | ||
"""Example module for running a disy Cadenza analytics extension that | ||
will show a (static) image in disy Cadenza""" | ||
import pandas as pd | ||
|
||
import cadenzaanalytics as ca | ||
|
||
|
||
def image_analytics_function(metadata: ca.RequestMetadata, data: pd.DataFrame): | ||
# pylint: disable=unused-argument | ||
with open("resources/example_image.png", "rb") as image_file: | ||
image = image_file.read() | ||
|
||
return ca.ImageResponse(image) | ||
|
||
|
||
image_attribute_group = ca.AttributeGroup( | ||
name="data", | ||
print_name="Data", | ||
data_types=[ca.DataType.STRING] | ||
) | ||
|
||
image_extension = ca.CadenzaAnalyticsExtension( | ||
relative_path="image-extension", | ||
analytics_function=image_analytics_function, | ||
print_name="Example Image Extension", | ||
extension_type=ca.ExtensionType.VISUALIZATION, | ||
attribute_groups=[image_attribute_group] | ||
) | ||
|
||
analytics_service = ca.CadenzaAnalyticsExtensionService() | ||
analytics_service.add_analytics_extension(image_extension) | ||
|
||
if __name__ == '__main__': | ||
analytics_service.run_development_server(5005) |
File renamed without changes
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,7 @@ | ||
# --extra-index-url https://test.pypi.org/simple | ||
Flask>=2.2.5 | ||
Flask-Cors>=3.0.10 | ||
gunicorn>=20.1.0 | ||
requests-toolbelt>=1.0.0 | ||
pandas>=2.0.2 | ||
cadenzaanalytics |
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
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
Oops, something went wrong.