Skip to content

Commit

Permalink
Make implementatation name settable from cli
Browse files Browse the repository at this point in the history
  • Loading branch information
sverhoeven committed Oct 17, 2023
1 parent a8d4e59 commit daeca16
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
4 changes: 2 additions & 2 deletions docs/server/Julia.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ The server can be started with

.. code-block:: sh
run-bmi-server --lang julia --name <MODEL-NAME> --port <PORT>
run-bmi-server --lang julia --name <MODEL-NAME>[,IMPLEMENTATION-NAME] --port <PORT>
For example with [Wflow.jl](https://github.com/Deltares/Wflow.jl/) use

.. code-block:: sh
run-bmi-server --lang julia --name Wflow.Model --port 55555
run-bmi-server --lang julia --name Wflow.Model,Wflow.bmi.BMI --port 55555
The Python grpc4bmi :ref:`usage` can then be used to connect to the server.
12 changes: 9 additions & 3 deletions grpc4bmi/run_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ def build_r(class_name, source_fn):
raise ValueError('Missing R dependencies, install with `pip install grpc4bmi[R]')
return BmiR(class_name, source_fn)

def build_julia(name: str):
def build_julia(name: str, implementation_name: str = 'BasicModelInterface'):
if not BmiJulia:
raise ValueError('Missing Julia dependencies, install with `pip install grpc4bmi[julia]')
return BmiJulia.from_name(name)
return BmiJulia.from_name(name, implementation_name)

def serve(model, port):
server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
Expand Down Expand Up @@ -120,7 +120,13 @@ def main(argv=sys.argv[1:]):
if args.language == "R":
model = build_r(args.name, path)
elif args.language == "julia":
model = build_julia(args.name)
names = args.name.split(',')
if len(names) == 2:
model = build_julia(names[0], names[1])
else:
model = build_julia(names[0])
# model.initialize('t')
# print(model.get_component_name())
else:
model = build(args.name, path)

Expand Down

0 comments on commit daeca16

Please sign in to comment.