Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: cutecutecat <junyuchen@tensorchord.ai>
  • Loading branch information
cutecutecat committed Oct 10, 2023
1 parent 1126b06 commit e72a4e7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ build:
@pdm build

build-local: build
@pip uninstall -y modelz-py
@pip install -e .

lint:
Expand All @@ -32,13 +31,20 @@ docs-dev: docs
# when swagger goreleaser asset is ready

# Only maintainers of ModelZ could run this command!
# These files are generated:
# - openapi/swagger.json
openapi-sync:
@git clone --depth=1 git@github.com:tensorchord/modelz.git --branch ${MODELZ_VERSION} tmp
@cp tmp/apiserver/pkg/docs/swagger.json openapi/swagger.json
@rm -rf tmp

# TODO(junyuchen): Move to generated v3.0 OpenAPI doc when swag supports it
# https://github.com/swaggo/swag/issues/386 and remove convert and pre-fix

# These files are generated:
# - openapi/swagger_v3.json
# - openapi/swagger_fix.json
# - openapi/sdk/*
generate:
@curl -X 'POST' https://converter.swagger.io/api/convert \
-H 'Content-Type: application/json' \
Expand Down
10 changes: 6 additions & 4 deletions modelz/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ def print(self, msg: str):


def jsonFormattedPrint(resp: Response):
try:
if hasattr(resp.parsed, "to_dict") and callable(resp.parsed.to_dict):
formatted = json.dumps(resp.parsed.to_dict(), indent=2)
except Exception:
formatted = resp.content.decode()
finally:
console.print(formatted)
elif resp.parsed is None:
formatted = "OK"
else:
formatted = resp.content.decode(errors="ignore")
console.print(formatted)

0 comments on commit e72a4e7

Please sign in to comment.