Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change statefulCompute/statelessCompute that access runDir #6290

Closed
robnagler opened this issue Sep 8, 2023 · 0 comments
Closed

Change statefulCompute/statelessCompute that access runDir #6290

robnagler opened this issue Sep 8, 2023 · 0 comments
Assignees
Milestone

Comments

@robnagler
Copy link
Member

Code like this should not be written:

def stateless_compute_read_epics_values(data, **kwargs):
    _PREV_EPICS_FILE = "prev-status.json"
    # TODO(pjm): hacked in animation directory
    run_dir = pkio.py_path(
        re.sub(r"/unused$", "/animation", str(simulation_db.simulation_run_dir(data)))
    )
    p = run_dir.join(_PREV_EPICS_FILE)

This is an analysisJob, not a statelessCompute.

BTW, globals (_PREV_EPICS_FILE) should be defined globally (with global), but in this case, it can be local to make the code clearer:

    run_dir.join("prev-status.json")

Also,

    shutil.copyfile(str(e), str(p))

This is not necessary. The reason we chose py.path is that it solves this problem for us:

    e.copy(p)

And this should be encapsulated in pkio:

        and e.exists()
        and p.exists()
        and filecmp.cmp(str(e), str(p), False)

See #6289 for why.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants