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

code requires update... #12

Open
stephank007 opened this issue Jan 10, 2023 · 3 comments
Open

code requires update... #12

stephank007 opened this issue Jan 10, 2023 · 3 comments

Comments

@stephank007
Copy link

Hello,

would love to use your package and examples, however it is outdated, with newer bootstrap and dash versions.

would it possible for you to update your package

@Mereep
Copy link

Mereep commented Feb 21, 2023

Hello,

would love to use your package and examples, however it is outdated, with newer bootstrap and dash versions.

would it possible for you to update your package

Came here for the same question. Any plans on updating the package? Is there some kind of roadmap on things to do?

@newlog
Copy link

newlog commented Aug 2, 2023

To be more explicit, this is one of the errors that are triggered on execution.

  File "<path>", line 8, in <module>
    from json_schema_to_dash_forms import SchemaFormContainer
  File "json_schema_to_dash_forms/__init__.py", line 1, in <module>
    from .forms import SchemaFormContainer
  File "json_schema_to_dash_forms/forms.py", line 17, in <module>
    class SchemaFormItem(dbc.FormGroup):
                         ^^^^^^^^^^^^^
  File "dash_bootstrap_components/__init__.py", line 50, in __getattr__
    raise AttributeError(
AttributeError: FormGroup was deprecated in dash-bootstrap-components version 1.0.0. You are using 1.4.1. For more details please see the migration guide: https://dash-bootstrap-components.opensource.faculty.ai/migration-guide/. Did you mean: 'CardGroup'?

@newlog
Copy link

newlog commented Aug 2, 2023

A list of fixes I had to do to get me to a point where it seems it might execute.

Deprecated components:

  • Replace FormsGroup by Form.
  • Remove InputGroupAddon objects and just pass whatever it's inside of the InputGroupAddon to the parent's children parameter.
  • Replace all references of "checked" to "value".
  • Replace all references of "bs_size" to "size".

It is assumed that the instance variable "schema" in SchemaForm class will always be a dictionary, even in the example of the author, it also happens to be a list. Here:

class SchemaForm(dbc.Card):
    """
    Form generated by JSON Schema.
    """

    def __init__(self, schema, key, container=None, parent_form=None):
        super().__init__([])

        self.schema = schema
        self.owner_class = schema.get('tag', '')
        self.parent_form = parent_form
        self.skiped_forms = []

And it fails with the schema example, here:

(...)
	    		"subform_children_array_example": {
	    			"type": "array",
		            "description": "subforms children array w/ size defined by min/max items and referenced by definitions",
		            "minItems": 2,
		            "maxItems": 2,
		            "items": [{"$ref":  "#/definitions/ChildrenExample"}]
	    		}
	    	}
	    }
      }
    }
  },
	"definitions": {
	    "ChildrenExample": {
	      "type": "object",
	      "required": ["string"],
	      "properties": {
	        "string": {
	          "type": "string",
	          "description": "children string field"
	        },
	        "description": {
	          "type": "number",
	          "description": "children numeric field"
	        }
	      }
	    }
	}
}

For now, I won't use subforms/refs in that manner.

Finally, it seems you can't pass DashBlueprint to parent_app when instantiating SchemaFormContainer . I fixed that by using the get_app() helper from dash (not positive it will always work in my case).

By doing all those changes you get the UI to render.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants