How to proceed: In Snap4City, this activity is strongly simplified since the Data Analytic can
- Develop the Data Analytic on local computer/workstations or on servers by using Python or Rstudio:
- Snap4City.org provides an online development user interface for Python (Jupiter Hub) and R (RStudio Server).
- From developed R/PY code you can directly access to Data from Storage performing REST Call API queries may be using some credential or access token to be authorized.
- From developed R/PY code you can directly send data into Storage sending them as Entity Instances and related Entity Messages (IoT Device messages) into one of the references Brokers at disposal.
- See example: https://www.snap4city.org/645
- Python usage of API: https://www.snap4city.org/829
- see also in the following the section on authentication and a section on Python access to API
- load Python or Rstudio on MicroService Node into Processing Logic (IoT App) to see them converted / deployed in Container on Cloud.
- bring the Python or Rstudio code into a container conforming the development according to Snap4City guidelines on Data Analytic development.
- Preparation of data parameters on function to send them on Data Analytic container, JSON to request computing Data Analytic (Python or Rstudio using different Nodes), see data result on debug. The Container of Data Analytic can pass back results and errors see example on the training course: https://www.snap4city.org/download/video/course/da/
- Use the Processing Logic (IoT App) to pass parameters to Python or Rstudio processes of Data Analytics and get results back into the Processing Logic (IoT App) in JSON, or get errors into the Processing Logic (IoT App) also in JSON.
- Please note that the Python and Rstudio processes in Container can directly access to the Smart City API. So that if they are designed in parametric manner (for example to work on the basis of data collected from a set of SURI, and in a time interval and these parameters are passed in the JSON input), the Data analytic node would be capable to provide Data Analytics as a Services on different data every time and automatically collecting the data (even big data amount) via a direct call of the Smart City API, using access token as described in the sequel.
- The user can also develop some Special Tools for implementing specific solutions providing their own visual interface, which may be included into dashboards as an External Service providing an HTTP URL.
In the following there is a code example in Python.
In Snap4City, there is a specific tutorial for the Data Analytic development with several examples: https://www.snap4city.org/download/video/course/da/