-
Notifications
You must be signed in to change notification settings - Fork 54
[Bug]: No longer way to obtain charge density from task_id #924
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Code snippet
# given some task id:
task_id = "mp-1805669"
# used to be able to do this
with MPRester(MP_API_KEY, monty_decode=deserialize) as mpr:
results = mpr.materials.search(task_ids=[task_id])
assert len(results) == 1
chgcar = mpr.charge_density.get_charge_density_from_file_id(results[0].fs_id)What happened?
There is currently no way to obtain charge density given some task id. MPRester.charge_density no longer exists, and there is no get_charge_density_from_file_id() function within MPRester.
I noticed there is a TODO related to this as well.
A work around is to use the tasks._query_open_data function manually, though I'm not sure this is robust to future API changes. Although I am not 100% sure this is correct, since I don't think the task_id always matches the file path in the key below.
# given some task id:
task_id = "mp-1805669"
with MPRester(MP_API_KEY) as mpr:
decoder = MontyDecoder().decode
chgcar = (
mpr.tasks._query_open_data(
bucket="materialsproject-parsed",
key=f"chgcars/{str(task_id)}.json.gz",
decoder=decoder,
fields=["data"],
)[0][0]["data"]
or {}
)Version
0.41.2
Which OS?
- MacOS
- Windows
- Linux
Log output
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working