-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
runner constructor #1238
runner constructor #1238
Conversation
import in |
Codecov Report
@@ Coverage Diff @@
## master #1238 +/- ##
==========================================
+ Coverage 68.23% 68.26% +0.03%
==========================================
Files 160 161 +1
Lines 10721 10739 +18
Branches 1969 1971 +2
==========================================
+ Hits 7315 7331 +16
- Misses 3022 3023 +1
- Partials 384 385 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
Hi @densechen , |
Hi, @ZwwWayne , if a |
Got it. Thanks for your contribution. And could you provide an example to show how to use the |
Currently, if we want to do something with runner provided by mmcv, we need such piece of code: from mmcv.runner.builder import RUNNERS, build_runner
from openfed.common.gluer import glue
from typing import Any
from .builder import build_openfed
def openfed_runner(model,
batch_processor=None,
optimizer=None,
work_dir=None,
logger=None,
meta=None,
max_iters=None,
max_epochs=None,
runner_cfg=None):
# Build Runner
runner = build_runner(
runner_cfg,
default_args=dict(
model=model,
batch_processor=batch_processor,
optimizer=optimizer,
work_dir=work_dir,
logger=logger,
meta=meta,
max_iters=max_iters,
max_epochs=max_epochs,
)
)
# DO SOMETHING HERE
runner.openfed_name = 'XXX'
return runner
@RUNNERS.register_module(name='OpenFedRunner')
class OpenFedRunner(object):
def __init__(self, *args, **kwargs):
super().__init__()
self.openfed_runner = openfed_runner(*args, **kwargs)
def __getattribute__(self, name: str) -> Any:
if name == 'openfed_runner':
return super().__getattribute__(name)
return getattr(self.openfed_runner, name)
def __setattr__(self, name: str, value: Any) -> None:
if name == 'openfed_runner':
return super().__setattr__(name, value)
return setattr(self.openfed_runner, name, value) This code is quite ugly. |
got it |
hi, please fix the CI |
fix yapf |
you can refer to https://github.com/open-mmlab/mmcv/blob/master/CONTRIBUTING.md |
fix yapf |
Waiting for merging |
hi @densechen , thanks for your contribution again. Before merging, An unittest should be added (refer to https://github.com/open-mmlab/mmcv/blob/master/tests/test_runner/test_optimizer.py). In addition, maybe we can enhance the docstring of DefaultRunnerConstructor like |
Overall, this PR looks good to me. We need to resolve conflict before the merge. |
Hi, @zhouzaida Can we have a further discussion via WeChat? My Email is densechen@foxmail.com |
Great, I send an email to you |
This PR can be merged after resolving linting issues and conflicts. |
Using Examples: Inject some new properties and functions for existing 1. Define a new
|
|
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.
LGTM
re-commit |
I am so sorry to force push to your master branch |
recommit |
Thanks |
Add
RunnerConstructor
feature to build_runner.It will not effect the original code feature, but just an enhancement.
Refer here for more details: issue1225