asdf-format / asdf

ASDF (Advanced Scientific Data Format) is a next generation interchange format for scientific data

Home Page:http://asdf.readthedocs.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`AsdfFile` instances are not pickleable

braingram opened this issue · comments

Description of the problem

AsdfFile instances are not pickleable.

Example of the problem

import asdf, pickle

af = asdf.AsdfFile({'a': 1})
pickle.dumps(af)

Fails with

AttributeError: Can't pickle local object 'ValidatorManager._get_jsonschema_validator.<locals>._validator'

System information

asdf version: main
python version: 3.10
operating system: mac os (m1)

To provide a bit more context. The lack of "pickle-ability" means AsdfFile instances do not play well with multiprocessing:

def get_a(af):
    return af['a']

with multiprocessing.Pool(4):
    pool.map(get_a, [af])

Fails with the above error.