Skip to content

Commit

Permalink
fix(code-style): running pre-commit against code base
Browse files Browse the repository at this point in the history
  • Loading branch information
nutrina committed Dec 12, 2022
1 parent e0dd875 commit d4b335d
Show file tree
Hide file tree
Showing 35 changed files with 57 additions and 64 deletions.
18 changes: 9 additions & 9 deletions MVP Passport Scoring Analysis/code.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ clean_stamps$class <- factor(clean_stamps$class)
###
### Logistic Regression Model
###
my_glm <- glm(class ~ ., data = clean_stamps %>%
filter(!is.na(class)) %>%
my_glm <- glm(class ~ ., data = clean_stamps %>%
filter(!is.na(class)) %>%
select(-handle), family = "binomial")

# Predictions
Expand Down Expand Up @@ -293,7 +293,7 @@ stamps_scoring_methods <- stamps %>%
`Stamps Collected` = stamps_collected,
`Logistic Regression Score` = Logistic, `Regularized Regression Score` = Regularized,
`COF Kish Score` = Kish, `Gitcoin Regen Score` = Regen, Stamps = stamps)

stamps_scoring_methods %>% write_csv("outputs/stamps_scoring_methods.csv")

###
Expand Down Expand Up @@ -336,15 +336,15 @@ model_confusion_matrix <- tibble(
mutate(glm_prediction = ifelse(glm_pred >= .5, "thor", "loki"),
glmnet_cv_prediction = ifelse(glmnet_cv_pred >= .5, "thor", "loki")) %>%
filter(!is.na(class))

table(model_confusion_matrix$glm_prediction, model_confusion_matrix$class)
table(model_confusion_matrix$glmnet_cv_prediction, model_confusion_matrix$class)

## Get a color scale gradient
cc <- scales::seq_gradient_pal("#F3587D", "#27AE60", "Lab")(seq(0,1,length.out=20))

## Pyramid Plot of Coefficients
p61 <- tibble(coef = names(glm_co), s1 = glm_co) %>%
p61 <- tibble(coef = names(glm_co), s1 = glm_co) %>%
filter(!is.na(s1)) %>%
arrange(desc(s1)) %>%
mutate(coef = factor(coef, levels = rev(coef))) %>%
Expand All @@ -365,7 +365,7 @@ p61 <- tibble(coef = names(glm_co), s1 = glm_co) %>%

ggsave(p61, filename = "outputs/pyramid_plot_logistic.png", width = 12, height = 8)

p62 <- tibble(coef = rownames(glmco_cv), s1 = glmco_cv[,1]) %>%
p62 <- tibble(coef = rownames(glmco_cv), s1 = glmco_cv[,1]) %>%
filter(!is.na(s1)) %>%
arrange(desc(s1)) %>%
mutate(coef = factor(coef, levels = rev(coef))) %>%
Expand Down Expand Up @@ -612,7 +612,7 @@ binded_models %>%
### Kish / Regen Deep-Dive
###

p63 <- tibble(coef = forgery$Stamp, s1 = as.numeric(forgery$COF_Kish_Estimates)) %>%
p63 <- tibble(coef = forgery$Stamp, s1 = as.numeric(forgery$COF_Kish_Estimates)) %>%
filter(!is.na(s1)) %>%
arrange(desc(s1)) %>%
mutate(coef = factor(coef, levels = rev(coef))) %>%
Expand All @@ -633,7 +633,7 @@ p63 <- tibble(coef = forgery$Stamp, s1 = as.numeric(forgery$COF_Kish_Estimates))

ggsave(p63, filename = "outputs/pyramid_plot_kish.png", width = 12, height = 8)

p64 <- tibble(coef = forgery$Stamp, s1 = as.numeric(forgery$FDD_Regen_Score_Omni)) %>%
p64 <- tibble(coef = forgery$Stamp, s1 = as.numeric(forgery$FDD_Regen_Score_Omni)) %>%
filter(!is.na(s1)) %>%
arrange(desc(s1)) %>%
mutate(coef = factor(coef, levels = rev(coef))) %>%
Expand Down Expand Up @@ -975,6 +975,6 @@ p113 <- ggplot(data = binded_models %>% arrange(Regen) %>%
ggsave(p113, filename = "outputs/non_sybil_score_regen_allpassports.png", width = 12, height = 8)

## Scatterplot Matrix
p200 <- ggpairs(binded_models %>% ungroup() %>% select(-handle, -class), title="correlogram with ggpairs()")
p200 <- ggpairs(binded_models %>% ungroup() %>% select(-handle, -class), title="correlogram with ggpairs()")

ggsave(p200, filename = "outputs/score_comparison.png", width = 12, height = 8)
6 changes: 3 additions & 3 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Start the dev server:
##Testing
### API

In the `./api` folder run (make sure your local virtual env is activated):
In the `./api` folder run (make sure your local virtual env is activated):
```
coverage run --source='.' manage.py test
```
Expand All @@ -48,7 +48,7 @@ coverage run --source='.' manage.py test

Make sure you install the dev dependencies `pipenv install --dev`.

- **docs**:
- **docs**:
- [pytest-bdd](https://pytest-bdd.readthedocs.io/en/latest/#advanced-code-generation)
- https://automationpanda.com/2018/10/22/python-testing-101-pytest-bdd/
- examples: https://github.com/AndyLPK247/behavior-driven-python
Expand All @@ -63,4 +63,4 @@ Make sure you install the dev dependencies `pipenv install --dev`.

In the `./test`:
- exec cypress tests: `yarn cypress run`
- open cypress: `yarn cypress open`
- open cypress: `yarn cypress open`
3 changes: 2 additions & 1 deletion api/account/admin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.contrib import admin
from .models import Account, Community, AccountAPIKey

from .models import Account, AccountAPIKey, Community


class AccountAdmin(admin.ModelAdmin):
Expand Down
2 changes: 1 addition & 1 deletion api/account/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Generated by Django 4.1.4 on 2022-12-09 09:45

import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):
Expand Down
2 changes: 1 addition & 1 deletion api/account/migrations/0002_alter_community_scorer.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Generated by Django 4.1.4 on 2022-12-09 14:25

import account.models
from django.db import migrations, models
import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):
Expand Down
18 changes: 9 additions & 9 deletions api/account/test/test_account.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
from django.test import TestCase
from django.test import Client

# Create your tests here.

from web3.auto import w3
from web3 import Web3
from eth_account.messages import encode_defunct
import binascii
import json
from copy import deepcopy
from datetime import datetime

from django.test import Client, TestCase
from eth_account.messages import encode_defunct
from siwe import SiweMessage
from copy import deepcopy
from web3 import Web3
from web3.auto import w3

# Create your tests here.


mock_api_key_body = {"name": "test"}
mock_community_body = {"name": "test", "description": "test"}
Expand Down
8 changes: 3 additions & 5 deletions api/account/test/test_api_key.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
from django.test import TestCase
from django.test import Client
from django.contrib.auth.models import User
from ninja_jwt.schema import RefreshToken
import json

from account.models import Account, AccountAPIKey

from django.contrib.auth.models import User
from django.test import Client, TestCase
from ninja_jwt.schema import RefreshToken

mock_api_key_body = {"name": "test"}

Expand Down
3 changes: 2 additions & 1 deletion api/account/urls.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from .views import api
from django.urls import path

from .views import api

urlpatterns = [
path("", api.urls),
]
2 changes: 1 addition & 1 deletion api/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ services:
restart: unless-stopped
ports:
- 5432:5432

environment:
POSTGRES_USER: passport_scorer
POSTGRES_PASSWORD: passport_scorer_pwd
Expand Down
1 change: 0 additions & 1 deletion api/registry/admin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from django.contrib import admin

from registry.models import Passport, Stamp


Expand Down
2 changes: 1 addition & 1 deletion api/registry/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Generated by Django 4.1.4 on 2022-12-09 09:45

from django.db import migrations, models
import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):
Expand Down
2 changes: 1 addition & 1 deletion api/registry/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.db import models
from account.models import Community
from django.db import models


class Passport(models.Model):
Expand Down
1 change: 0 additions & 1 deletion api/registry/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from .models import Passport, Stamp


# class PassportSerializer(serializers.ModelSerializer):
# class Meta:
# model = Passport
Expand Down
3 changes: 2 additions & 1 deletion api/registry/urls.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from .views import api
from django.urls import path

from .views import api

urlpatterns = [
path("", api.urls),
]
2 changes: 1 addition & 1 deletion api/scorer/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
https://docs.djangoproject.com/en/4.1/ref/settings/
"""

import os
from pathlib import Path

import environ
import os

env = environ.Env(
# set casting, default value
Expand Down
3 changes: 1 addition & 2 deletions api/scorer/test/features/submit_passport.feature
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Feature: Submit address for passport
As a user of the passport scoring service
I want to be able to submit eth addresses so I can get back
I want to be able to submit eth addresses so I can get back
the score for the owner of that eth address

# The "@" annotations are tags
Expand All @@ -21,4 +21,3 @@ Feature: Submit address for passport
When I call the submit-passport API for an Ethereum account under that community ID
Then I want to get a score based on the Gitcoin Community Score and deduplication rules (see default deduplication settings here)
And log the score associated with this Passport under the corresponding community ID

1 change: 0 additions & 1 deletion api/scorer_apu/admin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from django.contrib import admin

from scorer_apu.models import ApuScorer, Combo, NumInfo

# Register your models here.
Expand Down
2 changes: 1 addition & 1 deletion api/scorer_apu/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Generated by Django 4.1.4 on 2022-12-09 09:45

from django.db import migrations, models
import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):
Expand Down
1 change: 0 additions & 1 deletion api/scorer_apu/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from django.db import models

from registry.models import Passport


Expand Down
1 change: 0 additions & 1 deletion api/scorer_weighted/admin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from django.contrib import admin

from scorer_weighted.models import WeightedScorer

# Register your models here.
Expand Down
2 changes: 1 addition & 1 deletion api/scorer_weighted/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Generated by Django 4.1.4 on 2022-12-09 09:45

from django.db import migrations, models
import django.db.models.deletion
import scorer_weighted.models
from django.db import migrations, models


class Migration(migrations.Migration):
Expand Down
6 changes: 3 additions & 3 deletions api/scorer_weighted/models.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from django.db import models
from django.conf import settings

from typing import List

from django.conf import settings
from django.db import models


def get_default_parent_scorer_for_weighted():
return Scorer(type=Scorer.Type.WEIGHTED)
Expand Down
1 change: 0 additions & 1 deletion api/scorer_weighted/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

from .models import Score, WeightedScorer


# class WeightedScorerSerializer(serializers.ModelSerializer):
# class Meta:
# model = WeightedScorer
Expand Down
4 changes: 2 additions & 2 deletions infra/review/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ const secgrp = new aws.ec2.SecurityGroup(`scorer-run-migrations-task`, {
export const securityGroupForTaskDefinition = secgrp.id;

//////////////////////////////////////////////////////////////
// Set up EC2 instance
// Set up EC2 instance
// - it is intended to be used for troubleshooting
//////////////////////////////////////////////////////////////

Expand Down Expand Up @@ -413,7 +413,7 @@ apt-get install -y \
curl \
gnupg \
lsb-release
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo \
Expand Down
2 changes: 1 addition & 1 deletion interface/.env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
NEXT_PUBLIC_PASSPORT_SCORER_ALCHEMY_API_KEY=YOUR_API_KEY
NEXT_PUBLIC_PASSPORT_SCORER_BACKEND=http://localhost:8000/
NEXT_PUBLIC_PASSPORT_SCORER_BACKEND=http://localhost:8000/
2 changes: 1 addition & 1 deletion interface/__tests__/components/CommunityCard.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ describe("CommunityCard", () => {
// expect(screen.getByText("banks")).toBeInTheDocument();
// });
});
});
});
4 changes: 2 additions & 2 deletions interface/components/CommunityCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type CommunityCardProps = {
setUpdateCommunityModalOpen: Function;
}

const CommunityCard = ({
const CommunityCard = ({
community,
handleDeleteCommunity,
communityId,
Expand Down Expand Up @@ -58,4 +58,4 @@ const CommunityCard = ({
);
};

export default CommunityCard;
export default CommunityCard;
4 changes: 2 additions & 2 deletions interface/components/CommunityList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const CommunityList = (): JSX.Element => {

const handleUpdateCommunity = async (communityId: Community["id"]) => {
try {
await updateCommunity(communityId,
await updateCommunity(communityId,
{
name: updatedCommunityName,
description: updatedCommunityDescription,
Expand Down Expand Up @@ -86,7 +86,7 @@ const CommunityList = (): JSX.Element => {
}, []);

const communityList = communities.map((community: Community, i: number) => {
return (
return (
<CommunityCard
key={i}
community={community}
Expand Down
2 changes: 1 addition & 1 deletion interface/components/DoneToast.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// --- React components/methods
import React from "react";
import React from "react";
2 changes: 1 addition & 1 deletion interface/prettier.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
tailwindConfig: "./tailwind.config.js",
}
}
4 changes: 2 additions & 2 deletions interface/public/vercel.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion test/cypress/e2e/api_account.feature
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ Feature: API Account (#689)
And I Sign-in-with-Ethereum
Then I will have an account created
And be taken to the config dashboard

Loading

0 comments on commit d4b335d

Please sign in to comment.