-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Formatting and sorting imports in Python files (#394)
- Loading branch information
Marco Capuccini
authored
May 31, 2022
1 parent
4b53136
commit 34b10a4
Showing
55 changed files
with
919 additions
and
626 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import pymongo | ||
from time import sleep | ||
import sys | ||
from time import sleep | ||
|
||
import pymongo | ||
|
||
N_ROUNDS = 3 | ||
RETRIES= 6 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: "code checks" | ||
|
||
on: push | ||
|
||
jobs: | ||
code-checks: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: init venv | ||
run: .devcontainer/bin/init_venv.sh | ||
|
||
- name: check Python imports | ||
run: > | ||
.venv/bin/isort . --check --diff | ||
--skip .venv | ||
--skip .mnist-keras | ||
--skip .mnist-pytorch | ||
- name: check Python formatting | ||
run: > | ||
.venv/bin/autopep8 --recursive --diff | ||
--exclude .venv | ||
--exclude .mnist-keras | ||
--exclude .mnist-pytorch | ||
. | ||
# TODO: add linting/formatting for all file types |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"editor.formatOnSave": true, | ||
"editor.codeActionsOnSave": { | ||
"source.organizeImports": true | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ | |
# | ||
import os | ||
import sys | ||
|
||
sys.path.insert(0, os.path.abspath('../../fedn')) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,21 @@ | ||
#!./.mnist-keras/bin/python | ||
import os | ||
|
||
import fire | ||
import tensorflow as tf | ||
import numpy as np | ||
import os | ||
import tensorflow as tf | ||
|
||
|
||
def get_data(out_dir='data'): | ||
# Make dir if necessary | ||
if not os.path.exists(out_dir): | ||
os.mkdir(out_dir) | ||
|
||
# Download data | ||
(x_train, y_train), (x_test, y_test) = tf.keras.datasets.mnist.load_data() | ||
np.savez(f'{out_dir}/mnist.npz', x_train=x_train, y_train=y_train, x_test=x_test, y_test=y_test) | ||
np.savez(f'{out_dir}/mnist.npz', x_train=x_train, | ||
y_train=y_train, x_test=x_test, y_test=y_test) | ||
|
||
|
||
if __name__ == '__main__': | ||
fire.Fire(get_data) | ||
fire.Fire(get_data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,22 @@ | ||
#!./.mnist-pytorch/bin/python | ||
import os | ||
|
||
import fire | ||
import torchvision | ||
import numpy as np | ||
import os | ||
import torchvision | ||
|
||
|
||
def get_data(out_dir='data'): | ||
# Make dir if necessary | ||
if not os.path.exists(out_dir): | ||
os.mkdir(out_dir) | ||
|
||
# Download data | ||
torchvision.datasets.MNIST(root=f'{out_dir}/train', transform=torchvision.transforms.ToTensor, train=True, download=True) | ||
torchvision.datasets.MNIST(root=f'{out_dir}/test', transform=torchvision.transforms.ToTensor, train=False, download=True) | ||
torchvision.datasets.MNIST( | ||
root=f'{out_dir}/train', transform=torchvision.transforms.ToTensor, train=True, download=True) | ||
torchvision.datasets.MNIST( | ||
root=f'{out_dir}/test', transform=torchvision.transforms.ToTensor, train=False, download=True) | ||
|
||
|
||
if __name__ == '__main__': | ||
fire.Fire(get_data) | ||
fire.Fire(get_data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.