From 94a85a8b043e6fe2d3bfa77a460598927962a0ac Mon Sep 17 00:00:00 2001 From: terminaldweller Date: Wed, 6 Jul 2022 11:17:48 +0430 Subject: fixed a couple of the issues raised by codacy --- cargo/cargo.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'cargo') diff --git a/cargo/cargo.py b/cargo/cargo.py index 821e235..a5144dd 100755 --- a/cargo/cargo.py +++ b/cargo/cargo.py @@ -1,12 +1,13 @@ #!/usr/bin/env python3 import http.server -import huggingface_hub as hh -import socketserver import os +import socketserver +import huggingface_hub as hh # https://huggingface.co/docs/huggingface_hub/how-to-downstream def download(path: str = ".") -> None: + """Download the required models from huggingface.""" bart_pretrained = hh.hf_hub_url( "sshleifer/distilbart-cnn-12-6", filename="config.json" ) @@ -14,11 +15,12 @@ def download(path: str = ".") -> None: def serve() -> None: + """Startup a simple http file server.""" handler = http.server.SimpleHTTPRequestHandler - PORT = os.environ["SERVER_PORT"] + port_number = os.environ["SERVER_PORT"] download(os.environ["SERVER_VAULT"]) - with socketserver.TCPServer(("", int(PORT)), handler) as httpd: + with socketserver.TCPServer(("", int(port_number)), handler) as httpd: httpd.serve_forever() -- cgit v1.2.3