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

get_extract_by_id() always returns default values for camelCase extract fields #99

Closed
robe2037 opened this issue Oct 10, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@robe2037
Copy link
Collaborator

The MicrodataExtract() class expects arguments in snake case. However, because get_extract_info() returns the extract definition using the API's camel case conventions, the following lines in get_extract_by_id() end up passing all camel case arguments to **kwargs instead of the appropriate snake case arguments in MicrodataExtract().

extract_def = self.get_extract_info(extract_id, collection)
if "microdata" in BaseExtract._collection_type_to_extract:
    extract = MicrodataExtract(**extract_def["extractDefinition"])

For instance, an extract with a non-default data_structure will be reverted to a rectangular-on-P data structure because its value after get_extract_info() is stored in the dataStructure field of the response. Here's a reproducible example:

from ipumspy import *
import os

client = IpumsApiClient(os.environ.get("IPUMS_API_KEY"))

ext1 = MicrodataExtract(
    "usa",
    ["us2017a"],
    ["AGE"],
    data_structure = {"hierarchical": {}}
)

client.submit_extract(ext1)

ext2 = client.get_extract_by_id(ext1.extract_id, "usa")

print(ext1.data_structure) # {"hierarchical": {}}
print(ext2.data_structure) # {"rectangular": {"on": "P"}}
@robe2037 robe2037 added the bug Something isn't working label Oct 10, 2024
@robe2037
Copy link
Collaborator Author

We should be able to resolve this simply by using extract_from_dict() to convert from the dictionary to an extract object. extract_from_dict() already handles case conversion.

@robe2037 robe2037 self-assigned this Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant