Fix #4347: Flag for submissions UI and CLI#365
Conversation
📝 WalkthroughWalkthroughThe PR adds a single flag to track submission origin. The CLI's ChangesCLI submission origin tracking
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@evalai/challenges.py`:
- Line 299: submission_metadata is currently set with
submission_metadata['from_cli'] = True which becomes the string "True" when sent
as form data and mismatches how is_public is serialized; change the assignment
to mirror is_public's JSON-style serialization (e.g.
submission_metadata['from_cli'] = json.dumps(True)) and ensure json is imported
in the module so the backend receives "true"/"false" consistently with
is_public.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
| submission_meta_attributes = get_submission_meta_attributes( | ||
| ctx.challenge_id, ctx.phase_id | ||
| ) | ||
| submission_metadata['from_cli'] = True |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Search the codebase for backend handling of from_cli field
rg -n -C3 --type=py 'from_cli' -g '!evalai/challenges.py'Repository: Cloud-CV/evalai-cli
Length of output: 45
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Show the submit command section and the requests.post call for context
sed -n '230,330p' evalai/challenges.py | nl -ba | sed -n '1,120p'
# Narrowly locate is_public/from_cli assignments and request call
rg -n "is_public|from_cli|requests\.post|submission_metadata\[" evalai/challenges.py -n -C2Repository: Cloud-CV/evalai-cli
Length of output: 106
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "=== evalai/challenges.py lines 230-330 ==="
sed -n '230,330p' evalai/challenges.py | cat -n -w3 -s' ' | sed -n '1,120p'
echo "=== Focused matches in evalai/challenges.py ==="
rg -n --context=2 "requests\.post|is_public|from_cli|submission_metadata" evalai/challenges.pyRepository: Cloud-CV/evalai-cli
Length of output: 190
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "=== evalai/challenges.py lines 230-330 (with cat -n) ==="
sed -n '230,330p' evalai/challenges.py | cat -n
echo "=== Focused matches in evalai/challenges.py (with context) ==="
rg -n -C3 "requests\.post|is_public|from_cli|submission_metadata" evalai/challenges.pyRepository: Cloud-CV/evalai-cli
Length of output: 7686
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Find where helpers are defined
rg -n "def make_submission|def upload_file_using_presigned_url|make_submission\(|upload_file_using_presigned_url\(" evalai/challenges.py
# Show relevant sections around those function definitions
# (use sed ranges based on discovered line numbers)
rg -n "def make_submission" evalai/challenges.py | head -n 5
rg -n "def upload_file_using_presigned_url" evalai/challenges.py | head -n 5Repository: Cloud-CV/evalai-cli
Length of output: 235
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Find function definitions across repo
rg -n "def make_submission" -S .
rg -n "def upload_file_using_presigned_url" -S .
# Also look for where make_submission is imported/used
rg -n "make_submission\(" -S evalai | head -n 50
rg -n "upload_file_using_presigned_url\(" -S evalai | head -n 50Repository: Cloud-CV/evalai-cli
Length of output: 656
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "=== evalai/utils/submissions.py: make_submission ==="
sed -n '1,220p' evalai/utils/submissions.py | cat -n | sed -n '40,140p'
echo "=== evalai/utils/common.py: upload_file_using_presigned_url ==="
sed -n '1,260p' evalai/utils/common.py | cat -n | sed -n '130,240p'
echo "=== requests.post usage in these files ==="
rg -n "requests\.post" evalai/utils/submissions.py evalai/utils/common.pyRepository: Cloud-CV/evalai-cli
Length of output: 9241
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "=== evalai/utils/submissions.py (around make_submission) ==="
rg -n "def make_submission" evalai/utils/submissions.py
start=$(rg -n "def make_submission" evalai/utils/submissions.py | head -n1 | cut -d: -f1)
# Print a reasonable window around the function
sed -n "$((start-20)),$((start+120))p" evalai/utils/submissions.py
echo "=== evalai/utils/common.py (around upload_file_using_presigned_url) ==="
rg -n "def upload_file_using_presigned_url" evalai/utils/common.py
start2=$(rg -n "def upload_file_using_presigned_url" evalai/utils/common.py | head -n1 | cut -d: -f1)
sed -n "$((start2-20)),$((start2+160))p" evalai/utils/common.py
echo "=== requests.post calls in those files ==="
rg -n "requests\.post|post\(" evalai/utils/submissions.py evalai/utils/common.pyRepository: Cloud-CV/evalai-cli
Length of output: 10761
Fix from_cli boolean serialization to match is_public
evalai/challenges.py:299setssubmission_metadata['from_cli'] = True, but both submission flows sendsubmission_metadataas form data (requests.post(..., data=...)), so the backend receives"True"; meanwhileis_publicis sent as JSON-stringified"true"/"false", creating an inconsistency that can break backend parsing.
🔧 Proposed fix
- submission_metadata['from_cli'] = True
+ submission_metadata['from_cli'] = json.dumps(True)📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| submission_metadata['from_cli'] = True | |
| submission_metadata['from_cli'] = json.dumps(True) |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@evalai/challenges.py` at line 299, submission_metadata is currently set with
submission_metadata['from_cli'] = True which becomes the string "True" when sent
as form data and mismatches how is_public is serialized; change the assignment
to mirror is_public's JSON-style serialization (e.g.
submission_metadata['from_cli'] = json.dumps(True)) and ensure json is imported
in the module so the backend receives "true"/"false" consistently with
is_public.
This PR follows up on the previous one: Cloud-CV/EvalAI#4349
Summary by CodeRabbit