-
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.
defining the streamlit rendering component and integration - adding script from giro3D examples - defining the wrapper function to render the streamlit component and passing params
- Loading branch information
1 parent
fab0c2b
commit 77184c6
Showing
18 changed files
with
32,117 additions
and
57 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
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,20 @@ | ||
## upstash based kafka parameters. | ||
|
||
KAFKA_BROKER_URL="" | ||
SASL_PLAIN_USERNAME="" | ||
SASL_PLAIN_PASSWORD="" | ||
|
||
|
||
|
||
## twitter env parameters | ||
|
||
CONSUMER_KEY="" | ||
CONSUMER_KEY_SECRET="" | ||
API_KEY="" | ||
API_KEY_SECRET="" | ||
BEARER_TOKEN="" | ||
|
||
## discord env variables | ||
|
||
|
||
|
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 @@ | ||
**/config.json |
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.8 | ||
|
||
RUN mkdir -p /usr/src/app/visualization | ||
COPY pyproject.toml /usr/src/app/pyproject.toml | ||
WORKDIR /usr/src/app | ||
|
||
ENV PATH = "${PATH}:/root/.local/bin" | ||
|
||
RUN curl -sSL https://install.python-poetry.org | python3 - && poetry install | ||
|
||
WORKDIR / | ||
|
||
RUN poetry config virtualenvs.create false | ||
|
||
COPY . /usr/src/app/visualization | ||
|
||
|
||
CMD ["streamlit run ", "app.py"] |
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,29 @@ | ||
# Lidarbot/Visualization: | ||
|
||
This application package renders 3D view of the reconstructed mesh by [bacalhau](../bacalau/) computation result. | ||
|
||
## Credits to: | ||
- [discord-bot-template](https://github.com/kkrypt0nn/Python-Discord-Bot-Template). | ||
- [streamlit-component](https://github.com/streamlit/component-template). | ||
|
||
## Tech stack: | ||
1. upstash : for integrating the bot with the kafka service. | ||
|
||
## build instructions: | ||
1. Defining the parameters for the bots: | ||
- For twitter and kafka provider: provide the parameters as defined by the `.env.example`. | ||
- `$ cp .env.example .env` | ||
- then also instantiate a config.json file (as defined by the config-example.json) and then return the result. | ||
|
||
- for discord: | ||
- the details are defined in the [readme](https://github.com/kkrypt0nn/Python-Discord-Bot-Template/blob/main/README.md) of the python discord bot template. | ||
|
||
- invite your bots by replacing the generated parameters using the url given [here](https://discord.com/oauth2/authorize?&client_id=1138054674696650842&scope=bot+applications.commands&permissions=2048): | ||
|
||
|
||
|
||
|
||
2. Run the docker container. | ||
|
||
|
||
For more information regarding the deployment on cloud, checkout the [aws_deployment](../aws_deployment/) setup. |
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,76 @@ | ||
""" | ||
frontend for users to access the 3D reconstructed tile and then render it on the browser | ||
""" | ||
import time | ||
import streamlit as st | ||
import os | ||
from kafka import KafkaConsumer, KafkaProducer | ||
from dotenv import load_dotenv, dotenv_values | ||
from visualizer_component import run_visualization | ||
st.set_page_config(layout="wide") | ||
|
||
|
||
config = dotenv_values(dotenv_path='../.env') | ||
|
||
topic = ['lidarbot_get_visualization'] | ||
|
||
consumer = KafkaConsumer( | ||
bootstrap_servers=[config["KAFKA_BROKER_URL"]], | ||
sasl_mechanism='SCRAM-SHA-256', | ||
security_protocol='SASL_SSL', | ||
sasl_plain_username=config["SASL_PLAIN_USERNAME"], | ||
sasl_plain_password=config["SASL_PLAIN_PASSWORD"], | ||
auto_offset_reset='earliest', | ||
consumer_timeout_ms=1000 | ||
) | ||
|
||
def parse_submit_visualization_documentation() -> list(str): | ||
consumer.subscribe(topic[0]) | ||
message = consumer.poll(timeout_ms=1000, max_records=1) | ||
## now parsing the details for the visualization of the tiles | ||
if message: | ||
message = message[0] | ||
key = message.key | ||
value = message.value | ||
data = str(value.decode('utf-8')).split(',') | ||
print(f"Received data from kafka: {data}") | ||
tileIpfs = data[0] | ||
username = data[1] | ||
return [tileIpfs, username] | ||
|
||
def render_visualization(Xcoord, Ycoord): | ||
[tileIpfs, username] = parse_submit_visualization_documentation() | ||
st.header(f"Visualization for tile {tileIpfs} submitted by {username}") | ||
|
||
while st.container(): | ||
# Code to render 3D visualization goes here | ||
time.sleep(1) | ||
run_visualization(tilesetIPFS=tileIpfs,Xcoordinate=Xcoord, Ycoordinate=Ycoord) | ||
|
||
|
||
def main(): | ||
st.title("georender: download 3D geospatial database from algorithms running on web3") | ||
st.text("add your twitter handle name, select the required geo-coordinates and then get your shp file ready") | ||
|
||
with st.sidebar: | ||
with st.expander("User-details" ,False): | ||
user_name = st.text_input("account user-name") | ||
with st.expander("add geo-coordinates", False): | ||
x_coord = st.text_input("X coordinates") | ||
y_coord = st.text_input("Y coordinates") | ||
|
||
## user before needs to set the env variables files. | ||
with st.button("submit details"): | ||
try: | ||
if user_name & x_coord & y_coord: | ||
render_visualization(Xcoord=x_coord, Ycoord= x_coord) | ||
st.success("Job submitted successfully") | ||
else: | ||
st.error("please enter the user name") | ||
except Exception as e: | ||
st.error(f"parameters not complete") | ||
st.stop() | ||
|
||
if __name__ == "__main__": | ||
main() |
Oops, something went wrong.