Avaiga / taipy

Turns Data and AI algorithms into production-ready web applications in no time.
https://www.taipy.io
Apache License 2.0
16.99k stars 1.86k forks source link

[🐛 BUG] Library Initialization Order Issue #1776

Open FlorianJacta opened 2 months ago

FlorianJacta commented 2 months ago

What went wrong? 🤔

There is an issue when the ExampleLibrary is added after the page is declared using the builder method. The library does not work as expected unless it is added before the page declaration.

Reproduction Steps

  1. Add the ExampleLibrary after declaring the page using builder.
  2. Observe that the library is not functioning properly.

Workaround

Call Gui.add_library(ExampleLibrary()) before declaring the page.

Additional Context

The current implementation of ExampleLibrary looks like this:

class ExampleLibrary(ElementLibrary):
    def init(self) -> None:
        self.elements = {
            "label": Element(
                default_property = "textbody",
                properties = {"textbody": ElementProperty(PropertyType.dynamic_string),
                              "sessionid": ElementProperty(PropertyType.dynamic_string),
                              },
                react_component = "WordSelector",
            ),
        }

    def get_name(self) -> str:
        return "example"

    def get_elements(self) -> dict:
        return self.elements

    def get_scripts(self) -> list[str]:
        return ["front-end/dist/exampleLibrary.js"]

Expected Behavior

The ExampleLibrary should work as expected regardless of when it is added relative to the page declaration.

Suggested Solution

Investigate the initialization order and update the documentation or library to ensure compatibility.

Acceptance Criteria

Code of Conduct

jrobinAV commented 2 months ago

When add_library is called, could Taipy inform the developer that it is too late? Like a warning saying: "you already used builder. be careful!"?

heyysiri commented 2 months ago

Hey @jrobinAV @FlorianJacta , I'm a first time contributor at Hacktoberfest. I would like to work on this issue. Can you please assign it to me?

FlorianJacta commented 2 months ago

Hi @heyysiri, you are assigned to this issue. Don't hesitate to talk with @FabienLelaquais and @FredLL-Avaiga about this issue. Thank you for your contribution

quest-bot[bot] commented 1 month ago

New Quest! image New Quest!

A new Quest has been launched in @Avaiga’s repo. Merge a PR that solves this issue to loot the Quest and earn your reward.


Some loot has been stashed in this issue to reward the solver!

🗡 Comment @quest-bot embark to check-in for this Quest and start solving the issue. Other solvers will be notified!

⚔️ When you submit a PR, comment @quest-bot loot #1776 to link your PR to this Quest.

Questions? Check out the docs.

Namithesh commented 1 month ago

Hey @FlorianJacta, is this resolved?

FlorianJacta commented 1 month ago

Not yet, do you want to be assigned to this issue also? @Namithesh

github-actions[bot] commented 1 month ago

This issue has been labelled as "🥶Waiting for contributor" because it has been inactive for more than 14 days. If you would like to continue working on this issue, please add another comment or create a PR that links to this issue. If a PR has already been created which refers to this issue, then you should explicitly mention this issue in the relevant PR. Otherwise, you will be unassigned in 14 days. For more information please refer to the contributing guidelines.

github-actions[bot] commented 2 weeks ago

This issue has been unassigned automatically because it has been marked as "🥶Waiting for contributor" for more than 14 days with no activity.