taipy icon indicating copy to clipboard operation
taipy copied to clipboard

[🐛 BUG] Library Initialization Order Issue

Open FlorianJacta opened this issue 1 year ago • 6 comments

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

  • [ ] Ensure new code is unit tested, and check code coverage is at least 90%.
  • [ ] Create related issue in taipy-doc for documentation and Release Notes.

Code of Conduct

  • [X] I have checked the existing issues.
  • [ ] I am willing to work on this issue (optional)

FlorianJacta avatar Sep 11 '24 12:09 FlorianJacta

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!"?

jrobinAV avatar Sep 27 '24 12:09 jrobinAV

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?

heyysiri avatar Oct 02 '24 06:10 heyysiri

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

FlorianJacta avatar Oct 02 '24 07:10 FlorianJacta

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.

quest-bot[bot] avatar Oct 07 '24 11:10 quest-bot[bot]

Hey @FlorianJacta, is this resolved?

Namithesh avatar Oct 13 '24 10:10 Namithesh

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

FlorianJacta avatar Oct 14 '24 07:10 FlorianJacta

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] avatar Oct 28 '24 09:10 github-actions[bot]

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

github-actions[bot] avatar Nov 12 '24 09:11 github-actions[bot]