ESMCI / ESMCI/cime

_do_data_assimilation passing basename, which has the extension

Open
#4,930 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
174
Forks
225
Avg merge
1d 16h
Merged PRs (30d)
14

Description

In _do_data_assimilation `os.path.basename(da_script)` is passed as the subname to run_or_cmd

https://github.com/ESMCI/cime/blob/87d67c201247b1b91677f114f32fa8c0a6f52b18/CIME/case/case_run.py#L422-L436

If your da_script has an extension, e.g assimilate.py the run_or_cmd function ends up looking for `def assimlate.py` in the file rather than `def assimilate`

I think `os.path.splitext(os.path.basename(filepath))[0]` lets you have a script.py (or script with no extension) and still find the `def script` in the file.

```
>>> filepath='/users/hkershaw/assimilate.py'
>>> os.path.basename(filepath)
'assimilate.py'
>>> os.path.splitext(os.path.basename(filepath))[0]
'assimilate'
```

I'm not sure if there is a CIME convention to not have extensions (e.g. .py) on scripts that could be imported.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.