Fix json.decoder.JSONDecodeError when load pipeline_schema.json (#859)

When we use `modelscope server` to serve the model, the comma after last json object in this file will cause the error bellow:

```log
ERROR:    Traceback (most recent call last):
  File "/opt/conda/lib/python3.10/site-packages/starlette/routing.py", line 732, in lifespan
    async with self.lifespan_context(app) as maybe_state:
  File "/opt/conda/lib/python3.10/site-packages/starlette/routing.py", line 608, in __aenter__
    await self._router.startup()
  File "/opt/conda/lib/python3.10/site-packages/starlette/routing.py", line 711, in startup
    handler()
  File "/opt/conda/lib/python3.10/site-packages/modelscope/server/core/event_handlers.py", line 37, in startup
    _startup_model(app)
  File "/opt/conda/lib/python3.10/site-packages/modelscope/server/core/event_handlers.py", line 22, in _startup_model
    info['schema'] = get_task_schemas(app.state.pipeline.group_key)
  File "/opt/conda/lib/python3.10/site-packages/modelscope/utils/input_output.py", line 837, in get_task_schemas
    schema = json.load(f)
  File "/opt/conda/lib/python3.10/json/__init__.py", line 293, in load
    return loads(fp.read(),
  File "/opt/conda/lib/python3.10/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/opt/conda/lib/python3.10/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/opt/conda/lib/python3.10/json/decoder.py", line 353, in raw_decode
    obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 3836 column 1 (char 100720)
```
This commit is contained in:
Alpha Hinex
2024-05-24 11:39:37 +08:00
committed by GitHub
parent 82ee20f447
commit da985ad92d

View File

@@ -3832,5 +3832,5 @@
}
}
}
},
}
}