-
Notifications
You must be signed in to change notification settings - Fork 319
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
Look at the full collection of Exchange classes #1761
Open
shreve
wants to merge
4
commits into
jupyter:main
Choose a base branch
from
shreve:fix-configurable-class-list
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
eb8b274
Look at the correct collection of Exchange classes
shreve d98324c
Rename abc.Exchange to abc.ABCExchange for clarity
shreve 4c51c81
Deprecate accessing Exchange classes directly from nbgrader.exchange
shreve fcbe7ea
Add docstrings to exchange classes for better help text
shreve File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,21 +1,28 @@ | ||
|
||
from nbgrader.exchange.abc import (Exchange, ExchangeError, ExchangeCollect, ExchangeFetch, ExchangeFetchAssignment, | ||
ExchangeFetchFeedback, ExchangeList, ExchangeReleaseAssignment, ExchangeRelease, | ||
ExchangeReleaseFeedback, ExchangeSubmit, ExchangeReleaseFeedback) | ||
import warnings | ||
from nbgrader.exchange.abc import ExchangeError | ||
from nbgrader.exchange import abc, default | ||
from .exchange_factory import ExchangeFactory | ||
|
||
def __getattr__(name): | ||
if name in abc.__all__: | ||
warnings.warn( | ||
f"Importing {name} from nbgrader.exchange is deprecated." | ||
" Import from nbgrader.exchange.abc or the specific " | ||
" exchange implementation instead.".format(name), | ||
DeprecationWarning, | ||
stacklevel=2 | ||
) | ||
|
||
if hasattr(abc, name): | ||
return getattr(abc, name) | ||
elif hasattr(default, name): | ||
return getattr(default, name) | ||
|
||
raise AttributeError(f"module {__name__!r} has no attribute {name!r}") | ||
|
||
__all__ = [ | ||
"Exchange", | ||
"ExchangeError", | ||
"ExchangeCollect", | ||
"ExchangeFetch", | ||
"ExchangeFetchAssignment", | ||
"ExchangeFetchFeedback", | ||
"ExchangeList", | ||
"ExchangeRelease", | ||
"ExchangeReleaseAssignment", | ||
"ExchangeReleaseFeedback", | ||
"ExchangeSubmit", | ||
"abc", | ||
"default", | ||
"ExchangeFactory", | ||
"default" | ||
"ExchangeError", | ||
] |
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
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,15 +1,15 @@ | ||
import warnings | ||
|
||
from .fetch_assignment import ExchangeFetchAssignment | ||
from .fetch_assignment import ABCExchangeFetchAssignment | ||
|
||
|
||
class ExchangeFetch(ExchangeFetchAssignment): | ||
class ABCExchangeFetch(ABCExchangeFetchAssignment): | ||
|
||
def __init__(self, *args, **kwargs): | ||
super(ExchangeFetch, self).__init__(*args, **kwargs) | ||
super(ABCExchangeFetch, self).__init__(*args, **kwargs) | ||
msg = ( | ||
"The ExchangeFetch class is now deprecated, please use " | ||
"ExchangeFetchAssignment instead. This class will be removed in a " | ||
"The ABCExchangeFetch class is now deprecated, please use " | ||
"ABCExchangeFetchAssignment instead. This class will be removed in a " | ||
"future version of nbgrader.") | ||
warnings.warn(msg, DeprecationWarning) | ||
self.log.warning(msg) |
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,8 +1,8 @@ | ||
from traitlets import Bool | ||
|
||
from .exchange import Exchange | ||
from .exchange import ABCExchange | ||
|
||
|
||
class ExchangeFetchAssignment(Exchange): | ||
class ABCExchangeFetchAssignment(ABCExchange): | ||
|
||
replace_missing_files = Bool(False, help="Whether to replace missing files on fetch").tag(config=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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
from .exchange import Exchange | ||
from .exchange import ABCExchange | ||
|
||
|
||
class ExchangeFetchFeedback(Exchange): | ||
class ABCExchangeFetchFeedback(ABCExchange): | ||
pass |
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,15 +1,15 @@ | ||
import warnings | ||
|
||
from .release_assignment import ExchangeReleaseAssignment | ||
from .release_assignment import ABCExchangeReleaseAssignment | ||
|
||
|
||
class ExchangeRelease(ExchangeReleaseAssignment): | ||
class ABCExchangeRelease(ABCExchangeReleaseAssignment): | ||
|
||
def __init__(self, *args, **kwargs): | ||
super(ExchangeRelease, self).__init__(*args, **kwargs) | ||
super(ABCExchangeRelease, self).__init__(*args, **kwargs) | ||
msg = ( | ||
"The ExchangeRelease class is now deprecated, please use " | ||
"ExchangeReleaseAssignment instead. This class will be removed in " | ||
"The ABCExchangeRelease class is now deprecated, please use " | ||
"ABCExchangeReleaseAssignment instead. This class will be removed in " | ||
"a future version of nbgrader.") | ||
warnings.warn(msg, DeprecationWarning) | ||
self.log.warning(msg) |
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,8 +1,8 @@ | ||
from traitlets import Bool | ||
|
||
from .exchange import Exchange | ||
from .exchange import ABCExchange | ||
|
||
|
||
class ExchangeReleaseAssignment(Exchange): | ||
class ABCExchangeReleaseAssignment(ABCExchange): | ||
|
||
force = Bool(False, help="Force overwrite existing files in the exchange.").tag(config=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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
from .exchange import Exchange | ||
from .exchange import ABCExchange | ||
|
||
|
||
class ExchangeReleaseFeedback(Exchange): | ||
class ABCExchangeReleaseFeedback(ABCExchange): | ||
pass |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Do you think we need to catch all the
default
classes traits if they are similar to theabc
ones ?Since exchange is the only default class with dedicated traits, maybe it can be specified when calling the
_collect_configurables
function.This should avoid duplication for most of the exchange classes, but I'm not sure it will not break anything about the functionalities, I don't know well traitlets.
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.
After digging into this more, I think the duplication is just the nature of the beast. I have a new proposal to make the distinction more clear, which is to actually rename the
abc
classes.When they're used in the nbgrader codebase, we already do
from exchange.abc import Exchange as ABCExchange
, and if you search GitHub, so does everyone else: https://github.com/search?q=from+nbgrader.exchange+import+&type=codeBy renaming the actual class, we can get rid of these import aliases without touching the implementation, and create distinction in the generated config file.