1616import logging
1717import os
1818import sys
19- import tempfile
2019
2120import safetensors
2221
22+ from diffusers .utils .testing_utils import TemporaryDirectory
23+
2324
2425sys .path .append (".." )
2526from test_examples_utils import ExamplesTestsAccelerate , run_command # noqa: E402
@@ -39,7 +40,7 @@ class DreamBoothLoRAFluxAdvanced(ExamplesTestsAccelerate):
3940 script_path = "examples/advanced_diffusion_training/train_dreambooth_lora_flux_advanced.py"
4041
4142 def test_dreambooth_lora_flux (self ):
42- with tempfile . TemporaryDirectory (ignore_cleanup_errors = True ) as tmpdir :
43+ with TemporaryDirectory (ignore_cleanup_errors = True ) as tmpdir :
4344 test_args = f"""
4445 { self .script_path }
4546 --pretrained_model_name_or_path { self .pretrained_model_name_or_path }
@@ -71,7 +72,7 @@ def test_dreambooth_lora_flux(self):
7172 self .assertTrue (starts_with_transformer )
7273
7374 def test_dreambooth_lora_text_encoder_flux (self ):
74- with tempfile . TemporaryDirectory (ignore_cleanup_errors = True ) as tmpdir :
75+ with TemporaryDirectory (ignore_cleanup_errors = True ) as tmpdir :
7576 test_args = f"""
7677 { self .script_path }
7778 --pretrained_model_name_or_path { self .pretrained_model_name_or_path }
@@ -104,7 +105,7 @@ def test_dreambooth_lora_text_encoder_flux(self):
104105 self .assertTrue (starts_with_expected_prefix )
105106
106107 def test_dreambooth_lora_pivotal_tuning_flux_clip (self ):
107- with tempfile . TemporaryDirectory (ignore_cleanup_errors = True ) as tmpdir :
108+ with TemporaryDirectory (ignore_cleanup_errors = True ) as tmpdir :
108109 test_args = f"""
109110 { self .script_path }
110111 --pretrained_model_name_or_path { self .pretrained_model_name_or_path }
@@ -146,7 +147,7 @@ def test_dreambooth_lora_pivotal_tuning_flux_clip(self):
146147 self .assertTrue (starts_with_transformer )
147148
148149 def test_dreambooth_lora_pivotal_tuning_flux_clip_t5 (self ):
149- with tempfile . TemporaryDirectory (ignore_cleanup_errors = True ) as tmpdir :
150+ with TemporaryDirectory (ignore_cleanup_errors = True ) as tmpdir :
150151 test_args = f"""
151152 { self .script_path }
152153 --pretrained_model_name_or_path { self .pretrained_model_name_or_path }
@@ -189,7 +190,7 @@ def test_dreambooth_lora_pivotal_tuning_flux_clip_t5(self):
189190 self .assertTrue (starts_with_transformer )
190191
191192 def test_dreambooth_lora_latent_caching (self ):
192- with tempfile . TemporaryDirectory (ignore_cleanup_errors = True ) as tmpdir :
193+ with TemporaryDirectory (ignore_cleanup_errors = True ) as tmpdir :
193194 test_args = f"""
194195 { self .script_path }
195196 --pretrained_model_name_or_path { self .pretrained_model_name_or_path }
@@ -222,7 +223,7 @@ def test_dreambooth_lora_latent_caching(self):
222223 self .assertTrue (starts_with_transformer )
223224
224225 def test_dreambooth_lora_flux_checkpointing_checkpoints_total_limit (self ):
225- with tempfile . TemporaryDirectory (ignore_cleanup_errors = True ) as tmpdir :
226+ with TemporaryDirectory (ignore_cleanup_errors = True ) as tmpdir :
226227 test_args = f"""
227228 { self .script_path }
228229 --pretrained_model_name_or_path={ self .pretrained_model_name_or_path }
@@ -245,7 +246,7 @@ def test_dreambooth_lora_flux_checkpointing_checkpoints_total_limit(self):
245246 )
246247
247248 def test_dreambooth_lora_flux_checkpointing_checkpoints_total_limit_removes_multiple_checkpoints (self ):
248- with tempfile . TemporaryDirectory (ignore_cleanup_errors = True ) as tmpdir :
249+ with TemporaryDirectory (ignore_cleanup_errors = True ) as tmpdir :
249250 test_args = f"""
250251 { self .script_path }
251252 --pretrained_model_name_or_path={ self .pretrained_model_name_or_path }
0 commit comments