Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
沈秋雨
/
weknora_ragas
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
56b1b00a
...
56b1b00afbc2f4e98da064db9ef815d808dc0cfc
authored
2026-04-21 16:02:58 +0800
by
沈秋雨
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Improve WeKnora upload error diagnostics
1 parent
854ed21c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
6 deletions
scripts/01_upload_docs.py
src/weknora_eval/api.py
scripts/01_upload_docs.py
View file @
56b1b00
...
...
@@ -6,7 +6,7 @@ import _bootstrap # noqa: F401
from
weknora_eval.api
import
client_from_config
from
weknora_eval.config
import
load_config
from
weknora_eval.loaders
import
setup_logging
,
write_jsonl
from
weknora_eval.loaders
import
append_jsonl
,
setup_logging
,
write_jsonl
from
weknora_eval.raw_docs
import
iter_raw_doc_files
...
...
@@ -16,8 +16,22 @@ def main() -> int:
client
=
client_from_config
(
config
)
files
=
iter_raw_doc_files
()
rows
=
[]
failures
=
[]
for
path
in
files
:
data
=
client
.
upload_file
(
path
)
print
(
f
"Uploading {path}..."
)
try
:
data
=
client
.
upload_file
(
path
)
except
Exception
as
exc
:
# noqa: BLE001
failure
=
{
"file_path"
:
str
(
path
),
"file_name"
:
path
.
name
,
"file_type"
:
path
.
suffix
.
lstrip
(
"."
),
"error"
:
str
(
exc
),
}
failures
.
append
(
failure
)
append_jsonl
(
"data/exported/failed_uploads.jsonl"
,
failure
)
print
(
f
"Upload failed for {path}: {exc}"
)
continue
rows
.
append
(
{
"knowledge_id"
:
data
.
get
(
"id"
),
...
...
@@ -28,9 +42,10 @@ def main() -> int:
"raw"
:
data
,
}
)
print
(
f
"Uploaded {path}: knowledge_id={data.get('id')}"
)
write_jsonl
(
"data/exported/knowledge_uploads.jsonl"
,
rows
)
print
(
f
"Uploaded {len(rows)} files"
)
return
0
print
(
f
"Uploaded {len(rows)} files
, failed {len(failures)} files
"
)
return
1
if
failures
else
0
if
__name__
==
"__main__"
:
...
...
src/weknora_eval/api.py
View file @
56b1b00
...
...
@@ -244,10 +244,13 @@ class WeKnoraClient:
continue
if
response
.
status_code
>=
400
:
self
.
_log_error
(
method
,
url
,
response
)
raise
WeKnoraApiError
(
f
"{method} {url} failed with HTTP {response.status_code}"
)
body
=
response
.
text
[:
1000
]
raise
WeKnoraApiError
(
f
"{method} {url} failed with HTTP {response.status_code}: {body}"
)
time
.
sleep
(
self
.
request_interval_seconds
)
return
response
.
json
()
except
(
requests
.
RequestException
,
ValueError
,
WeKnoraApiError
)
as
exc
:
except
(
requests
.
RequestException
,
ValueError
)
as
exc
:
last_error
=
exc
if
attempt
>=
self
.
max_retries
:
break
...
...
Please
register
or
sign in
to post a comment