-
Notifications
You must be signed in to change notification settings - Fork 211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Standardize linting and formatting #980
Standardize linting and formatting #980
Conversation
Signed-off-by: Shah, Karan <[email protected]>
Signed-off-by: Shah, Karan <[email protected]>
Signed-off-by: Shah, Karan <[email protected]>
Signed-off-by: Shah, Karan <[email protected]>
Signed-off-by: Shah, Karan <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @MasterSkepticista. Looks like there's just a couple remaining lint issues before approval. Will the namex
changes be included in a future PR?
Yes, this PR is for non-breaking formatting changes. |
Signed-off-by: Shah, Karan <[email protected]>
@psfoley Added relevant ignores in Could not get rid of |
Signed-off-by: Shah, Karan <[email protected]>
from .federated_runtime import FederatedRuntime | ||
|
||
from .local_runtime import LocalRuntime | ||
from .runtime import Runtime |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing the import order is leading to this circular import error (confirmed this by changing the order manually locally on develop, which is passing). This should either be reverted or fixed: https://github.com/securefederatedai/openfl/actions/runs/9381169993/job/25829824994?pr=980#step:5:19
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since __init__.py
files are useful for API exports, until we transition to API export decorators, we need to:
- Export classes using absolute paths:
# Before (order-sensitive, fails)
from .federated_runtime import FederatedRuntime
from .local_runtime import LocalRuntime
from .runtime import Runtime
__all__ = ["FederatedRuntime", "LocalRuntime", "Runtime"]
# After (order-agnostic)
from openfl.experimental.runtime.federated_runtime import FederatedRuntime
from openfl.experimental.runtime.local_runtime import LocalRuntime
from openfl.experimental.runtime.runtime import Runtime
- Use absolute imports in source code:
# Before (order sensitive, fails)
from openfl.experimental.runtime import Runtime
# After (order-agnostic)
from openfl.experimental.runtime.runtime import Runtime
This gives the intended behavior: users can access imported objects without long paths in user code, and order of imports within source code does not lead to errors.
This fix will be used for all subsequent tests.
Signed-off-by: Shah, Karan <[email protected]>
Signed-off-by: Shah, Karan <[email protected]>
Signed-off-by: Shah, Karan <[email protected]>
Fixed imports in the entire |
* [openfl.experimental] Sort imports Signed-off-by: Shah, Karan <[email protected]> * [openfl.experimental] Format using flake8 Signed-off-by: Shah, Karan <[email protected]> * [openfl.experimental] Sort imports in black profile Signed-off-by: Shah, Karan <[email protected]> * [openfl.experimental] Format using black and lint with flake8 Signed-off-by: Shah, Karan <[email protected]> * [openfl.experimental] Add scripts for lint and format Signed-off-by: Shah, Karan <[email protected]> * Update flake8 ignores Signed-off-by: Shah, Karan <[email protected]> * Update contribution guidelines Signed-off-by: Shah, Karan <[email protected]> * Ignore flake8 unused import warnings in __init__.py Signed-off-by: Shah, Karan <[email protected]> * Fix circular import using absolute imports Signed-off-by: Shah, Karan <[email protected]> * [openfl.experimental] Use absolute imports Signed-off-by: Shah, Karan <[email protected]> --------- Signed-off-by: Shah, Karan <[email protected]>
Note: This PR only impacts
openfl.experimental
namespace, and should be a non-breaking change.Changes:
isort
black
flake8
Configuration for
isort
andblack
is included inpyproject.toml
.flake8
continues to usesetup.cfg
For future development:
./shell/lint.sh
./shell/format.sh