Skip to content
Snippets Groups Projects
Commit 35e5aff8 authored by fima's avatar fima :beers:
Browse files

Merge branch 'gradio_fix_unused_file_issue' into 'main'

Added event trigger for removing output file in working directory

See merge request !41
parents 2e94eb52 2d5eded9
No related branches found
No related tags found
1 merge request!41Added event trigger for removing output file in working directory
......@@ -170,7 +170,9 @@ class Interface:
fn=operations.save_mask,
inputs=output_masks,
outputs=[save_output, save_output],
)
).success(
fn=lambda: os.remove('mask.tif')
) # Remove mask file from working directory immediately after sending it to /tmp/gradio
# Update 'Add mask' button interactivit according to the current count
counts.change(
......
......@@ -187,6 +187,11 @@ class Interface:
return fig, "iso3d.html"
def remove_unused_file(self):
# Remove localthickness.tif file from working directory
# as it otherwise is not deleted
os.remove("iso3d.html")
def create_interface(self):
# Create gradio app
......@@ -367,6 +372,7 @@ class Interface:
# fmt: off
btn_run.click(
fn=self.process, inputs=inputs, outputs=outputs).success(
fn=self.remove_unused_file).success(
fn=self.make_visible, inputs=None, outputs=plot_download)
# fmt: on
......
......@@ -90,7 +90,6 @@ class Interface:
quiet=quiet,
height=self.height,
width=self.width,
show_tips=False,
)
return
......@@ -272,6 +271,7 @@ class Interface:
fn=pipeline.output_viz, inputs=session, outputs=output_vol).success(
fn=pipeline.thickness_histogram, inputs=session, outputs=histogram).success(
fn=pipeline.save_lt, inputs=session, outputs=lt_output).success(
fn=pipeline.remove_unused_file).success(
fn=self.make_visible, inputs=None, outputs=lt_output)
......@@ -421,6 +421,11 @@ class Pipeline:
return filename
def remove_unused_file(self):
# Remove localthickness.tif file from working directory
# as it otherwise is not deleted
os.remove('localthickness.tif')
def run_interface(host = "0.0.0.0"):
gradio_interface = Interface().create_interface()
internal_tools.run_gradio_app(gradio_interface,host)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment