| 
36 | 36 |     parse_cli_vars,  | 
37 | 37 | )  | 
38 | 38 | from ..ctl.validate import app as validate_app  | 
39 |  | -from ..exceptions import GraphQLError, InfrahubTransformNotFoundError  | 
 | 39 | +from ..exceptions import GraphQLError, ModuleImportError  | 
40 | 40 | from ..jinja2 import identify_faulty_jinja_code  | 
41 | 41 | from ..schema import (  | 
42 | 42 |     InfrahubRepositoryConfig,  | 
43 | 43 |     MainSchemaTypes,  | 
44 | 44 |     SchemaRoot,  | 
45 | 45 | )  | 
46 |  | -from ..transforms import get_transform_class_instance  | 
47 | 46 | from ..utils import get_branch, write_to_file  | 
48 | 47 | from ..yaml import SchemaFile  | 
49 | 48 | from .exporter import dump  | 
@@ -338,16 +337,17 @@ def transform(  | 
338 | 337 |     client = initialize_client()  | 
339 | 338 | 
 
  | 
340 | 339 |     # Get python transform class instance  | 
 | 340 | + | 
 | 341 | +    relative_path = str(transform_config.file_path.parent) if transform_config.file_path.parent != Path() else None  | 
 | 342 | + | 
341 | 343 |     try:  | 
342 |  | -        transform = get_transform_class_instance(  | 
343 |  | -            transform_config=transform_config,  | 
344 |  | -            branch=branch,  | 
345 |  | -            client=client,  | 
346 |  | -        )  | 
347 |  | -    except InfrahubTransformNotFoundError as exc:  | 
348 |  | -        console.print(f"Unable to load {transform_name} from python_transforms")  | 
 | 344 | +        transform_class = transform_config.load_class(import_root=str(Path.cwd()), relative_path=relative_path)  | 
 | 345 | +    except ModuleImportError as exc:  | 
 | 346 | +        console.print(f"[red]{exc.message}")  | 
349 | 347 |         raise typer.Exit(1) from exc  | 
350 | 348 | 
 
  | 
 | 349 | +    transform = transform_class(client=client, branch=branch)  | 
 | 350 | + | 
351 | 351 |     # Get data  | 
352 | 352 |     query_str = repository_config.get_query(name=transform.query).load_query()  | 
353 | 353 |     data = asyncio.run(  | 
 | 
0 commit comments