From 05176b210b1400fc2078af542ef92d98716e039a Mon Sep 17 00:00:00 2001 From: relifest <3380383714@qq.com> Date: Thu, 10 Oct 2024 22:04:06 +0800 Subject: [PATCH 01/14] configuring the GitHub actions and flows --- pytdml/type/basic_types.py | 4 ++-- pytdml/type/extended_types.py | 11 ++++++++++- tests/data/WHU-building.json | 35 +++++++++++++++++++++++++++++------ tests/test_basic_types.py | 6 +++--- 4 files changed, 44 insertions(+), 12 deletions(-) diff --git a/pytdml/type/basic_types.py b/pytdml/type/basic_types.py index 49544ee..5a581e4 100644 --- a/pytdml/type/basic_types.py +++ b/pytdml/type/basic_types.py @@ -1289,8 +1289,8 @@ class AI_Label(BaseCamelModel): type: Literal["AI_AbstractLabel"] - is_negative: Optional[bool] = False # Optional without default value - confidence: Optional[float] = Field(1.0, ge=0.0, le=1.0) + is_negative: Optional[bool] = None + confidence: Optional[float] = Field(None, ge=0.0, le=1.0) def to_dict(self): return self.model_dump(by_alias=True, exclude_none=True) diff --git a/pytdml/type/extended_types.py b/pytdml/type/extended_types.py index 10f7eeb..0cd3842 100644 --- a/pytdml/type/extended_types.py +++ b/pytdml/type/extended_types.py @@ -195,7 +195,7 @@ class EOTrainingDataset(TrainingDataset): # For Convinience, we allow the user to specify the bands by name bands: Optional[List[MD_Band]] = None - extent: Optional[EX_Extent] = None + extent: Optional[Union[EX_Extent, List[Union[int, float]]]] = None image_size: Optional[str] = None def to_dict(self): @@ -204,4 +204,13 @@ def to_dict(self): @staticmethod def from_dict(json_dict): new_dict = copy.deepcopy(json_dict) + if new_dict.__contains__('extent'): + extent = new_dict['extent'] + print(extent) + for i in range(len(extent)): + if EX_Extent.can_build_from_data(extent[i]): + extent[i] = EX_Extent.from_dict(extent[i]) + else: + print(1) + new_dict['extent'] = extent return EOTrainingDataset(**new_dict) diff --git a/tests/data/WHU-building.json b/tests/data/WHU-building.json index d2aec23..26326f6 100644 --- a/tests/data/WHU-building.json +++ b/tests/data/WHU-building.json @@ -18,14 +18,33 @@ ], "classes": [ { - "building": 1 + "key": "building", + "value": 1 } ], "numberOfClasses": 1, "bands": [ - "red", - "green", - "blue" + { + "name": [ + { + "code": "red" + } + ] + }, + { + "name": [ + { + "code": "green" + } + ] + }, + { + "name": [ + { + "code": "blue" + } + ] + } ], "imageSize": "32507x15354", "tasks": [ @@ -58,8 +77,12 @@ "labels": [ { "type": "AI_PixelLabel", - "imageURL": ["change label/change_label.tif"], - "imageFormat": ["TIFF"] + "imageURL": [ + "change_label/change_label.tif" + ], + "imageFormat": [ + "image/tiff" + ] } ] } diff --git a/tests/test_basic_types.py b/tests/test_basic_types.py index c369b77..23b92d7 100644 --- a/tests/test_basic_types.py +++ b/tests/test_basic_types.py @@ -3,7 +3,7 @@ import jsonschema import requests -from pytdml.type.basic_types import _validate_date, to_camel,Labeler +from pytdml.type.basic_types import _validate_date, to_camel, AI_Labeler base_url = "https://raw.githubusercontent.com/opengeospatial/TrainingDML-AI_SWG/main/schemas/1.0/json_schema/{}.json" @@ -120,7 +120,7 @@ def test_required_elements_with_Labeler(): "name": "zhaoyan" } with pytest.raises( ValidationError): - Labeler(**data) + AI_Labeler(**data) # Test valid Labeler and with remote schema def test_valid_Labeler_schema(): @@ -129,7 +129,7 @@ def test_valid_Labeler_schema(): "id": "1", "name": "zhaoyan" } - labeler = Labeler(**data) + labeler = AI_Labeler(**data) remote_schema_url = base_url.format("ai_labeler") response = requests.get(remote_schema_url) From 342b2762beb8a6c9b5602a1b5fb0a5e5c1b5173b Mon Sep 17 00:00:00 2001 From: Zhangyang <100121932+Relifest@users.noreply.github.com> Date: Fri, 11 Oct 2024 10:19:14 +0800 Subject: [PATCH 02/14] Update tests.yml --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f9c5036..7fe5056 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -26,7 +26,7 @@ jobs: ${{ runner.os }}-pip- - name: Install dependencies - run: pip install -r requirements.txt && pip install .[test] + run: pip install -r requirements.txt && pip install .[dev] - name: Run tests run: pytest From c6e00351cd8a40809b0b5b1e1105c8e080d14fe4 Mon Sep 17 00:00:00 2001 From: Zhangyang <100121932+Relifest@users.noreply.github.com> Date: Fri, 11 Oct 2024 11:27:20 +0800 Subject: [PATCH 03/14] Update requirements.txt --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index b81f0e8..71f82f7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -17,4 +17,5 @@ rasterio~=1.3.10 matplotlib~=3.9.1 minio~=7.2.7 tqdm~=4.66.4 +pytest~=8.3.3 # setuptools~=60.10.0 From f27ff3525a31006c07e4dd064847f82c65b138d9 Mon Sep 17 00:00:00 2001 From: Zhangyang <100121932+Relifest@users.noreply.github.com> Date: Fri, 11 Oct 2024 16:37:37 +0800 Subject: [PATCH 04/14] Update setup.py --- setup.py | 103 +++++++++++++------------------------------------------ 1 file changed, 24 insertions(+), 79 deletions(-) diff --git a/setup.py b/setup.py index 301b175..4c139a1 100644 --- a/setup.py +++ b/setup.py @@ -1,87 +1,32 @@ -# ------------------------------------------------------------------------------ -# -# Project: pytdml -# Authors: Boyi Shangguan, Kaixuan Wang -# Created: 2022-05-04 -# Email: sgby@whu.edu.cn -# -# ------------------------------------------------------------------------------ -# -# Copyright (c) 2022 OGC Training Data Markup Language for AI Standard Working Group -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# -# ------------------------------------------------------------------------------ +name: Python application -"""Install pytdml.""" +on: [push, pull_request] -from setuptools import find_packages, setup -import io -import os.path +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 -def read(filename, encoding='utf-8'): - """read file contents""" - full_path = os.path.join(os.path.dirname(__file__), filename) - with io.open(full_path, encoding=encoding) as fh: - contents = fh.read().strip() - return contents + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.9' + - name: Cache pip dependencies + id: cache-pip + uses: actions/cache@v4 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }} -# get version number -with open(os.path.join(os.path.dirname(__file__), 'pytdml/__init__.py')) as f: - for line in f: - if line.find("__version__") >= 0: - version = line.split("=")[1].strip() - version = version.strip('"') - version = version.strip("'") - break + restore-keys: | + ${{ runner.os }}-pip- + - name: Install dependencies + run: pip install . && pip install .[dev] -# get dependencies -with open("requirements.txt") as f: - install_requires = [line for line in f if line and line[0] not in "#-"] - - -# use README.md for project long_description -long_description = read('README.md') - -setup( - name='pytdml', - version=version, - description='Parsing and encoding training datasets based on OGC Training Data Markup Language for AI (' - 'TrainingDML-AI) standard', - long_description=long_description, - long_description_content_type="text/markdown", - author='Boyi Shangguan', - author_email='sgby@whu.edu.cn', - url='https://github.com/TrainingDML/pytdml', - license='MIT', - packages=find_packages(), - include_package_data=True, - install_requires=install_requires, - classifiers=[ - 'Development Status :: 3 - Alpha', - 'Intended Audience :: Developers', - 'Topic :: Scientific/Engineering :: GIS', - 'License :: OSI Approved :: MIT License', - 'Programming Language :: Python :: 3', - ], - tests_require=['pytest'] -) + - name: Run tests + run: pytest From 648d28accec76e256f93d2a0bdee780e3ca37241 Mon Sep 17 00:00:00 2001 From: Zhangyang <100121932+Relifest@users.noreply.github.com> Date: Fri, 11 Oct 2024 16:39:09 +0800 Subject: [PATCH 05/14] Create pyproject.toml --- pyproject.toml | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..9c782e2 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,38 @@ +[build-system] +requires = ["setuptools>=42", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "pytdml" +version = "0.0.1" +dependencies = [ + "geojson~=3.1.0", + "Pillow~=10.4.0", + "PyYAML~=6.0", + "numpy~=1.26.4", + "pandas~=2.2.2", + "opencv-python~=4.10.0.84", + "tensorflow~=2.17.0", + "jsonschema~=4.23.0", + "requests~=2.32.3", + "pydantic~=2.8.2", + "urllib3~=2.2.2", + "rasterio~=1.3.10", + "matplotlib~=3.9.1", + "minio~=7.2.7", + "tqdm~=4.66.4", + "s3fs~=2024.9.0" +] + +[project.optional-dependencies] +torch = [ + "torch~=2.3.1", + "torchvision~=0.18.1", + "torchdata~=0.7.1" +] + +[project.urls] +homepage = "https://github.com/TrainingDML/pytdml" + +[tool.setuptools.packages.find] +where = ["."] From 533bcac27620013ba321bec98a77f17485d0c2ac Mon Sep 17 00:00:00 2001 From: Zhangyang <100121932+Relifest@users.noreply.github.com> Date: Fri, 11 Oct 2024 16:39:25 +0800 Subject: [PATCH 06/14] Delete requirements.txt --- requirements.txt | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 requirements.txt diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 71f82f7..0000000 --- a/requirements.txt +++ /dev/null @@ -1,21 +0,0 @@ -geojson~=3.1.0 -torch~=2.3.1 -Pillow~=10.4.0 -PyYAML~=6.0 -numpy~=1.26.4 -pandas~=2.2.2 -opencv-python~=4.10.0.84 -tensorflow~=2.17.0 -tensorflow-io~=0.37.1 -torchvision~=0.18.1 -torchdata~=0.7.1 -jsonschema~=4.23.0 -requests~=2.32.3 -pydantic~=2.8.2 -urllib3~=2.2.2 -rasterio~=1.3.10 -matplotlib~=3.9.1 -minio~=7.2.7 -tqdm~=4.66.4 -pytest~=8.3.3 -# setuptools~=60.10.0 From 63d8aecd11271ec0c429913ec90387a269bb6c52 Mon Sep 17 00:00:00 2001 From: Zhangyang <100121932+Relifest@users.noreply.github.com> Date: Fri, 11 Oct 2024 16:40:02 +0800 Subject: [PATCH 07/14] Update tests.yml --- .github/workflows/tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 7fe5056..4c139a1 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -20,13 +20,13 @@ jobs: uses: actions/cache@v4 with: path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} + key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }} restore-keys: | ${{ runner.os }}-pip- - name: Install dependencies - run: pip install -r requirements.txt && pip install .[dev] + run: pip install . && pip install .[dev] - name: Run tests run: pytest From 3aa2927ab2cf7d9e7d0ad47083c190139545e206 Mon Sep 17 00:00:00 2001 From: relifest <3380383714@qq.com> Date: Fri, 11 Oct 2024 16:57:18 +0800 Subject: [PATCH 08/14] dividing pytorch from basic function. --- pytdml/convert_utils.py | 14 ++--- pytdml/tdml_image_crop.py | 6 +- pytdml/type/__init__.py | 5 ++ setup.py | 122 ++++++++++++++++++++++++++++++-------- tests/test_basic_types.py | 10 ++-- tests/test_tdml_io.py | 2 +- 6 files changed, 119 insertions(+), 40 deletions(-) diff --git a/pytdml/convert_utils.py b/pytdml/convert_utils.py index 3329048..cc43e81 100644 --- a/pytdml/convert_utils.py +++ b/pytdml/convert_utils.py @@ -3,7 +3,7 @@ from geojson import Feature from pytdml.io import write_to_json -from pytdml.type import EOTrainingData, EOTrainingDataset, EOTask, ObjectLabel,PixelLabel +from pytdml.type import AI_EOTrainingData, EOTrainingDataset, AI_EOTask, AI_ObjectLabel, AI_PixelLabel import os import re import time @@ -102,7 +102,7 @@ def convert_coco_to_tdml(coco_dataset_path, output_json_path): coord = [[points[0], points[1]], [points[0] + points[2], points[1]], [points[0] + points[2], points[1] + points[3]], [points[0], points[1] + points[2]]] - labels = ObjectLabel(is_negative=False, type="AI_ObjectLabel", confidence=1.0, object=Feature( + labels = AI_ObjectLabel(is_negative=False, type="AI_ObjectLabel", confidence=1.0, object=Feature( id="feature " + str(i), geometry={ "type": "Polygon", "coordinates": coord @@ -112,7 +112,7 @@ def convert_coco_to_tdml(coco_dataset_path, output_json_path): training_type = categorize_string(os.path.basename(os.path.dirname(image_json["coco_url"]))) numbers_of_labels = len(object_labels) - td = EOTrainingData(id=str(image_json["id"]),type="AI_EOTrainingData",data_sources=[""], + td = AI_EOTrainingData(id=str(image_json["id"]),type="AI_EOTrainingData",data_sources=[""], dataset_id=dataset_id, training_type=training_type, number_of_labels=numbers_of_labels, labels=object_labels, date_time=[image_json["date_captured"].replace(' ', 'T')],extent=None, data_URL=[image_json["coco_url"]]) @@ -131,7 +131,7 @@ def convert_coco_to_tdml(coco_dataset_path, output_json_path): type="AI_EOTrainingDataset", name=dataset_name, description=dataset_description, - tasks=[EOTask(task_type="Object Detection", + tasks=[AI_EOTask(task_type="Object Detection", id=str(dataset_id) + "_task", dataset_id=str(dataset_id), type='AI_EOTask', @@ -202,16 +202,16 @@ def convert_stac_to_tdml(stac_dataset_path, output_json_path): data_url.append(img_path) label_url = label_path image_type = label_type - labels = [PixelLabel(confidence=1.0,type="AI_PixelLabel",image_URL=[label_url],image_format=[image_type])] + labels = [AI_PixelLabel(confidence=1.0,type="AI_PixelLabel",image_URL=[label_url],image_format=[image_type])] td_list.append( - EOTrainingData(id=item_id,type="AI_EOTrainingData",training_type="Train", dataset_id=dataset_id,number_of_labels=1,labels=labels,extent=item_extent, + AI_EOTrainingData(id=item_id,type="AI_EOTrainingData",training_type="Train", dataset_id=dataset_id,number_of_labels=1,labels=labels,extent=item_extent, data_URL=data_url)) for class_dict in label_classes: class_dict['value'] = class_dict.pop('classes') - tasks = [EOTask(task_type=task_name, + tasks = [AI_EOTask(task_type=task_name, id=str(dataset_id) + "_task", dataset_id= str(dataset_id), type='AI_EOTask')] diff --git a/pytdml/tdml_image_crop.py b/pytdml/tdml_image_crop.py index 8c82a49..f382994 100644 --- a/pytdml/tdml_image_crop.py +++ b/pytdml/tdml_image_crop.py @@ -39,7 +39,7 @@ from geojson import Feature, Polygon from pytdml.io import read_from_json -from pytdml.type import EOTrainingDataset, EOTrainingData, PixelLabel +from pytdml.type import EOTrainingDataset, AI_EOTrainingData, AI_PixelLabel from pytdml.utils import remove_empty @@ -62,9 +62,9 @@ def td_image_crop(td: EOTrainingDataset, save_tdml_path: str, save_crop_dir: str crop_image_list = image_crop(image_url, image_dir, sub_size) crop_label_list = image_crop(label_url, label_dir, sub_size) for crop_image_url, crop_label_url in zip(crop_image_list, crop_label_list): - new_d = EOTrainingData( + new_d = AI_EOTrainingData( id=str(index), - labels=[PixelLabel(image_url=crop_label_url)], + labels=[AI_PixelLabel(image_url=crop_label_url)], data_url=crop_image_url, ) index = index + 1 diff --git a/pytdml/type/__init__.py b/pytdml/type/__init__.py index e129b5a..c2ea481 100644 --- a/pytdml/type/__init__.py +++ b/pytdml/type/__init__.py @@ -41,4 +41,9 @@ from .basic_types import QualityElement from .basic_types import DataQuality from .basic_types import TrainingDataset +from .extended_types import AI_PixelLabel +from .extended_types import AI_ObjectLabel +from .extended_types import AI_ObjectLabel +from .extended_types import AI_EOTask +from .extended_types import AI_EOTrainingData from .extended_types import EOTrainingDataset diff --git a/setup.py b/setup.py index 4c139a1..f8773a4 100644 --- a/setup.py +++ b/setup.py @@ -1,32 +1,106 @@ -name: Python application +# ------------------------------------------------------------------------------ +# +# Project: pytdml +# Authors: Boyi Shangguan, Kaixuan Wang +# Created: 2022-05-04 +# Email: sgby@whu.edu.cn +# +# ------------------------------------------------------------------------------ +# +# Copyright (c) 2022 OGC Training Data Markup Language for AI Standard Working Group +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# +# ------------------------------------------------------------------------------ -on: [push, pull_request] +"""Install pytdml.""" -jobs: - build: - runs-on: ubuntu-latest +from setuptools import find_packages, setup +import io +import os.path - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: '3.9' +def read(filename, encoding='utf-8'): + """read file contents""" + full_path = os.path.join(os.path.dirname(__file__), filename) + with io.open(full_path, encoding=encoding) as fh: + contents = fh.read().strip() + return contents - - name: Cache pip dependencies - id: cache-pip - uses: actions/cache@v4 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }} - restore-keys: | - ${{ runner.os }}-pip- +# get version number +with open(os.path.join(os.path.dirname(__file__), 'pytdml/__init__.py')) as f: + for line in f: + if line.find("__version__") >= 0: + version = line.split("=")[1].strip() + version = version.strip('"') + version = version.strip("'") + break - - name: Install dependencies - run: pip install . && pip install .[dev] - - name: Run tests - run: pytest +# use README.md for project long_description +long_description = read('README.md') + +from setuptools import find_packages, setup +import io +import os.path + +def read(filename, encoding='utf-8'): + """read file contents""" + full_path = os.path.join(os.path.dirname(__file__), filename) + with io.open(full_path, encoding=encoding) as fh: + contents = fh.read().strip() + return contents + +# get version number +with open(os.path.join(os.path.dirname(__file__), 'pytdml/__init__.py')) as f: + for line in f: + if line.find("__version__") >= 0: + version = line.split("=")[1].strip() + version = version.strip('"') + version = version.strip("'") + break + +# use README.md for project long_description +long_description = read('README.md') + +setup( + name='pytdml', + version=version, + description='Parsing and encoding training datasets based on OGC Training Data Markup Language for AI (TrainingDML-AI) standard', + long_description=long_description, + long_description_content_type="text/markdown", + author='Boyi Shangguan', + author_email='sgby@whu.edu.cn', + url='https://github.com/TrainingDML/pytdml', + license='MIT', + packages=find_packages(), + include_package_data=True, + classifiers=[ + 'Development Status :: 3 - Alpha', + 'Intended Audience :: Developers', + 'Topic :: Scientific/Engineering :: GIS', + 'License :: OSI Approved :: MIT License', + 'Programming Language :: Python :: 3', + ], + tests_require=['pytest'], + extras_require = { + 'dev': ['pytest'], + } +) diff --git a/tests/test_basic_types.py b/tests/test_basic_types.py index 23b92d7..3c0bd1e 100644 --- a/tests/test_basic_types.py +++ b/tests/test_basic_types.py @@ -1,5 +1,5 @@ import pytest -from pydantic import ValidationError, BaseModel, validator +from pydantic import ValidationError, BaseModel, validator, field_validator import jsonschema import requests @@ -11,7 +11,7 @@ class test_date_model(BaseModel): date: str - @validator("date") + @field_validator("date") def validate_date(cls, v): return _validate_date(v) @@ -120,7 +120,7 @@ def test_required_elements_with_Labeler(): "name": "zhaoyan" } with pytest.raises( ValidationError): - AI_Labeler(**data) + AI_Labeler.from_dict(data) # Test valid Labeler and with remote schema def test_valid_Labeler_schema(): @@ -129,10 +129,10 @@ def test_valid_Labeler_schema(): "id": "1", "name": "zhaoyan" } - labeler = AI_Labeler(**data) + labeler = AI_Labeler.from_dict(data) remote_schema_url = base_url.format("ai_labeler") response = requests.get(remote_schema_url) remote_schema = response.json() - jsonschema.validate(instance=labeler.dict(), schema=remote_schema) + jsonschema.validate(instance=labeler.to_dict(), schema=remote_schema) diff --git a/tests/test_tdml_io.py b/tests/test_tdml_io.py index 4b871ef..aca405a 100644 --- a/tests/test_tdml_io.py +++ b/tests/test_tdml_io.py @@ -12,4 +12,4 @@ def test_read_and_write(): td = read_from_json(tdml_path) with open(tdml_path, 'r') as f: data = json.load(f) - assert td.dict(by_alias=True,exclude_none=True) == data + assert td.to_dict() == data From eae4af471dadcc227823901f2e0ff350e8a09861 Mon Sep 17 00:00:00 2001 From: relifest <3380383714@qq.com> Date: Fri, 11 Oct 2024 17:11:17 +0800 Subject: [PATCH 09/14] dividing pytorch from basic function. --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 9c782e2..b9da0a3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,6 +5,7 @@ build-backend = "setuptools.build_meta" [project] name = "pytdml" version = "0.0.1" +dynamic = ["authors", "license", "description", "readme"] dependencies = [ "geojson~=3.1.0", "Pillow~=10.4.0", From 0ccea3110d1baa7bd54c20870de73e2f653ab3a5 Mon Sep 17 00:00:00 2001 From: relifest <3380383714@qq.com> Date: Fri, 11 Oct 2024 17:18:27 +0800 Subject: [PATCH 10/14] dividing pytorch from basic function. --- pyproject.toml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index b9da0a3..f492e35 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,8 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "pytdml" -version = "0.0.1" -dynamic = ["authors", "license", "description", "readme"] +dynamic = ["version", "authors", "license", "description", "readme"] dependencies = [ "geojson~=3.1.0", "Pillow~=10.4.0", From 4c1ae9de883456db28a2c702177ea149fc1016f2 Mon Sep 17 00:00:00 2001 From: Zhangyang <100121932+Relifest@users.noreply.github.com> Date: Fri, 11 Oct 2024 17:46:13 +0800 Subject: [PATCH 11/14] Update tests.yml --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4c139a1..5a11dc9 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -26,7 +26,7 @@ jobs: ${{ runner.os }}-pip- - name: Install dependencies - run: pip install . && pip install .[dev] + run: pip install .[dev] - name: Run tests run: pytest From 91dc19e2d45d31631796852901b57ac5061f4f7a Mon Sep 17 00:00:00 2001 From: Zhangyang <100121932+Relifest@users.noreply.github.com> Date: Fri, 11 Oct 2024 17:53:22 +0800 Subject: [PATCH 12/14] Update tests.yml --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5a11dc9..d68bd34 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -26,7 +26,7 @@ jobs: ${{ runner.os }}-pip- - name: Install dependencies - run: pip install .[dev] + run: pip install .[dev] && pip install .[all] - name: Run tests run: pytest From 3dde76d90082b5bdb4018555190f1071514f9ffb Mon Sep 17 00:00:00 2001 From: Zhangyang <100121932+Relifest@users.noreply.github.com> Date: Tue, 15 Oct 2024 20:54:40 +0800 Subject: [PATCH 13/14] Update pyproject.toml --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index f492e35..515a48b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,7 +16,7 @@ dependencies = [ "jsonschema~=4.23.0", "requests~=2.32.3", "pydantic~=2.8.2", - "urllib3~=2.2.2", + "urllib3~=1.25.4", "rasterio~=1.3.10", "matplotlib~=3.9.1", "minio~=7.2.7", From fe0831e65875a8aae7be25984a1d1cd4f5186dea Mon Sep 17 00:00:00 2001 From: Zhangyang <100121932+Relifest@users.noreply.github.com> Date: Wed, 16 Oct 2024 17:38:12 +0800 Subject: [PATCH 14/14] Update extended_types.py --- pytdml/type/extended_types.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pytdml/type/extended_types.py b/pytdml/type/extended_types.py index 0cd3842..0d8275b 100644 --- a/pytdml/type/extended_types.py +++ b/pytdml/type/extended_types.py @@ -206,11 +206,10 @@ def from_dict(json_dict): new_dict = copy.deepcopy(json_dict) if new_dict.__contains__('extent'): extent = new_dict['extent'] - print(extent) for i in range(len(extent)): if EX_Extent.can_build_from_data(extent[i]): extent[i] = EX_Extent.from_dict(extent[i]) else: - print(1) + continue new_dict['extent'] = extent return EOTrainingDataset(**new_dict)