Skip to content

Commit

Permalink
import SerializationContext from asdf.extension for version >3
Browse files Browse the repository at this point in the history
  • Loading branch information
braingram committed Mar 22, 2024
1 parent e3fcbbb commit f9dca49
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
7 changes: 6 additions & 1 deletion weldx/asdf/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
import functools
import re

from asdf.asdf import SerializationContext
import asdf

if asdf.__version__ >= "3.0.0":
from asdf.extension import SerializationContext
else:
from asdf.asdf import SerializationContext
from asdf.extension import Converter
from asdf.versioning import AsdfSpec
from boltons.iterutils import remap
Expand Down
8 changes: 6 additions & 2 deletions weldx/asdf/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@

import asdf
import pint
from asdf.asdf import SerializationContext

if asdf.__version__ >= "3.0.0":
from asdf.extension import SerializationContext
else:
from asdf.asdf import SerializationContext
from asdf.config import AsdfConfig, get_config
from asdf.extension import Extension
from asdf.tagged import TaggedDict, TaggedList, TaggedString
Expand Down Expand Up @@ -495,7 +499,7 @@ def from_yaml_tree(

def get_weldx_extension(ctx: SerializationContext | AsdfConfig) -> Extension:
"""Grab the weldx extension from list of current active extensions."""
if isinstance(ctx, asdf.asdf.SerializationContext):
if isinstance(ctx, SerializationContext):
extensions = ctx.extension_manager.extensions
elif isinstance(ctx, asdf.config.AsdfConfig):
extensions = ctx.extensions
Expand Down
7 changes: 6 additions & 1 deletion weldx/tags/base_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@

from uuid import UUID

from asdf.asdf import SerializationContext
import asdf

if asdf.__version__ >= "3.0.0":
from asdf.extension import SerializationContext
else:
from asdf.asdf import SerializationContext

from weldx.asdf.types import WeldxConverter

Expand Down

0 comments on commit f9dca49

Please sign in to comment.