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

New Trello document loader #4767

Merged
merged 10 commits into from
May 30, 2023

Conversation

GMartin-dev
Copy link
Contributor

@GMartin-dev GMartin-dev commented May 16, 2023

Added New Trello loader class and documentation

Simple Loader on top of py-trello wrapper.
With a board name you can pull cards and to do some field parameter tweaks on load operation.
I included documentation and examples.
Included unit test cases using patch and a fixture for py-trello client class.

Thanks in advance for your feedback @eyurtsev.

Copy link
Collaborator

@eyurtsev eyurtsev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes to move configuration information into the initializer.

self.api_token = api_token

def load(
self,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GDrupal Thanks for the contribution!

Document loaders require an argumentless load method.

Could you push the configuration into the initializer?

I've commented on the types of some of the parameters in load, so we can update the type signatures as well when moving to __ init __

self,
board_name: str,
card_filter: Optional[str] = "all",
include_card_name: Optional[bool] = True,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bools shouldn't have an optional since we only care about True and False, not about a None value. (At least in this case)

Suggested change
include_card_name: Optional[bool] = True,
include_card_name: bool = True,

include_card_name: Optional[bool] = True,
include_comments: Optional[bool] = True,
include_checklist: Optional[bool] = True,
extra_metadata: Optional[List[str]] = [
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sequence to denote immutability and assign tuple as default value rather than list. No need for an optional.

Suggested change
extra_metadata: Optional[List[str]] = [
extra_metadata: Sequence[str] = ("due_date", "labels", "list", "is_closed")

@@ -0,0 +1,124 @@
"""Loader that loads cards from Trello"""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have any sample data (can be fake data) to help test that the massaging code inside the loader is correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for you feedback!
I updated most of it already. Now, about the fake data....
what do you need exactly?
Are you testing loaders (with external Api request) with mockups endpoints?
Asking because I could not find examples in the codebase.
In this case we have 2 abstraction layers the actual trello api and the objects returned by py-trello, that last one is the one we interact directly from langchain.
We could create a Trello "Lang Chain Test" board from a dummy email, since the free plan gives you api access too.
But I guess you will have to keep those safe, langchain maintainers side.
No sure if that is even possible for your current test setup.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally we could test everything that follows usage of the trello client.

The client can be patched, to have board.get_cards return a fixture

cards = board.get_cards(card_filter=self.card_filter)  # <-- from a fixture instead of the web

A fixture would allow testing all the code that follows that statement, without having to rely on an internet connection or configuring trello accounts etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just attached a comment in the main methods that retrieve data. Each comment has a JSON example of the data structure that method returns.
I hope that's enough. The object from py-trello are quite obscure, I just simplified them for this use case.

@eyurtsev
Copy link
Collaborator

Thanks @GDrupal looking mostly good -- we only need to change the location of configuration to be consistent with the loader interface

@GMartin-dev GMartin-dev requested a review from eyurtsev May 17, 2023 05:54
@eyurtsev
Copy link
Collaborator

@GDrupal with some sample card data, a maintain will be able to merge this change in. We'll refactor the initializer to accept the client and create a classmethod that allows instantiation from api keys

@hwchase17 hwchase17 added the 03 enhancement Enhancement of existing functionality label May 22, 2023
@eyurtsev
Copy link
Collaborator

@GDrupal apologies for the delay -- I'll try to merge in 1-2 days trying to set some time aside to write the tests.

However, if you're familiar with unit test library and how to use mock/patch or use the responses library to get the fixture working feel free to add the tests -- that'll be helpful :)

@GMartin-dev
Copy link
Contributor Author

GMartin-dev commented May 23, 2023

@eyurtsev
I'm familiar with unit test. I found how are you doing it in the ConfluenceLoader. I will try to have it ready in the next couple of days.
Don't worry.

@dev2049 dev2049 added the Ɑ: doc loader Related to document loader module (not documentation) label May 25, 2023
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eyurtsev Added unit test cases! let me know if you see something wrong. The Trello objects are quite "weird", it took me some "creative" approach to get it working.

for item in checklist.items
]
)
text_content += f"\n{checklist.name}\n" + "\n".join(items)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

guessing only new items should be part of the join? otherwise you'll be reading all the items added from a previous checklists

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!
I saw that you did a little refactor, thanks!

@dev2049 dev2049 merged commit 0b3e0dd into langchain-ai:master May 30, 2023
@dev2049
Copy link
Contributor

dev2049 commented May 30, 2023

thanks @GDrupal! will mention this feature on twitter, happy to tag you if there's a twitter handle you wanted me to mention!

@GMartin-dev
Copy link
Contributor Author

Go for it! @musicaoriginal2
My tw handler it's messy, because i'm not only do code and I get into a lot local political discussions xD.
I'm working in a project that will need a loader for Asana and utils for both Asana / Trello.
I will be creating more PR's in the next couple of weeks / months.
So, sadly, you guys will probably have to suffer my sloppy code a bit more.

vowelparrot pushed a commit that referenced this pull request May 31, 2023
# Added New Trello loader class and documentation

Simple Loader on top of py-trello wrapper. 
With a board name you can pull cards and to do some field parameter
tweaks on load operation.
I included documentation and examples.
Included unit test cases using patch and a fixture for py-trello client
class.

---------

Co-authored-by: Dev 2049 <dev.dev2049@gmail.com>
@danielchalef danielchalef mentioned this pull request Jun 5, 2023
Undertone0809 pushed a commit to Undertone0809/langchain that referenced this pull request Jun 19, 2023
# Added New Trello loader class and documentation

Simple Loader on top of py-trello wrapper. 
With a board name you can pull cards and to do some field parameter
tweaks on load operation.
I included documentation and examples.
Included unit test cases using patch and a fixture for py-trello client
class.

---------

Co-authored-by: Dev 2049 <dev.dev2049@gmail.com>
This was referenced Jun 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
03 enhancement Enhancement of existing functionality Ɑ: doc loader Related to document loader module (not documentation)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants