mirror of
https://github.com/wassname/optuna-dashboard.git
synced 2026-09-10 12:23:22 +08:00
Make another file including broken lines
This commit is contained in:
@@ -87,12 +87,13 @@ if __name__ == "__main__":
|
||||
]:
|
||||
create_optuna_storage(storage)
|
||||
|
||||
# Add a broken line to the random position in the journal.log to test error handling
|
||||
# Make a file including a broken line to the random position to test error handling
|
||||
shutil.copyfile(os.path.join(BASE_DIR, "journal.log"), os.path.join(BASE_DIR, "journal-broken.log"))
|
||||
broken_line = (
|
||||
'{"op_code": ..., "worker_id": "0000", "study_id": 0,'
|
||||
'"datetime_start": "2024-04-01T12:00:00.000000"}\n'
|
||||
)
|
||||
with open(os.path.join(BASE_DIR, "journal.log"), "r+") as f:
|
||||
with open(os.path.join(BASE_DIR, "journal-broken.log"), "r+") as f:
|
||||
lines = f.readlines()
|
||||
lines.insert(random.randint(0, len(lines)), broken_line)
|
||||
f.truncate(0)
|
||||
|
||||
@@ -15,7 +15,6 @@ describe("Test Journal File Storage", async () => {
|
||||
const studies = await Promise.all(
|
||||
studySummaries.map((_summary, index) => storage.getStudy(index))
|
||||
)
|
||||
const errors = storage.getErrors()
|
||||
|
||||
it("Check the study including Infinities", () => {
|
||||
const study = studies.find((s) => s.study_name === "single-inf")
|
||||
@@ -38,7 +37,14 @@ describe("Test Journal File Storage", async () => {
|
||||
}
|
||||
})
|
||||
|
||||
it("Check the parsing errors", () => {
|
||||
it("Check the parsing errors", async () => {
|
||||
const blob = await openAsBlob(
|
||||
path.resolve(".", "test", "asset", "journal-broken.log")
|
||||
)
|
||||
const buf = await blob.arrayBuffer()
|
||||
const storage = new mut.JournalFileStorage(buf)
|
||||
const errors = storage.getErrors()
|
||||
|
||||
assert.strictEqual(errors.length, 1)
|
||||
assert.strictEqual(
|
||||
errors[0].message,
|
||||
|
||||
Reference in New Issue
Block a user