44import logging
55import matplotlib .pyplot as plt
66
7- # showcase for importing functions from another .py file (in this case from "./app/getGeoDataFrame.py")
8- from app .getGeoDataFrame import get_GDF
9-
7+ from app .panel import build_panel_app , serve_panel_app
108
119class App (object ):
1210
@@ -19,38 +17,12 @@ def execute(self, data: TrajectoryCollection, config: dict) -> TrajectoryCollect
1917 logging .info (f'Welcome to the { config } ' )
2018
2119 """Your app code goes here"""
20+
21+ pn_app = build_panel_app (data )
2222
23- # showcase injecting App settings (parameter `year`)
24- data_gdf = get_GDF (data ) # translate the TrajectoryCollection to a GeoDataFrame
25- logging .info (f'Subsetting data for { config ["year" ]} ' )
26- # subset the data to only contain the specified year
27- if config ["year" ] in data_gdf .index .year :
28- result = data_gdf [data_gdf .index .year == config ["year" ]]
29- else :
30- result = None
31-
32- # showcase creating an artifact
33- if result is not None :
34- result .plot (column = data .get_traj_id_col (), alpha = 0.5 )
35- plot_file = self .moveapps_io .create_artifacts_file ("plot.png" )
36- plt .savefig (plot_file )
37- logging .info (f'saved plot to { plot_file } ' )
38- else :
39- logging .warning ("Nothing to plot" )
40-
41- # showcase accessing auxiliary files
42- auxiliary_file_a = MoveAppsIo .get_auxiliary_file_path ("auxiliary-file-a" )
43- with open (auxiliary_file_a , 'r' ) as f :
44- logging .info (f .read ())
45-
46- # Translate the result back to a TrajectoryCollection
47- if result is not None :
48- result = TrajectoryCollection (
49- result ,
50- traj_id_col = data .get_traj_id_col (),
51- t = data .to_point_gdf ().index .name ,
52- crs = data .get_crs ()
53- )
23+ serve_panel_app (pn_app )
24+
25+ logging .info ("Panel app running on port 5006" )
5426
5527 # return the resulting data for next Apps in the Workflow
56- return result
28+ return data
0 commit comments