AgnostiqHQ / covalent

Pythonic tool for orchestrating machine-learning/high performance/quantum-computing workflows in heterogeneous compute environments.
https://www.covalent.xyz
Apache License 2.0
770 stars 91 forks source link

Provide a clean way for users to add metadata to `Electron` and/or `Lattice` objects once imported #1683

Open Andrew-S-Rosen opened 1 year ago

Andrew-S-Rosen commented 1 year ago

What should we add?

If there's not already, there should be a clean way in Covalent to add user-defined metadata to an Electron (or Lattice) after it's been imported. Ideally, this would be metadata they would retrieve when they call ct.get_result(<dispatch ID>) or view the UI as well.

For example, let's say I have a Python library of Electron objects that the user can import and use. If the user wants to run 1000s of lattices with these electrons, they might want to add metadata to some of them so they can keep track of which campaign they were for.

I could do something like:

#mypackage
import covalent as ct

@ct.electron
def add(val1,val2):
    return val1+val2

with the user then being informed to do

from mypackage import add

add.electron_object.metadata["tag"] = "TrialRun"

But I'm not thinking that's the best route because we shouldn't be touching the Covalent-specified metadata...

Describe alternatives you've considered.

No response

Note

I'm not sure if this is the same as #1569 because there's no associated comment.

janosh commented 1 year ago

@arosen93 Are you looking for sth similar to wandb's run config? If so, that could be a source of inspiration.

Andrew-S-Rosen commented 1 year ago

I was actually inspired by the job.metadata option in Jobflow and the corresponding update_metadata function! Will check out the WandB example too!

Edit: Looks like the WandB example is slightly different. I'm looking to set metadata that does not impact the job at all but is useful for querying the results when deposited in a database.

janosh commented 1 year ago

wandb config is like that too. It is stored with the job but by default has no bearing on the job execution. That's for the user to implement if desired. This is what it looks like in the wandb UI. You can query by it.

Screenshot 2023-06-02 at 15 45 29

Andrew-S-Rosen commented 1 year ago

Ah, I see now! Very useful. Thanks! Lots of inspiration to go by.

santoshkumarradha commented 1 year ago

just grooming on this one a bit more, @Andrew-S-Rosen would you prefer it at electron level or lattice level or dispatches?

Andrew-S-Rosen commented 1 year ago

@santoshkumarradha: That's a good question. When you ask about lattice vs. dispatch, are you referring to setting metadata via the Lattice object itself vs. some optional arguments passed to ct.dispatch? The latter might be quite convenient for users.

Anyway, I suppose metadata at any level would be useful, but perhaps the most important would be at the full workflow (lattice) level.