Skip to content

Commit

Permalink
FileWrite: rename builddir to output_dir
Browse files Browse the repository at this point in the history
  • Loading branch information
awnawab committed Nov 4, 2024
1 parent 9b6e88d commit f6b3c18
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
6 changes: 3 additions & 3 deletions loki/batch/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class Scheduler:
By default a full parse is executed, use this flag to suppress.
frontend : :any:`Frontend`, optional
Frontend to use for full parse of source files (default :any:`FP`).
builddir : str or path
output_dir : str or path
Directory for the output to be written to
"""

Expand All @@ -129,7 +129,7 @@ class Scheduler:

def __init__(self, paths, config=None, seed_routines=None, preprocess=False,
includes=None, defines=None, definitions=None, xmods=None,
omni_includes=None, full_parse=True, frontend=FP, builddir=None):
omni_includes=None, full_parse=True, frontend=FP, output_dir=None):
# Derive config from file or dict
if isinstance(config, SchedulerConfig):
self.config = config
Expand All @@ -156,7 +156,7 @@ def __init__(self, paths, config=None, seed_routines=None, preprocess=False,
'xmods': xmods,
'omni_includes': omni_includes,
'frontend': frontend,
'builddir': builddir
'output_dir': output_dir
}

# Internal data structures to store the callgraph
Expand Down
6 changes: 3 additions & 3 deletions loki/batch/tests/test_transformation.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ def test_transformation_file_write(tmp_path):
ricks_path = tmp_path/'rick.loki.F90'
if ricks_path.exists():
ricks_path.unlink()
FileWriteTransformation().apply(source=source, item=item, build_args={'builddir': tmp_path})
FileWriteTransformation().apply(source=source, item=item, build_args={'output_dir': tmp_path})
assert ricks_path.exists()
ricks_path.unlink()

Expand All @@ -429,15 +429,15 @@ def test_transformation_file_write(tmp_path):
if ricks_path.exists():
ricks_path.unlink()
FileWriteTransformation(mode='roll', suffix='.java').apply(source=source, item=item,
build_args={'builddir': tmp_path})
build_args={'output_dir': tmp_path})
assert ricks_path.exists()
ricks_path.unlink()

# Test writing with "items" only (as in file graph traversal)
ricks_path = tmp_path/'rick.loki.F90'
if ricks_path.exists():
ricks_path.unlink()
FileWriteTransformation().apply(source=source, items=(item,), build_args={'builddir': tmp_path})
FileWriteTransformation().apply(source=source, items=(item,), build_args={'output_dir': tmp_path})
assert ricks_path.exists()
ricks_path.unlink()

Expand Down
5 changes: 3 additions & 2 deletions loki/transformations/build_system/file_write.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def transform_file(self, sourcefile, **kwargs):
path = Path(item.path)
suffix = self.suffix if self.suffix else path.suffix
sourcepath = Path(item.path).with_suffix(f'.{self.mode}{suffix}')
if (builddir := kwargs.get('build_args', {}).get('builddir', None)) is not None:
sourcepath = Path(builddir)/sourcepath.name
build_args = kwargs.get('build_args', {})
if build_args and (output_dir := build_args.get('output_dir', None)) is not None:
sourcepath = Path(output_dir)/sourcepath.name
sourcefile.write(path=sourcepath, cuf=self.cuf)
2 changes: 1 addition & 1 deletion scripts/loki_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def convert(
paths = [Path(p).resolve() for p in as_tuple(source)]
paths += [Path(h).resolve().parent for h in as_tuple(header)]
scheduler = Scheduler(
paths=paths, config=config, frontend=frontend, definitions=definitions, builddir=build, **build_args
paths=paths, config=config, frontend=frontend, definitions=definitions, output_dir=build, **build_args
)

# If requested, apply a custom pipeline from the scheduler config
Expand Down

0 comments on commit f6b3c18

Please sign in to comment.