Skip to content

adds type stubs for python imports#556

Merged
dpaiton merged 6 commits intomainfrom
dylan/get-max-wrapper
Aug 15, 2023
Merged

adds type stubs for python imports#556
dpaiton merged 6 commits intomainfrom
dylan/get-max-wrapper

Conversation

@dpaiton
Copy link
Copy Markdown
Contributor

@dpaiton dpaiton commented Aug 15, 2023

The primary goals of this PR are

  1. to resolve a pylint error when running from hyperdrive_math_py import HyperdriveState
  2. to enable Python type hints for the HyperdriveState object.

To achieve this, I had to change the install pattern from using maturin to the lower-level setuptools-rust. This allows us to specify types & interface stubs so that pylint & pyright can parse type hints. While Maturin technically claims to support this behavior as well, Matt and I were unable to get it to work with the automatic maturin develop install process.

The new directory structure follows the recommended example from pyo3, which looks like this:

crates/hyperdrive-math-py/
├── Cargo.toml
├── MANIFEST.in
├── pyproject.toml
├── python
│   └── hyperdrive_math_py
│       ├── __init__.py
│       ├── hyperdrive_math_py.pyi
│       └── types.py
├── setup.py
└── src
    └── lib.rs

Most notably is the new python folder, which holds type hints, and the setup.py file, which specifies how setuptools is supposed to install the package via pip.

The README.md file has been updated to reflect the install process, which is simply to enter your preferred python environment and run pip install crates/hyperdrive-math-py from the project root.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Aug 15, 2023

Hyperdrive Gas Benchmark

Benchmark suite Current: 391be0b Previous: 91163bc Deviation Status
addLiquidity: min 807 gas 807 gas 0% 🟰
addLiquidity: avg 43878 gas 44021 gas -0.3248%
addLiquidity: max 80591 gas 80591 gas 0% 🟰
checkpoint: min 514 gas 514 gas 0% 🟰
checkpoint: avg 23181 gas 23181 gas 0% 🟰
checkpoint: max 34040 gas 34040 gas 0% 🟰
closeLong: min 852 gas 852 gas 0% 🟰
closeLong: avg 45872 gas 45871 gas 0.0022% 🚨
closeLong: max 85951 gas 85951 gas 0% 🟰
closeShort: min 809 gas 809 gas 0% 🟰
closeShort: avg 42140 gas 42251 gas -0.2627%
closeShort: max 87386 gas 87386 gas 0% 🟰
initialize: min 714 gas 714 gas 0% 🟰
initialize: avg 159447 gas 159447 gas 0% 🟰
initialize: max 233486 gas 233486 gas 0% 🟰
openLong: min 740 gas 740 gas 0% 🟰
openLong: avg 113381 gas 113783 gas -0.3533%
openLong: max 179317 gas 179317 gas 0% 🟰
openShort: min 804 gas 804 gas 0% 🟰
openShort: avg 150773 gas 150351 gas 0.2807% 🚨
openShort: max 219084 gas 219084 gas 0% 🟰
removeLiquidity: min 784 gas 784 gas 0% 🟰
removeLiquidity: avg 57194 gas 57394 gas -0.3485%
removeLiquidity: max 119628 gas 119628 gas 0% 🟰

This comment was automatically generated by workflow using github-action-benchmark.

@dpaiton dpaiton force-pushed the dylan/get-max-wrapper branch from 36235e5 to 7a88347 Compare August 15, 2023 00:47
@dpaiton dpaiton force-pushed the dylan/get-max-wrapper branch 2 times, most recently from 59a677a to f932c9e Compare August 15, 2023 01:50
@coveralls
Copy link
Copy Markdown
Collaborator

coveralls commented Aug 15, 2023

Coverage Status

coverage: 98.524%. remained the same when pulling 391be0b on dylan/get-max-wrapper into 91163bc on main.

@dpaiton dpaiton force-pushed the dylan/get-max-wrapper branch 2 times, most recently from 9451fee to d632225 Compare August 15, 2023 02:19
@dpaiton dpaiton force-pushed the dylan/get-max-wrapper branch 2 times, most recently from 3a389da to 5994778 Compare August 15, 2023 02:51
@dpaiton dpaiton requested a review from sentilesdal August 15, 2023 02:51
@dpaiton dpaiton force-pushed the dylan/get-max-wrapper branch from 5994778 to 391be0b Compare August 15, 2023 02:57
Copy link
Copy Markdown
Contributor

@sentilesdal sentilesdal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good!

Comment thread crates/hyperdrive-math-py/python/hyperdrive_math_py/__init__.py
Comment thread README.md
@dpaiton dpaiton merged commit fe876b7 into main Aug 15, 2023
@dpaiton dpaiton deleted the dylan/get-max-wrapper branch August 15, 2023 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants