File tree Expand file tree Collapse file tree
wayang-api/wayang-api-json/src/main/scala
wayang-commons/wayang-core/src/main/java/org/apache/wayang/core/api Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -109,7 +109,7 @@ def execute(self):
109109 json_data ["operators" ] = []
110110
111111 nodes = []
112- pipeline = list ()
112+ pipeline = []
113113 self .graph .traversal (self .graph .starting_nodes , lambda x , parent : nodes .append (x ))
114114 id_table = {(obj .current [0 ]): index + 1 for index , obj in enumerate (nodes )}
115115 serializer = JSONSerializer (id_table )
@@ -123,10 +123,14 @@ def execute(self):
123123 json_data ["operators" ].append (serializer .serialize_pipeline (pipeline ))
124124
125125 json_data ["operators" ].append (serializer .serialize (operator ))
126- pipeline = list ()
126+ pipeline = []
127127
128- # This should either be configurable on the WayangContext or env
129- url = 'http://localhost:8080/wayang-api-json/submit-plan/json'
128+ port = self .configuration .get_property ("wayang.api.python.port" )
129+
130+ if port is None :
131+ port = 8080
132+
133+ url = f'http://localhost:{ port } /wayang-api-json/submit-plan/json'
130134 headers = {'Content-type' : 'application/json' }
131135 json_body = json .dumps (json_data )
132136 print (json_body )
Original file line number Diff line number Diff line change @@ -70,5 +70,8 @@ object Main extends ZIOAppDefault {
7070 val app = Routes (drawRoute, jsonRoute).toHttpApp
7171
7272 // Run it like any simple app
73- override val run = Server .serve(app).provide(Server .default)
73+ def run = for {
74+ args <- getArgs
75+ _ <- Server .serve(app).provide(Server .defaultWithPort((args.headOption getOrElse " 8080" toInt)))
76+ } yield ()
7477}
Original file line number Diff line number Diff line change 7575import java .util .Map ;
7676import java .util .Optional ;
7777import java .util .OptionalDouble ;
78+ import java .util .OptionalInt ;
7879import java .util .OptionalLong ;
7980import java .util .Properties ;
8081import java .util .Random ;
@@ -778,6 +779,20 @@ public long getLongProperty(String key) {
778779 return optionalLongProperty .getAsLong ();
779780 }
780781
782+
783+ public OptionalInt getOptionalIntProperty (String key ) {
784+ final Optional <String > intValue = this .properties .optionallyProvideFor (key );
785+ if (intValue .isPresent ()) {
786+ return OptionalInt .of (Integer .valueOf (intValue .get ()));
787+ } else {
788+ return OptionalInt .empty ();
789+ }
790+ }
791+
792+ public int getIntProperty (String key ) {
793+ return getOptionalIntProperty (key ).orElseThrow (() -> new WayangException (String .format ("No value for \" %s\" ." , key )));
794+ }
795+
781796 public long getLongProperty (String key , long fallback ) {
782797 return this .getOptionalLongProperty (key ).orElse (fallback );
783798 }
You can’t perform that action at this time.
0 commit comments