-
Notifications
You must be signed in to change notification settings - Fork 98
Add AssetStatusBar reporter, use in data asset-wait cli command #865
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
Changes from all commits
2a01f84
35274f2
ed0be25
04d33fa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -110,3 +110,48 @@ def update(self, | |
|
||
if self.bar is not None: | ||
self.bar.refresh() | ||
|
||
|
||
class AssetStatusBar(ProgressBar): | ||
"""Bar reporter of asset status.""" | ||
|
||
def __init__( | ||
self, | ||
item_type, | ||
item_id, | ||
asset_type, | ||
disable: bool = False, | ||
): | ||
"""Initialize the object. | ||
""" | ||
self.item_type = item_type | ||
self.item_id = item_id | ||
self.asset_type = asset_type | ||
self.status = '' | ||
super().__init__(disable=disable) | ||
|
||
def open_bar(self): | ||
"""Initialize and start the progress bar.""" | ||
self.bar = tqdm( | ||
bar_format="{elapsed} - {desc} - {postfix[0]}: {postfix[1]}", | ||
desc=self.desc, | ||
postfix=["status", self.status], | ||
disable=self.disable) | ||
|
||
@property | ||
def desc(self): | ||
return f'{self.item_type} {self.item_id} {self.asset_type}' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. EDIT: This is a bug which is resolved when pulling in the most recent changes from your base branch. The bug stems from Is the bar supposed to read When I run it on my computer I get this:
|
||
|
||
def update(self, status: str): | ||
self.status = status | ||
|
||
if self.bar is not None: | ||
try: | ||
self.bar.postfix[1] = self.status | ||
except AttributeError: | ||
# If the bar is disabled, attempting to access self.bar.postfix | ||
# will result in an error. In this case, just skip it. | ||
pass | ||
|
||
if self.bar is not None: | ||
self.bar.refresh() |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -1051,7 +1051,7 @@ def test_asset_wait(invoke, | |||||
runner=runner) | ||||||
|
||||||
assert not result.exception | ||||||
assert "state: active" in result.output | ||||||
assert "status: active" in result.output | ||||||
|
||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would check to see if all things you want to report end up in your reporting bar. Maybe something like this? This currently fails on my laptop, since
Suggested change
|
||||||
|
||||||
# @respx.mock | ||||||
|
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.
Might be worth doing this: