Skip to content

Commit

Permalink
refactor: moved nibiru_protos into py-sdk (#255)
Browse files Browse the repository at this point in the history
* refactor: folder structure, nibiru_protos

* chore: moved tests

* chore: excluded .venv from flake8
  • Loading branch information
onikonychev authored Sep 22, 2023
1 parent ffc71ce commit 3334e78
Show file tree
Hide file tree
Showing 577 changed files with 50,643 additions and 209 deletions.
74 changes: 4 additions & 70 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,8 @@ jobs:
lint-py:
runs-on: ubuntu-latest
timeout-minutes: 2
# `jobs.<job_id>.defaults`:
# `jobs.<job_id>.defaults`:
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_iddefaultsrun
# defaults:
# run:
# working-directory: "pysdk"
steps:
- name: Check out the repo
uses: actions/checkout@v3
Expand All @@ -27,19 +24,6 @@ jobs:
with:
python-version: "3.8.16"

- name: "Load pip cache if cache exists"
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip
restore-keys: ${{ runner.os }}-pip
- name: "Install and run flake8"
run: |
python -m pip install flake8
flake8 pysdk
flake8 tests
flake8 examples
# ----------------------------------------------
# Try to load a cached poetry binary
# See https://github.com/snok/install-poetry#caching-the-poetry-installation for the source
Expand Down Expand Up @@ -69,59 +53,9 @@ jobs:
# if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root

- name: Run checks for black and isort
- name: Run black, isort, flake8 and mypy
run: |
poetry run black . --check
poetry run isort .
mypy-static:
runs-on: ubuntu-latest
# `jobs.<job_id>.defaults`:
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_iddefaultsrun
defaults:
run:
working-directory: "pysdk"
timeout-minutes: 2
steps:
- name: "Check out the repo"
uses: actions/checkout@v3

- name: "Setup Python"
uses: actions/setup-python@v2
with:
python-version: "3.8.16"
# ----------------------------------------------
# Try to load a cached poetry binary
# See https://github.com/snok/install-poetry#caching-the-poetry-installation for the source
# ----------------------------------------------
- name: "Load cached Poetry installation"
uses: actions/cache@v2
with:
path: ~/.local
key: poetry-2 # increment to reset cache

- name: "Install poetry"
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
version: latest
- name: "Load cached venv"
id: cached-poetry-dependencies
uses: actions/cache@v2
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}

- name: "Install dependencies with poetry (using cache)"
# if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root

- name: "poetry run mypy [files ...] [-h] [-v]"
run: |
poetry run isort . --check
poetry run flake8
poetry run mypy --version
# poetry run mypy tests --exclude 'pysdk/*'
# TODO: epic(pysdk): Add static type checking for pysdk (uncomment above)
# https://github.com/NibiruChain/py-sdk/issues/245
67 changes: 33 additions & 34 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,35 +1,34 @@
repos:
- repo: https://github.com/floatingpurr/sync_with_poetry
rev: "1.1.0" # the revision or tag to clone at
hooks:
- id: sync_with_poetry
args: [] # optional args
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: end-of-file-fixer
exclude: nibiru/proto/.+

- id: trailing-whitespace
exclude: nibiru/proto/.+

- repo: https://github.com/psf/black
rev: 22.12.0
hooks:
- id: black
files: \.py$
exclude: nibiru/proto/.+

- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
files: \.py$
exclude: nibiru/proto/.+
args: ["--profile", "black"]

- repo: https://github.com/pycqa/flake8
rev: 6.0.0
hooks:
- id: flake8
args: ["--max-line-length", "120"]
- repo: local
hooks:
- id: black
name: black
entry: poetry run black
language: system
types: [python]
exclude: >
(?x)^(
nibiru_proto/.+
)$
- repo: local
hooks:
- id: isort
name: isort
entry: poetry run isort
language: system
types: [python]
exclude: >
(?x)^(
nibiru_proto/.+
)$
- repo: local
hooks:
- id: flake8
name: flake8
entry: poetry run flake8
language: system
types: [python]
exclude: >
(?x)^(
nibiru_proto/.+
)$
8 changes: 4 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ All notable changes to this project will be documented in this file.

## [Unreleased]

## [v0.21.9](https://github.com/NibiruChain/py-sdk/tree/v0.21.9)
## [v0.21.10](https://github.com/NibiruChain/py-sdk/tree/v0.21.10)

- [#252](https://github.com/NibiruChain/py-sdk/pull/252) Updates the `nibiru-proto` dependency to v0.21.9, corresponding to the same version of NibiruChain/nibiru.
- deps!: This version of the chain uses Cosmos-SDK v0.47
- [#250](https://github.com/NibiruChain/py-sdk/pull/250): feat(perp): add query markets
- [#243](https://github.com/NibiruChain/py-sdk/pull/243): epic(tmrpc): all passing tests for v0.21
- [#238](https://github.com/NibiruChain/py-sdk/pull/238): epic: migration for v0.21 with passing tests
- [#238](https://github.com/NibiruChain/py-sdk/pull/238): epic: migration for v0.21 with passing tests
- [#238](https://github.com/NibiruChain/py-sdk/pull/238): epic: migration for v0.21 with passing tests
- [#238](https://github.com/NibiruChain/py-sdk/pull/238): epic: migration for v0.21 with passing tests
- [#235](https://github.com/NibiruChain/py-sdk/pull/235): ci: Run tests on release branches
- [#225](https://github.com/NibiruChain/py-sdk/pull/225): chore(deps): bump requests from 2.28.2 to 2.31.0
- [#249](https://github.com/NibiruChain/py-sdk/pull/249): chore(deps): Bump aiohttp from 3.8.4 to 3.8.5 in /pysdk
- [#249](https://github.com/NibiruChain/py-sdk/pull/249): chore(deps): Bump aiohttp from 3.8.4 to 3.8.5 in /pysdk

## v0.19.0

Expand Down
6 changes: 6 additions & 0 deletions HACKING.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ poetry install

This will resolve dependencies between each of the project's packages and install them into a virtual environment.

## Generating nibiru protos

```bash
poetry run ./scripts/proto-gen-py.sh
```

## Running tests

#### Setting environment variables
Expand Down
5 changes: 5 additions & 0 deletions nibiru_proto/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import os
import sys

sys.path.insert(0, os.path.abspath(os.path.dirname(__file__)))
version = '0.21.10'
30 changes: 30 additions & 0 deletions nibiru_proto/amino/amino_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

82 changes: 82 additions & 0 deletions nibiru_proto/amino/amino_pb2.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
"""
@generated by mypy-protobuf. Do not edit manually!
isort:skip_file
"""
import builtins
import google.protobuf.descriptor
import google.protobuf.descriptor_pb2
import google.protobuf.internal.extension_dict

DESCRIPTOR: google.protobuf.descriptor.FileDescriptor

NAME_FIELD_NUMBER: builtins.int
MESSAGE_ENCODING_FIELD_NUMBER: builtins.int
ENCODING_FIELD_NUMBER: builtins.int
FIELD_NAME_FIELD_NUMBER: builtins.int
DONT_OMITEMPTY_FIELD_NUMBER: builtins.int
name: google.protobuf.internal.extension_dict._ExtensionFieldDescriptor[google.protobuf.descriptor_pb2.MessageOptions, builtins.str]
"""name is the string used when registering a concrete
type into the Amino type registry, via the Amino codec's
`RegisterConcrete()` method. This string MUST be at most 39
characters long, or else the message will be rejected by the
Ledger hardware device.
"""
message_encoding: google.protobuf.internal.extension_dict._ExtensionFieldDescriptor[google.protobuf.descriptor_pb2.MessageOptions, builtins.str]
"""encoding describes the encoding format used by Amino for the given
message. The field type is chosen to be a string for
flexibility, but it should ideally be short and expected to be
machine-readable, for example "base64" or "utf8_json". We
highly recommend to use underscores for word separation instead of spaces.
If left empty, then the Amino encoding is expected to be the same as the
Protobuf one.
This annotation should not be confused with the `encoding`
one which operates on the field level.
"""
encoding: google.protobuf.internal.extension_dict._ExtensionFieldDescriptor[google.protobuf.descriptor_pb2.FieldOptions, builtins.str]
"""encoding describes the encoding format used by Amino for
the given field. The field type is chosen to be a string for
flexibility, but it should ideally be short and expected to be
machine-readable, for example "base64" or "utf8_json". We
highly recommend to use underscores for word separation instead of spaces.
If left empty, then the Amino encoding is expected to be the same as the
Protobuf one.
This annotation should not be confused with the
`message_encoding` one which operates on the message level.
"""
field_name: google.protobuf.internal.extension_dict._ExtensionFieldDescriptor[google.protobuf.descriptor_pb2.FieldOptions, builtins.str]
"""field_name sets a different field name (i.e. key name) in
the amino JSON object for the given field.
Example:
message Foo {
string bar = 1 [(amino.field_name) = "baz"];
}
Then the Amino encoding of Foo will be:
`{"baz":"some value"}`
"""
dont_omitempty: google.protobuf.internal.extension_dict._ExtensionFieldDescriptor[google.protobuf.descriptor_pb2.FieldOptions, builtins.bool]
"""dont_omitempty sets the field in the JSON object even if
its value is empty, i.e. equal to the Golang zero value. To learn what
the zero values are, see https://go.dev/ref/spec#The_zero_value.
Fields default to `omitempty`, which is the default behavior when this
annotation is unset. When set to true, then the field value in the
JSON object will be set, i.e. not `undefined`.
Example:
message Foo {
string bar = 1;
string baz = 2 [(amino.dont_omitempty) = true];
}
f := Foo{};
out := AminoJSONEncoder(&f);
out == {"baz":""}
"""
4 changes: 4 additions & 0 deletions nibiru_proto/amino/amino_pb2_grpc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
"""Client and server classes corresponding to protobuf-defined services."""
import grpc

30 changes: 30 additions & 0 deletions nibiru_proto/cosmos/app/runtime/v1alpha1/module_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 3334e78

Please sign in to comment.