Project description placed inside the folder. I only need help on how to implement the new function.
__MACOSX/._basicGRPC basicGRPC/Project Description.docx 1. In this scenario, the file /basicGRPC/server/src/server.py is considered the server and handles the computations and return values involved with invoking the function whohas. The files /basicGRPC/client/src/client-py.py and /basicGRPC/client/src/client-node.js are considered the clients, allowing users to remotely call services provided by the server. Sitting in-between the server and the client is the mediator that declares the services and messages that will be communicated, /basicGRPC/protos/keysearch/proto/keysearch.proto. 2. If you do not have them already, install the dependencies needed to execute the program. Note, these installation instructions were made with a Linux machine in mind. Additionally, if you are receiving permission errors, prepend your commands with sudo. . Always a good idea to update your package manager first: $ apt update $ apt upgrade · If you are using a fresh machine instantiation, you might need to install Python as well: $ apt install python3 · Install and update pip (Python package manager): $ apt install python3-pip $ python3 -m pip install --upgrade pip · Install pipenv: $ pip3 install pipx $ pip3 install pipenv · Install protobuf: $ pip3 install protobuf · Install gRPC: $ pip3 install grpcio-tools · Install Node.js: $ apt install nodejs · Install and update npm: $ apt install npm $ npm install -g npm@next 0. Now that all of the dependencies are installed, navigate to the location of your /basicGRPC directory. If the basicGRPC folder you downloaded is located in your /home/User/Documents directory, you can travel there with: $ cd /home/User/Documents/basicGRPC 0. Generate the preliminary libraries and build the virtual environment: $ make prelim 0. Start the Python virtual environment. This is something that will need to be done every time you enter a new terminal: $ pipenv shell *Notice that the environment you are currently in (basicGRPC) is located to the left of your username: 0. Instantiate the environment variables. These are constants that are important to the application: $ . ./server.env 0. Now it is time to build and run the server: $ make server *The server is now running, indicated by the current port number it is listening on. Do not close this terminal: 0. In a separate terminal, make and run the Python client (be sure to enter the virtual environment again): $ make client-py ARGS=”whohas money” *This is the command used to invoke our function (whohas) remotely from the server (server.py), where money is the argument we are passing. whohas searches a “database”, represented by /basicGRPC/server/db/index.txt, for the word and returns the files it is found in as well as the amount of times the word appears in the file. The output looks something like this: 0. gRPC communication is language independent. Alongside the Python version of the client, we have a version written in Node.js. To make and run this version: $ make client-node ARGS=”whohas money” 0. In its current state, the program only supports one function, whohas. It is your goal to implement a new function that can be called from the client. This function will accept a new argument, representing the minimum amount of times the given word appears in a document. The return of this function call will be similar to the return of whohas, but only return those files in which this word appears a minimum amount of times. Additionally, the user should still be able to call the original function. For example: Input: $ make client-node ARGS=”whohas money” Output: Input: $ make client-node ARGS=”whohas2 money 100” Output: *Tips · You do not need to implement the new function in Python, you only need to implement it with the Node.js version. · A few sections of code that are already written can be reimplemented to support your new function. · Some areas that might need to be altered: · mincount in /basicGRPC/server/src/server.py · Query and KeywordSearch in /basicGRPC/protos/keysearch/proto/keysearch.proto · /basicGRPC/client/src/client-node.js 1. Explain the changes you made to create your new function and how it was implemented. __MACOSX/basicGRPC/._Project Description.docx __MACOSX/basicGRPC/._protos basicGRPC/.DS_Store __MACOSX/basicGRPC/._.DS_Store basicGRPC/Makefile .PHONY: help list targets protos dist-server requirements startapp projectid .DEFAULT_GOAL := help PROJECT_ID=keywordsearch ME := $(realpath $(firstword $(MAKEFILE_LIST))) PWD := $(dir $(ME)) help: targets ## List targets [aka help | list | targets] list: targets targets: @echo @echo "Make targets:" @echo @cat $(ME) | \ sed -n -E 's/^([^.[:space:]][^: ]+)\s*:(([^=#]*##\s*(.*[^[:space:]])\s*))$$/ \1\4/p' | \ sort -u | \ expand -t20 @echo check-server-env: @if [ -z "${SERVER_GRPC_PORT}"]; then \ echo "!! ERROR: One or more server variables missing:"; \ echo " - SERVER_GRPC_PORT"; \ echo " - SERVER_BASE_URL"; \ echo ""; \ echo "Did you source server.env ?"; \ exit 1; \ fi protos: ## Compile .proto files rm -f libs/proto/keyword_search/proto/*.py python3 -m grpc_tools.protoc \ -I./protos \ --include_imports \ --include_source_info \ --python_out=./libs/proto \ --grpc_python_out=./libs/proto \ --descriptor_set_out=./keysearch_service.pb \ ./protos/keysearch/proto/*.proto node-libs: npm install --prefix "${PWD}./client/src/" @grpc/grpc-js npm install --prefix "${PWD}./client/src/" @grpc/proto-loader prelim: protos pipenv install server: check-server-env protos ## Launch server app locally via pipenv pipenv run python3 "${PWD}./server/src/server.py" client-py: protos ## Launch client app locally via pipenv pipenv run python3 "${PWD}./client/src/client-py.py" ${ARGS} client-node: node-libs node "${PWD}./client/src/client-node.js" ${ARGS} __MACOSX/basicGRPC/._Makefile __MACOSX/basicGRPC/._server __MACOSX/basicGRPC/._libs basicGRPC/README.MD ### These instructions were made with a Linux machine in mind ### Common prerequisites: python (v3.8+), pyenv, pipenv, protobuf, Node.js (v10.0+), grpc, npm (v6.0+) ### Always a good idea to update package manager: ``` $ apt update $ apt upgrade ``` ### How to install python: ``` $ apt install python3 ``` ### How to install and update pip: ``` $ apt install python3-pip $ python3 -m pip install --upgrade pip ``` ### How to install pipenv: ``` $ pip3 install pipx $ pip3 install pipenv ``` ### How to install protobuf: ``` $ pip3 install protobuf ``` ### How to install grpc: ``` $ pip3 install grpcio-tools ``` ### How to install Node.js: ``` $ apt install nodejs ``` ### How to install and update npm: ``` $ apt install npm $ npm install -g npm@next ``` ### Now all of the immediate dependencies should be installed ### go to basicGRPC directory ``` $ cd basicGRPC ``` ### Generate the preliminary libraries and build the virtual environment ``` $ make prelim ``` ### start python env (need to do everytime) ### If the following does not work, try Pipenv shell with an uppercase P ``` $ pipenv shell ``` ### Instantiate the environment variables. These are constants that are important to the application ``` $ . ./server.env ``` ### Make and run server ``` $ make server ``` ### The server is now running ### Do not close this terminal ### Now it's time to make and run the client ### Open up a new terminal (be sure to enter the virtual env again with pipenv shell) ### ARGS= is a way to pass along command line arguments from make file to ### first argument is the grpc function name to call (currently we only have whohas) ### next argument is the argument of function that we call (in this case, keyword to search) ### example of calling whohas through grpc to search for word "money": ``` $ make client-py ARGS="whohas money" ``` ### Execute client-node, where money is the keyword we are searching for ``` $ make client-node ARGS="whohas money" ``` ### TIPS on implementing the two-argument function: ### You only need to implement the new function in the Node.js version of the client ### A few sections of code can be reimplemented to support the new function ### mincount in server/src/server.py will need to be altered ### Query and KeywordSearch in protos/keysearch/proto/keysearch.proto will need to be altered as well ### The client-node.js file in client/src will also need to be altered __MACOSX/basicGRPC/._README.MD basicGRPC/Pipfile [[source]] name = "pypi" url = "https://pypi.org/simple" verify_ssl = true [dev-packages] [packages] grpcio = "*" grpcio-tools = "*" grpcio-testing = "*" grpcio-reflection = "*" psycopg2-binary = "*" googleapis-common-protos = "*" googleapis-common-protos-stubs = "*" keysearch-proto = {editable = true,path = "./libs/proto"} [requires] python_version = "3.8" __MACOSX/basicGRPC/._Pipfile basicGRPC/keysearch_service.pb basicGRPC/server.env export SERVER_GRPC_PORT=50051 __MACOSX/basicGRPC/._server.env basicGRPC/Pipfile.lock { "_meta": { "hash": { "sha256": "f2ff63c5f0b44bc86f19e86c1a4cd792156097a398b095b0ac9fc03bfdc00bac" }, "pipfile-spec": 6, "requires": { "python_version": "3.8" }, "sources": [ { "name": "pypi", "url": "https://pypi.org/simple", "verify_ssl": true } ] }, "default": { "googleapis-common-protos": { "hashes": [ "sha256:a88ee8903aa0a81f6c3cec2d5cf62d3c8aa67c06439b0496b49048fb1854ebf4", "sha256:f6d561ab8fb16b30020b940e2dd01cd80082f4762fa9f3ee670f4419b4b8dbd0" ], "index": "pypi", "version": "==1.53.0" }, "googleapis-common-protos-stubs": { "hashes": [ "sha256:2ae33df34cdf50f0c8bdaabe5689cc343d3338bae49ca16100e7c682cf1773ef", "sha256:3ada7b1be5123a0a737b9be1c5af1f1dd2ce0419cc19203b3c203374db0f700a" ], "index": "pypi", "version": "==2.0.0" }, "grpc-stubs": { "hashes": [