openrsgis / pytdml

Python library for TrainingDML-AI encode/decode
MIT License
16 stars 7 forks source link

Potential bugs withing pytdml yaml_to_pytdml #11

Open pixalytics opened 3 months ago

pixalytics commented 3 months ago

I am trying to use yaml_to_pytdml.py, but have found the following issues with the latest version that I think will also be experienced by other users. I'd be happy to push my changes, but you might have an improved set of fixes as you know the code better. So, I'm listing them and my quick but not elegant solutions. Let me know if you need further details, or I've done something incorrectly.

Best Wishes, Sam

  1. When I import pytdml into my code, the Python module import gets stuck.
    • If I stop the code, I find pytdml.utils.remove_empty is trying to access a Wuhan S3 bucket, but failing to do so. My quick solution was to comment out from pytdml.utils import remove_empty from tdml_writers.py
    • The next problem is I get the error "ImportError: cannot import name 'Label' from partially initialized module 'pytdml.type.basic_types' (most likely due to a circular import)" I think is because pytdml.type.basic_types imports pytdml.type.extended_types and pytdml.type.extended_types imports pytdml.type.basic_types. To solve this quickly, I commented out the import of pytdml.type.extended_types import of pytdml.type.basic_types but also had to undo the recent changes that used the extended types.
  2. If optional parameters are not included, the validator complains about them not being present. I found I needed to do the following in basic_types and extended_types, e.g. change date_time: Optional[str] to date_time: Optional[str] = "" I wasn't sure what to do when then the variable is a float/integer, e.g. tone_gradation: Optional[int], so this becomes optional.
  3. When yaml_to_pytdml.py calls an extended function, I find I need to add type for the validator to be happy, but it feels like this shouldn't be needed in the call as the value is always the same, e.g. from modified pytdml.type.extended_types:
    if dataset_type == 'EOTrainingDataset':
        eo_training_dataset = EOTrainingDataset(
            type="AI_EOTrainingDataset",
            id=yaml_dict['id'],
            name=yaml_dict['name'],
            description=yaml_dict['description'],
photonbit commented 3 months ago

Although not optimally, this PR https://github.com/openrsgis/pytdml/pull/14 solves the points 1 and 3 :nerd_face: