-
Notifications
You must be signed in to change notification settings - Fork 1
Update from task cef5c1dc-60ce-4986-87db-30725a46661f #134
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
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 |
|---|---|---|
| @@ -1,50 +1,116 @@ | ||
| ``` | ||
| # Environment variables | ||
| .env | ||
| .env.local | ||
| .env.* | ||
|
|
||
| # Python specific | ||
| # Python | ||
| __pycache__/ | ||
| *.pyc | ||
| *.pyo | ||
| *.pyd | ||
| .Python | ||
| *.so | ||
| *.egg-info/ | ||
| .eggs/ | ||
|
|
||
| # Dependencies | ||
| .venv/ | ||
| venv/ | ||
| env/ | ||
| ENV/ | ||
| venv/ | ||
| .venv/ | ||
| .venv*/ | ||
| .ENV | ||
| .env.bak | ||
| .env.dev | ||
| .env.development | ||
| .env.prod | ||
| .env.production | ||
| .env.staging | ||
| .env.test | ||
| .env.testing | ||
|
|
||
| # Build artifacts | ||
| build/ | ||
| # Testing | ||
| .coverage | ||
| coverage/ | ||
| htmlcov/ | ||
| .nyc_output/ | ||
| .pytest_cache/ | ||
| .tox/ | ||
| .cover/ | ||
|
|
||
| # Distribution / packaging | ||
| dist/ | ||
| build/ | ||
| *.egg | ||
| *.egg-info/ | ||
| .eggs/ | ||
| pip-log.txt | ||
| pip-delete-this-directory.txt | ||
|
|
||
| # Logs | ||
| *.log | ||
|
|
||
| # OS generated files | ||
| .DS_Store | ||
| Thumbs.db | ||
|
|
||
| # Editor files | ||
| # IDE | ||
| .vscode/ | ||
| .idea/ | ||
| *.swp | ||
| *.swo | ||
|
|
||
| # OS | ||
| .DS_Store | ||
| Thumbs.db | ||
|
|
||
| # Logs | ||
| *.log | ||
|
|
||
| # Environment | ||
| .env | ||
| .env.local | ||
| *.env.* | ||
|
|
||
| # Temp files | ||
| *.tmp | ||
| *.temp | ||
|
|
||
| # Coverage reports | ||
| .coverage | ||
| htmlcov/ | ||
| coverage/ | ||
| # Coverage | ||
| coverage.xml | ||
| *.gcda | ||
| *.gcno | ||
|
|
||
| # Testing | ||
| .pytest_cache/ | ||
| # Compiled | ||
| *.so | ||
| *.dylib | ||
| *.dll | ||
| *.exe | ||
| *.out | ||
|
|
||
| # Compressed | ||
| *.zip | ||
| *.gz | ||
| *.tar | ||
| *.tgz | ||
| *.bz2 | ||
| *.xz | ||
| *.7z | ||
| *.rar | ||
| *.zst | ||
| *.lz4 | ||
| *.lzh | ||
| *.cab | ||
| *.arj | ||
| *.rpm | ||
| *.deb | ||
| *.Z | ||
| *.lz | ||
| *.lzo | ||
| *.tar.gz | ||
| *.tar.bz2 | ||
| *.tar.xz | ||
| *.tar.zst | ||
|
|
||
| # Gradle | ||
| .gradle/ | ||
| build/ | ||
|
|
||
| # MyPy | ||
| .mypy_cache/ | ||
|
|
||
| # Node | ||
| node_modules/ | ||
| npm-debug.log* | ||
| yarn-debug.log* | ||
| yarn-error.log* | ||
|
|
||
| # Jupyter | ||
| .ipynb_checkpoints/ | ||
|
|
||
| # Docker | ||
| .dockerenv | ||
| ``` |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -243,7 +243,7 @@ async def upload_chunk( | |||||||||||||||||||||||||||||
| form = await request.form() | ||||||||||||||||||||||||||||||
| chunk_index_val = form.get("chunk_index") | ||||||||||||||||||||||||||||||
| else: | ||||||||||||||||||||||||||||||
| chunk_index_val = data.get("chunk_index") | ||||||||||||||||||||||||||||||
| chunk_index_val = data.get("chunk_index") if data else None | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| if chunk_index_val is None: | ||||||||||||||||||||||||||||||
| raise HTTPException(400, "Missing chunk_index") | ||||||||||||||||||||||||||||||
|
|
@@ -257,7 +257,7 @@ async def upload_chunk( | |||||||||||||||||||||||||||||
| form = await request.form() | ||||||||||||||||||||||||||||||
| chunk_hash_val = form.get("chunk_hash") | ||||||||||||||||||||||||||||||
| else: | ||||||||||||||||||||||||||||||
| chunk_hash_val = data.get("chunk_hash") | ||||||||||||||||||||||||||||||
| chunk_hash_val = data.get("chunk_hash") if data else None | ||||||||||||||||||||||||||||||
|
Comment on lines
259
to
+260
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. Similar to the
Suggested change
|
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| if not chunk_hash_val: | ||||||||||||||||||||||||||||||
| raise HTTPException(400, "Missing chunk_hash for integrity verification") | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -173,31 +173,30 @@ async def StreamUploadProgress( | |||||
| # Check if upload is complete | ||||||
| chunks_received = session.get('chunks_received', 0) | ||||||
|
|
||||||
| if True: | ||||||
| total_size = session['total_size'] | ||||||
| chunk_size = session.get('chunk_size', 1024 * 1024) | ||||||
| total_chunks = session.get('total_chunks', 1) | ||||||
|
|
||||||
| bytes_transferred = chunks_received * chunk_size | ||||||
| percent_complete = (chunks_received / total_chunks) * 100 | ||||||
|
|
||||||
| # Estimate transfer rate and ETA | ||||||
| elapsed = time.time() - session['started_at'] | ||||||
| transfer_rate = (bytes_transferred / elapsed / 1_000_000) if elapsed > 0 else 0 | ||||||
| remaining_bytes = total_size - bytes_transferred | ||||||
| eta_seconds = (remaining_bytes / transfer_rate / 1_000_000) if transfer_rate > 0 else 0 | ||||||
|
|
||||||
| yield wire_pb2.UploadProgressStream( # type: ignore[attr-defined] | ||||||
| session_id=session_id, | ||||||
| percent_complete=percent_complete, | ||||||
| bytes_transferred=bytes_transferred, | ||||||
| bytes_total=total_size, | ||||||
| transfer_rate_mbps=transfer_rate, | ||||||
| eta_seconds=int(eta_seconds) | ||||||
| ) | ||||||
|
|
||||||
| if chunks_received >= total_chunks: | ||||||
| break | ||||||
| total_size = session['total_size'] | ||||||
| chunk_size = session.get('chunk_size', 1024 * 1024) | ||||||
| total_chunks = session.get('total_chunks', 1) | ||||||
|
|
||||||
| bytes_transferred = chunks_received * chunk_size | ||||||
| percent_complete = (chunks_received / total_chunks) * 100 | ||||||
|
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. If
Suggested change
|
||||||
|
|
||||||
| # Estimate transfer rate and ETA | ||||||
| elapsed = time.time() - session['started_at'] | ||||||
| transfer_rate = (bytes_transferred / elapsed / 1_000_000) if elapsed > 0 else 0 | ||||||
| remaining_bytes = total_size - bytes_transferred | ||||||
| eta_seconds = (remaining_bytes / transfer_rate / 1_000_000) if transfer_rate > 0 else 0 | ||||||
|
|
||||||
| yield wire_pb2.UploadProgressStream( # type: ignore[attr-defined] | ||||||
| session_id=session_id, | ||||||
| percent_complete=percent_complete, | ||||||
| bytes_transferred=bytes_transferred, | ||||||
| bytes_total=total_size, | ||||||
| transfer_rate_mbps=transfer_rate, | ||||||
| eta_seconds=int(eta_seconds) | ||||||
| ) | ||||||
|
|
||||||
| if chunks_received >= total_chunks: | ||||||
| break | ||||||
|
|
||||||
| await asyncio.sleep(0.5) | ||||||
|
|
||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -77,7 +77,8 @@ def explain_blame(file: str, line_start: int, line_end: int, | |||||
| cwd: str, api_key: str, model: str) -> str: | ||||||
| blame = _git(f"git log --oneline {file}", cwd) | ||||||
| try: | ||||||
| code = "\n".join(open(f"{cwd}/{file}").readlines()[line_start-1:line_end]) | ||||||
| with open(f"{cwd}/{file}") as f: | ||||||
| code = "\n".join(f.readlines()[line_start-1:line_end]) | ||||||
|
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. The lines returned by
Suggested change
|
||||||
| except Exception: | ||||||
| code = "(could not read file)" | ||||||
| return _call(api_key, model, | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -132,9 +132,7 @@ def fake_urlopen(req, timeout=None): | |||||
| import urllib.error | ||||||
| body = json.dumps({"error": {"type": "permission_error", | ||||||
| "message": "Missing required scopes."}}).encode() | ||||||
| raise urllib.error.HTTPError(req.full_url, 403, "forbidden", {}, None).__class__( | ||||||
| req.full_url, 403, "forbidden", {}, None | ||||||
| ) if False else _http_error(req.full_url, 403, body) | ||||||
| return _http_error(req.full_url, 403, body) | ||||||
|
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. In the mock
Suggested change
|
||||||
|
|
||||||
| def _http_error(url, code, body): | ||||||
| import io | ||||||
|
|
||||||
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.
If
session_id_valis provided in the request headers, thedatavariable is never initialized. Ifx-chunk-indexis also missing from the headers, accessingdatahere will raise anUnboundLocalError. To prevent this, we should safely handle the potentially unbounddatavariable and fall back to reading and parsing the request body if necessary.