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

NameError: name 'ujson' is not defined #170

Closed
najiya-12 opened this issue Jun 6, 2022 · 7 comments
Closed

NameError: name 'ujson' is not defined #170

najiya-12 opened this issue Jun 6, 2022 · 7 comments

Comments

@najiya-12
Copy link

najiya-12 commented Jun 6, 2022

I listed the files from S3
urls = ['s3://' + f for f in fs.glob("s3://noaa-goes16/ABI-L2-ACMC/2022/116/*/*.nc")]
given around
len(urls)
272 files
and then generated the jsons files and created in the ./jsons/ directory, however, I run into an issue with gen_json() function
NameError: name 'ujson' is not defined. I followed @lsterzinger tutorial in
(https://medium.com/pangeo/fake-it-until-you-make-it-reading-goes-netcdf4-data-on-aws-s3-as-zarr-for-rapid-data-access-61e33f8fe685)

@peterm790
Copy link
Collaborator

Try installing and importing the ujson package: https://pypi.org/project/ujson/ . I believe it is functionally the same as the normal json encoder just a bit faster

@keewis
Copy link
Contributor

keewis commented Jun 6, 2022

I think this is a bug in the blog post: it was updated to use json instead of ujson, but it seems like that particular instance was forgotten.

@martindurant
Copy link
Member

Yep, originally we just ran with stock builtin JSON, but as reference files got bigger, we decided to switch to ujson. If installing kerchunk doesn't grab this, then we need to add it to the deps.

@lsterzinger
Copy link
Collaborator

Thanks for catching this typo @najiya-12 - I corrected the import to import ujson at the beginning of the tutorial. As @martindurant said, it should be installed alongside Kerchunk since it's listed in the dependencies

@najiya-12
Copy link
Author

najiya-12 commented Jun 6, 2022

Thanks for catching this typo @najiya-12 - I corrected the import to import ujson at the beginning of the tutorial. As @martindurant said, it should be installed alongside Kerchunk since it's listed in the dependencies

Thank you! It worked

@keewis
Copy link
Contributor

keewis commented Jun 6, 2022

there's still a typo:

m_list = []
for js in tqdm(json_list):
    with open(js) as f:
        m_list.append(fsspec.get_mapper("reference://", 
            fo=json.load(f), remote_protocol="s3",
            remote_options={"anon": True}))

json.loadujson.load

@lsterzinger
Copy link
Collaborator

Good catch, thanks!

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

5 participants