Skip to content

Validators selection - milestone 1#696

Merged
keeganquigley merged 1 commit intow3f:masterfrom
miepsik:master
Feb 3, 2023
Merged

Validators selection - milestone 1#696
keeganquigley merged 1 commit intow3f:masterfrom
miepsik:master

Conversation

@miepsik
Copy link
Copy Markdown
Contributor

@miepsik miepsik commented Jan 17, 2023

Milestone Delivery Checklist

Link to the application pull request: w3f/Grants-Program#1326 < please fill this in with the PR number of your application.

@0xCaso
Copy link
Copy Markdown
Contributor

0xCaso commented Jan 18, 2023

Hi @miepsik, thanks for the delivery! Someone from our team will look at it shortly.

@keeganquigley keeganquigley self-assigned this Jan 20, 2023
@keeganquigley
Copy link
Copy Markdown
Contributor

Hi @miepsik I'm evaluating your delivery.

  • Currently the tests and docker file are failing. Can you please review my notes and perhaps add a guide section for what commands need to be run for the docker file as well as locally?
  • I appreciate the API examples, however we don't typically code as part of the evaluation and so instead we ask that these examples be implemented as unit tests and integration tests, in addition to a Docker container that runs the full backend (rather than just the unit tests). This way we can easily boot up your app and test with Westend or a local substrate node.

Thanks for any improvements you can make!

@miepsik
Copy link
Copy Markdown
Contributor Author

miepsik commented Jan 26, 2023

Hi @keeganquigley thanks for the feedback. I've added requested improvements.

@keeganquigley
Copy link
Copy Markdown
Contributor

keeganquigley commented Jan 31, 2023

@miepsik thanks for the changes.

  • I'm now running the tests from the main dir, but was getting multiple errors about failing to import modules. Turns out I had to manually install Flask, NumPy, pandas, scipy, matplotlib, mhar, torch, and sklearn modules. Is this because I needed to run pip3 install -r requirements.txt first? If so, can you please include this command in the guide?
  • After installing all the modules, manually running the tests still fails with:
python -m unittest discover
..n:  34   mi: 92   me: 0   z: 250
n:  34   mi: 92   me: 0   z: 250
n:  34   mi: 92   me: 0   z: 250
n:  34   mi: 92   me: 0   z: 250
n:  34   mi: 92   me: 0   z: 250
n:  34   mi: 92   me: 0   z: 250
n:  34   mi: 92   me: 0   z: 250
n:  34   mi: 92   me: 0   z: 250
n:  34   mi: 92   me: 0   z: 250
n:  34   mi: 92   me: 0   z: 250
n:  34   mi: 92   me: 0   z: 250
n:  34   mi: 92   me: 0   z: 250
domination
n:  34   mi: 92   me: 0   z: 250
n:  34   mi: 92   me: 0   z: 250
n:  34   mi: 92   me: 0   z: 250
n:  34   mi: 92   me: 0   z: 250
n:  34   mi: 92   me: 0   z: 250
n:  34   mi: 92   me: 0   z: 250
n:  34   mi: 92   me: 0   z: 250
n:  34   mi: 92   me: 0   z: 250
domination
n:  34   mi: 92   me: 0   z: 250
n:  34   mi: 92   me: 0   z: 250
n:  34   mi: 92   me: 0   z: 250
n:  34   mi: 92   me: 0   z: 250
n:  34   mi: 92   me: 0   z: 250
n:  34   mi: 92   me: 0   z: 250
n:  34   mi: 92   me: 0   z: 250
n:  34   mi: 92   me: 0   z: 250
n:  34   mi: 92   me: 0   z: 250
n:  34   mi: 92   me: 0   z: 250
n:  34   mi: 92   me: 0   z: 250
n:  34   mi: 92   me: 0   z: 250
n:  34   mi: 92   me: 0   z: 250
n:  34   mi: 92   me: 0   z: 250
n:  34   mi: 92   me: 0   z: 250
n:  34   mi: 92   me: 0   z: 250
(array([5.0000000e+00, 1.9209000e+03, 2.1677018e+06, 9.2000000e+02,
       1.0000000e+00, 7.0300000e+02]), array([1.500000e+00, 3.801300e+03, 2.167745e+06, 8.600000e+02,
       1.000000e+00, 1.166000e+03]))
.E
======================================================================
ERROR: tests.test_ValidatorSelection (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: tests.test_ValidatorSelection
Traceback (most recent call last):
  File "/usr/lib/python3.8/unittest/loader.py", line 436, in _find_test_path
    module = self._get_module_from_name(name)
  File "/usr/lib/python3.8/unittest/loader.py", line 377, in _get_module_from_name
    __import__(name)
  File "/home/keegan/validators_selection/tests/test_ValidatorSelection.py", line 2, in <module>
    import polkadot
  File "/home/keegan/validators_selection/src/polkadot.py", line 12, in <module>
    from sklearn.preprocessing import StandardScaler
ModuleNotFoundError: No module named 'sklearn'


----------------------------------------------------------------------
Ran 4 tests in 4.885s

FAILED (errors=1)

I don't understand why though because I already installed sklearn:

pip install sklearn
Collecting sklearn
  Downloading sklearn-0.0.post1.tar.gz (3.6 kB)
Building wheels for collected packages: sklearn
  Building wheel for sklearn (setup.py) ... done
  Created wheel for sklearn: filename=sklearn-0.0.post1-py3-none-any.whl size=2342 sha256=5cd6146cdaeed8a7ac64d33c06690d10e7481ec80212aafb2c7627536f353f26
  Stored in directory: /home/keegan/.cache/pip/wheels/14/25/f7/1cc0956978ae479e75140219088deb7a36f60459df242b1a72
Successfully built sklearn
Installing collected packages: sklearn
Successfully installed sklearn-0.0.post1
  • The Dockerfile builds successfully now and the tests seem to pass. Again, I'm not sure what commands I should be using here but running the container results in this:
docker run dc2b3dd84423
 * Serving Flask app 'polkadot' (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
 * Running on all addresses (0.0.0.0)
 * Running on http://127.0.0.1:14237
 * Running on http://172.17.0.2:14237
Press CTRL+C to quit

Any idea on the the tests fail manually? Can you please address the comments above? I'm running these on an Ubuntu machine. Thanks!

@keeganquigley
Copy link
Copy Markdown
Contributor

I'm also having trouble testing out the curl commands. When I run this:

curl -X POST -F 'validators=@validators.csv' -F 'depth=2' localhost:14237/fileupload
curl: (7) Failed to connect to localhost port 14237: Connection refused

It fails to connect, even when the Docker container is running. What do I need to do to get it running on my local 14237 port? Can you add some context to the instructions? Thanks!

@miepsik
Copy link
Copy Markdown
Contributor Author

miepsik commented Feb 2, 2023

Hi @keeganquigley , thanks for your feedback
I added description on how to set up an environment for tests. To import sklearn you have to install scikit-learn, it's quite inconsistent. It's already in requirements so as explained in the description and as you mentioned you can just execute pip3 install -r requirements.txt
I also added information on how to run a docer to have this port exposed. Please note the example in the description was not meant as a test and since the algorithm is probabilistic you will very likely obtain different results. There is an integration test implemented to test running docker.
Output from the container looks ok. This milestone is not final so the server is in a development mode which is easier to debug.

@keeganquigley
Copy link
Copy Markdown
Contributor

keeganquigley commented Feb 3, 2023

@miepsik thanks for your help! Everything works as expected now. After installing scikit-learn the unit tests pass and I can successfully run the calls and get the expected responses. I am happy to go ahead and pass this milestone. You can find my final notes here. Looking forward to the next one!

@keeganquigley keeganquigley merged commit 9c6a554 into w3f:master Feb 3, 2023
@keeganquigley
Copy link
Copy Markdown
Contributor

@miepsik I found your invoice but am not seeing a bitcoin address on it. Can you please re-submit an updated invoice including the BTC address that is listed on your application? Also, can you please translate the invoice items into English? This will help make it easier for our operations team. Thank you!

@miepsik
Copy link
Copy Markdown
Contributor Author

miepsik commented Feb 24, 2023

I didn't notice your comment. Fixed invoice was already sent for this and the second milestone

@keeganquigley
Copy link
Copy Markdown
Contributor

@miepsik thank you! I have forwarded your invoice internally for payment.

@RouvenP
Copy link
Copy Markdown

RouvenP commented Mar 6, 2023

hi @miepsik we transferred the payment today.

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.

4 participants