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

Ignore Pydantic 'Field name "json" shadows an attribute in parent' warning #417

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/datachain/lib/webdataset.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import hashlib
import json
import tarfile
import warnings
from collections.abc import Iterator, Sequence
from pathlib import Path
from typing import (
Expand All @@ -19,6 +20,18 @@
from datachain.lib.file import File, TarVFile
from datachain.lib.utils import DataChainError

# The `json` method of the Pydantic `BaseModel` class has been deprecated
# and will be removed in Pydantic v3. For more details, see:
# https://github.com/pydantic/pydantic/issues/10033
# Until then, we can ignore the warning.
warnings.filterwarnings(
"ignore",
category=UserWarning,
message=(
'Field name "json" in "WDSAllFile" shadows an attribute in parent "WDSBasic"'
),
)


class WDSError(DataChainError):
def __init__(self, tar_stream, message: str):
Expand Down
13 changes: 13 additions & 0 deletions src/datachain/lib/webdataset_laion.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import warnings
from collections.abc import Iterator
from typing import Optional

Expand All @@ -7,6 +8,18 @@
from datachain.lib.file import File
from datachain.lib.webdataset import WDSBasic, WDSReadableSubclass

# The `json` method of the Pydantic `BaseModel` class has been deprecated
# and will be removed in Pydantic v3. For more details, see:
# https://github.com/pydantic/pydantic/issues/10033
# Until then, we can ignore the warning.
warnings.filterwarnings(
"ignore",
category=UserWarning,
message=(
'Field name "json" in "WDSLaion" shadows an attribute in parent "WDSBasic"'
),
)


class Laion(WDSReadableSubclass):
uid: str = Field(default="")
Expand Down
Loading