Skip to content

Commit

Permalink
Finalize the readme file and Update the Contributing.md file (#39)
Browse files Browse the repository at this point in the history
* Finalise the readme file.

* Update the contrinbuting.md with developer guidelines.

* Fix Typo

* Fix Typo

* Update the host_as_grpc_service to host_service and fix typo.

* Add dev dependency info for the stub file generation.

* Resolve review comments on readme/contributing md style.

* Add the source info of proto file in contributing.md

* Recreated Lock after main rebase conflicts on poetry lock file.

* Remove space between tabel of contents.

* Update a statement on poetry install.

* Fix header link issue on "Steps to run the measurement service"

* Update Readme with minor refactoring.

* Add Ide info in readme

* Resolve Review comments and Update content in Readme.
  • Loading branch information
Vasantha-Kumar-J authored Mar 31, 2022
1 parent ab8fcab commit 4fe3018
Show file tree
Hide file tree
Showing 8 changed files with 411 additions and 139 deletions.
94 changes: 86 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,107 @@
Contributions to Measurement Services Support for Python are welcome from all!

Measurement Services Support for Python is managed via [git](https://git-scm.com), with the canonical upstream
repository hosted on [GitHub](https://github.com/ni/measurement-services-python/).
repository hosted on [GitHub](https://github.com/ni/measurement-services-python/). The repo contains the necessary Python Measurement templates and examples to call into the Measurement Services.

Measurement Services Support for Python follows a pull-request model for development. If you wish to
contribute, you will need to create a GitHub account, fork this project, push a
branch with your changes to your project, and then submit a pull request.

Please remember to sign off your commits (e.g., by using `git commit -s` if you
are using the command line client). This amends your git commit message with a line
of the form `Signed-off-by: Name Lastname <name.lastmail@emailaddress.com>`. Please
are using the command-line client). This amends your git commit message with a line
of the form `Signed-off-by: Name LastName <name.lastmail@emailaddress.com>`. Please
include all authors of any given commit into the commit message with a
`Signed-off-by` line. This indicates that you have read and signed the Developer
Certificate of Origin (see below) and are able to legally submit your code to
Certificate of Origin (see below) and can legally submit your code to
this repository.

See [GitHub's official documentation](https://help.github.com/articles/using-pull-requests/) for more details.

# Getting Started

- TODO: include build steps here.
## Prerequisites

- Install the [Visual Studio Code](https://code.visualstudio.com/download).
- Install Git.
- Install [Poetry](https://python-poetry.org/docs/#installation).
- Install Python and add it to the PATH. (Recommended Version:3.8)

## Clone Repo

Clone the repo, this will pull the NI Measurement Service Framework components and related components.

```cmd
git clone https://github.com/ni/measurement-services-python.git
```

## Initializing the repo with .venv

From the root directory of the repo, initialize the project using the [poetry init](https://python-poetry.org/docs/cli/#init) command. This will set up a .venv with all the required dependencies based on poetry.lock file and pyproject.toml.

```cmd
poetry init
```

## Ensure that the `./.venv` virtual environment is activated

- In the command prompt: `poetry shell`
- In the vscode ([link](https://code.visualstudio.com/docs/python/environments#_select-and-activate-an-environment))
- ALTERNATIVE: run commands with `poetry run`. i.e., `poetry run python measurement.py`

# Adding dependencies

Add dependency package for `ni_measurement_service` using [poetry add](https://python-poetry.org/docs/cli/#add) command.

```cmd
poetry add <name_of_dependency>:<version>
```

Add **development dependencies** with the `-D` switch as shown below.

```cmd
poetry add -D <name_of_dev_dependency>:<version>
```

# Updating gRPC stubs when a .proto file is modified

The `ni_measurement_service\_internal\stubs` directory contains the auto-generated python files based on measurement services related protobuf (.proto) files. The file needs to be replaced whenever there is a change to these .proto files:

- DiscoveryServices.proto
- Measurement.proto
- ServiceLocation.proto
- ServiceManagement.proto

The .proto files are currently available in [Azure Repo](https://dev.azure.com/ni/DevCentral/_git/ASW?path=/Source/MeasurementServices/proto). From the Azure Repo manually copy the proto files to the `ni_measurement_service\_internal\stubs\proto` folder.

The commands below generate the .py file from all the proto files listed above. Run the commands after activating the `.venv` from the project root. The required `grpcio-tool` package is already added as a development dependency in pyproject.toml.

```cmd
cd <parent_path_of_repo>\ni_measurement_service\_internal\stubs
```

```cmd
python -m grpc_tools.protoc -I proto --python_out=. --grpc_python_out=. ServiceLocation.proto DiscoveryServices.proto Measurement.proto ServiceManagement.proto
```

After the files are autogenerated change the imports of xxxx_pb2.py in xxxx_pb2_grpc.py to relative imports. For example, in `DiscoveryServices_pb2_grpc.py` we convert the imports of `DiscoveryServices_pb2` and `ServiceLocation_pb2` as relative imports.

``` py
# DiscoveryServices_pb2_grpc.py
from . import DiscoveryServices_pb2 as DiscoveryServices__pb2
from . import ServiceLocation_pb2 as ServiceLocation__pb2
```

# Build

```cmd
poetry build
```

Running this command from the repo's root directory will generate the tar.gz file and .whl file of ni_measurement_service package to the `dist` directory.

# Testing

- TODO: include testing steps here.
TODO: include testing steps here.

# Developer Certificate of Origin (DCO)

Expand All @@ -34,14 +112,14 @@ See [GitHub's official documentation](https://help.github.com/articles/using-pul
By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
have the right to submit it under the open source license
have the right to submit it under the open-source license
indicated in the file; or

(b) The contribution is based upon previous work that, to the best
of my knowledge, is covered under an appropriate open source
license and I have the right under that license to submit that
work with modifications, whether created in whole or in part
by me, under the same open source license (unless I am
by me, under the same open-source license (unless I am
permitted to submit under a different license), as indicated
in the file; or

Expand Down
Loading

0 comments on commit 4fe3018

Please sign in to comment.