openeo-python-client icon indicating copy to clipboard operation
openeo-python-client copied to clipboard

autogenerated job description

Open soxofaan opened this issue 2 years ago • 2 comments

Feature idea from @EmileSonneveld : have a way to automatically generate a job description with some desired metadata (current git commit, used python source code, ...).

e.g. very rough concept:

job = cube.create_job(
    ...
    description=auto_description(src=__file__, git_commit=True)
)

soxofaan avatar Sep 19 '23 14:09 soxofaan

At the moment I have this snippet where I launch jobs:

try:
    from git import Repo
    repo = Repo(os.path.dirname(__file__), search_parent_directories=True)
    job_description += "GIT URL: " + list(repo.remotes[0].urls)[0] + "\n\n"
    job_description += "GIT branch: '" + repo.active_branch.name + "' commit: '" + repo.active_branch.commit.hexsha + "'\n\n"
    job_description += "GIT changed files: " + ", ".join(map(lambda f: f.a_path, repo.index.diff(None))) + "\n"
except Exception as e:
    print("Could not attach GIT info: " + str(e))

If this would be implemented in the openeo-client, the path of the calling code can be found with parent_filename = inspect.stack()[1].filename

EmileSonneveld avatar Sep 20 '23 08:09 EmileSonneveld

Nice idea! This can help quite a bit in finding jobs again, maybe the same goes for job title? As default implementation, for title, we could just use the name of the file that starts the job? Adding calling function would be even better, if available.

Note that I would go for a solution that does not introduce dependencies, or does not depend on git. That could however be another auxiliary function?

jdries avatar Dec 20 '23 08:12 jdries