1
0
Fork 0

sonar lint fixes

This commit is contained in:
Sean Sube 2023-02-19 22:10:35 -06:00
parent c5eae688e3
commit 40e396a2c4
Signed by: ssube
GPG Key ID: 3EED7B957D362AF1
7 changed files with 17 additions and 17 deletions

View File

@ -35,7 +35,7 @@ def load_resrgan(
return cache_pipe
if not path.isfile(model_path):
raise Exception("Real ESRGAN model not found at %s" % model_path)
raise FileNotFoundError("Real ESRGAN model not found at %s" % model_path)
if params.format == "onnx":
# use ONNX acceleration, if available
@ -66,7 +66,7 @@ def load_resrgan(
scale=params.scale,
)
else:
raise Exception("unknown platform %s" % params.format)
raise ValueError("unknown platform %s" % params.format)
dni_weight = None
if params.upscale_model == TAG_X4_V3 and params.denoise != 1:

View File

@ -52,7 +52,7 @@ def process_tile_spiral(
**kwargs,
) -> Image.Image:
if scale != 1:
raise Exception("unsupported scale")
raise ValueError("unsupported scale")
width, height = source.size
image = Image.new("RGB", (width * scale, height * scale))

View File

@ -30,7 +30,7 @@ def mask_filter_gaussian_multiply(
"""
noise = mask_filter_none(mask, dims, origin)
for i in range(rounds):
for _i in range(rounds):
blur = noise.filter(ImageFilter.GaussianBlur(5))
noise = ImageChops.multiply(noise, blur)
@ -45,7 +45,7 @@ def mask_filter_gaussian_screen(
"""
noise = mask_filter_none(mask, dims, origin)
for i in range(rounds):
for _i in range(rounds):
blur = noise.filter(ImageFilter.GaussianBlur(5))
noise = ImageChops.screen(noise, blur)
@ -88,7 +88,7 @@ def noise_source_gaussian(
noise = noise_source_uniform(source, dims, origin)
noise.paste(source, origin)
for i in range(rounds):
for _i in range(rounds):
noise = noise.filter(ImageFilter.GaussianBlur(5))
return noise

View File

@ -803,8 +803,8 @@ def ready():
done, progress = executor.done(output_file)
if done is None:
file = base_join(context.output_path, output_file)
if path.exists(file):
output = base_join(context.output_path, output_file)
if path.exists(output):
return ready_reply(True)
return ready_reply(done, progress=progress)

View File

@ -44,7 +44,7 @@ class JobContext:
with self.device_index.get_lock():
device_index = self.device_index.value
if device_index < 0:
raise Exception("job has not been assigned to a device")
raise ValueError("job has not been assigned to a device")
else:
device = self.devices[device_index]
logger.debug("job %s assigned to device %s", self.key, device)
@ -57,7 +57,7 @@ class JobContext:
def on_progress(step: int, timestep: int, latents: Any):
on_progress.step = step
if self.is_cancelled():
raise Exception("job has been cancelled")
raise RuntimeError("job has been cancelled")
else:
logger.debug("setting progress for job %s to %s", self.key, step)
self.set_progress(step)

View File

@ -65,7 +65,7 @@ def get_not_empty(args: Any, key: str, default: Any) -> Any:
return val
def get_size(val: Union[int, str, None]) -> SizeChart:
def get_size(val: Union[int, str, None]) -> Union[int, SizeChart]:
if val is None:
return SizeChart.auto
@ -79,7 +79,7 @@ def get_size(val: Union[int, str, None]) -> SizeChart:
return int(val)
raise Exception("invalid size")
raise ValueError("invalid size")
def run_gc(devices: List[DeviceParams] = None):

2
api/scripts/test-memory-leak.sh Normal file → Executable file
View File

@ -6,7 +6,7 @@ do
curl "http://${test_host}:5000/api/txt2img?"\
'cfg=16.00&steps=35&scheduler=deis-multi&seed=-1&'\
'prompt=an+astronaut+eating+a+hamburger&negativePrompt=&'\
'model=stable-diffusion-v1-5&platform=any&'\
'model=stable-diffusion-onnx-v1-5&platform=any&'\
'upscaling=upscaling-real-esrgan-x2-plus&correction=correction-codeformer&'\
'lpw=false&width=512&height=512&upscaleOrder=correction-both' \
-X 'POST' \