@@ -4532,16 +4532,47 @@ def _get_output_paths(
4532
4532
if isinstance (filename , str ):
4533
4533
filename = Path (filename )
4534
4534
if artifacts_dir is None :
4535
+ abs_filename = filename .resolve ()
4535
4536
# Remove the extension and add '_pictures'
4536
- artifacts_dir = filename .with_suffix ("" )
4537
- artifacts_dir = artifacts_dir .with_name (artifacts_dir .name + "_artifacts" )
4538
- if artifacts_dir .is_absolute ():
4537
+ artifacts_dir = abs_filename .with_name (
4538
+ abs_filename .stem + "_artifacts"
4539
+ )
4540
+ #artifacts_dir = abs_filename.with_suffix("")
4541
+ #artifacts_dir = artifacts_dir.with_name(artifacts_dir.name + "_artifacts")
4542
+ if filename .is_absolute ():
4539
4543
reference_path = None
4540
4544
else :
4541
4545
reference_path = filename .parent
4542
4546
artifacts_dir = reference_path / artifacts_dir
4543
4547
4544
4548
return artifacts_dir , reference_path
4549
+
4550
+ def _get_output_paths (
4551
+ self , filename : Union [str , Path ], artifacts_dir : Optional [Path ] = None
4552
+ ) -> Tuple [Path , Optional [Path ]]:
4553
+ """
4554
+ Determines the output directory for artifacts and the reference path for URIs.
4555
+
4556
+ This function correctly handles absolute and relative paths for `filename`
4557
+ and `artifacts_dir` without path duplication.
4558
+ """
4559
+ if isinstance (filename , str ):
4560
+ filename = Path (filename )
4561
+ if artifacts_dir is None :
4562
+ # Default case: create an '_artifacts' directory alongside the file.
4563
+ final_artifacts_dir = filename .with_name (filename .stem + "_artifacts" )
4564
+ else :
4565
+ if isinstance (artifacts_dir , str ):
4566
+ artifacts_dir = Path (artifacts_dir )
4567
+ if artifacts_dir .is_absolute ():
4568
+ final_artifacts_dir = artifacts_dir
4569
+ else :
4570
+ final_artifacts_dir = filename .parent / artifacts_dir
4571
+ if final_artifacts_dir .is_absolute ():
4572
+ reference_path = None
4573
+ else :
4574
+ reference_path = filename .parent
4575
+ return final_artifacts_dir , reference_path
4545
4576
4546
4577
def _make_copy_with_refmode (
4547
4578
self ,
0 commit comments