Skip to content
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

Return empty state_details for deprecated bundle types. #4229

Merged
merged 6 commits into from
Aug 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions codalab/lib/bundle_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ def get_bundle_state_details(bundle):
type = bundle.get('bundle_type')
state = bundle.get('state')
state_details_by_type = {
'dataset': {
'dataset': { # uploaded
'created': 'Bundle has been created but its contents have not been uploaded yet.',
'uploading': 'Bundle contents are being uploaded.',
'ready': 'Bundle has finished uploading successfully, and is ready to be used for further runs.',
Expand All @@ -399,6 +399,10 @@ def get_bundle_state_details(bundle):
},
}

# We can remove the defensive checks below once program bundles are converted to dataset bundles.
# Related Issue: https://github.com/codalab/codalab-worksheets/issues/4235
state_details = state_details_by_type.get(type, {}).get(state, '')

if state == 'preparing' or state == 'running':
return run_status
return state_details_by_type[type][state]
return state_details
8 changes: 8 additions & 0 deletions tests/unit/lib/bundle_util_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@


class GetBundleStateDetailsTest(unittest.TestCase):
def test_deprecated_bundle(self):
"""
Returns an empty string for deprecated bundle types.
"""
deprecated_bundle = {'bundle_type': 'program', 'state': 'ready'}
state_details = get_bundle_state_details(deprecated_bundle)
self.assertEqual(state_details, '')

def test_running_bundle(self):
"""
Returns `run_status` if state is `running`.
Expand Down