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

add repr method for Rule, Dataset. #2148

Merged
merged 4 commits into from Jan 30, 2023

Conversation

Ankush-Chander
Copy link
Contributor

@Ankush-Chander Ankush-Chander commented Jan 7, 2023

Description

Please include a summary of the changes and the related issue. Please also include relevant motivation and context. List any dependencies that are required for this change.

Closes #2046

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested

Please describe the tests that you ran to verify your changes. And ideally reference tests.

import argilla as rg
from argilla.labeling.text_classification.rule import Rule

plz = Rule(query="plz OR please", label="SPAM")
print(repr(plz))
>>> Rule(query='plz OR please', label='SPAM', name='plz OR please')


records = [
        rg.TextClassificationRecord(text="example"),
        rg.TextClassificationRecord(text="another example"),
        rg.TextClassificationRecord(text="another example another example another example another example another example another example"),
    ]
dataset = rg.DatasetForTextClassification(records=records)
print(dataset)
>>>
    	text                          	annotation	prediction
0   	example                       	None      	None      
1   	another example               	None      	None      
2   	another example another exampl	None      	None      
...
3 TextClassificationRecord records

Checklist

  • I have merged the original branch into my forked branch
  • I added relevant documentation
  • follows the style guidelines of this project
  • I did a self-review of my code
  • I added comments to my code
  • I made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works

@codecov
Copy link

codecov bot commented Jan 7, 2023

Codecov Report

Base: 94.30% // Head: 94.34% // Increases project coverage by +0.04% 🎉

Coverage data is based on head (2b6526c) compared to base (3aa0c55).
Patch has no changes to coverable lines.

❗ Current head 2b6526c differs from pull request most recent head 2234032. Consider uploading reports for the commit 2234032 to get more accurate results

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2148      +/-   ##
===========================================
+ Coverage    94.30%   94.34%   +0.04%     
===========================================
  Files          151      151              
  Lines         7218     7218              
===========================================
+ Hits          6807     6810       +3     
+ Misses         411      408       -3     
Flag Coverage Δ
pytest 94.34% <ø> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/argilla/client/datasets.py 85.19% <ø> (ø)
src/argilla/labeling/text_classification/rule.py 97.05% <ø> (ø)
...gilla/labeling/text_classification/label_errors.py 90.36% <0.00%> (+3.61%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Member

@davidberenstein1957 davidberenstein1957 left a comment

Choose a reason for hiding this comment

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

Hi @Ankush-Chander, it looks great:) Could you perhaps also add a __repr__ for the API client, which exposes the active workspace and potentially available workspaces, URL/host and available datasets?

src/argilla/client/datasets.py Outdated Show resolved Hide resolved
@@ -172,6 +172,14 @@ def __call__(
else:
return self._label

def __repr__(self):
Copy link
Member

Choose a reason for hiding this comment

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

This looks great:)

@davidberenstein1957
Copy link
Member

Also, perhaps the __repr__ of TokenClassificationRecord, TextClassificationRecord, and Text2TexClassificationRecord can be limited a bit by cutting the str of text and the tokens

@davidberenstein1957
Copy link
Member

Thanks for the great work @Ankush-Chander 👍

Copy link
Member

@frascuchon frascuchon left a comment

Choose a reason for hiding this comment

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

Nice work !! Thanks @Ankush-Chander

@davidberenstein1957 davidberenstein1957 merged commit f52b49c into argilla-io:develop Jan 30, 2023
frascuchon added a commit that referenced this pull request Feb 9, 2023
# Changelog

All notable changes to this project will be documented in this file. See
[standard-version](https://github.com/conventional-changelog/standard-version)
for commit guidelines.

## [1.3.0](v1.2.1...v1.3.0)
(2023-02-09)


### Features

* better log error handling
([#2245](#2245))
([66e5cce](66e5cce)),
closes [#2005](#2005)
* Change view mode order in sidebar
([#2215](#2215))
([dff1ea1](dff1ea1)),
closes [#2214](#2214)
* **Client:** Expose keywords dataset metrics
([#2290](#2290))
([a945c5e](a945c5e)),
closes [#2135](#2135)
* **Client:** relax client constraints for rules management
([#2242](#2242))
([6e749b7](6e749b7)),
closes [#2048](#2048)
* Create a multiple contextual help component
([#2255](#2255))
([a35fae2](a35fae2)),
closes [#1926](#1926)
* Include record event_timestamp
([#2156](#2156))
([3992b8f](3992b8f)),
closes [#1911](#1911)
* updated the `prepare_for_training` methods
([#2225](#2225))
([e53c201](e53c201)),
closes [#2154](#2154)
[#2132](#2132)
[#2122](#2122)
[#2045](#2045)
[#1697](#1697)


### Bug Fixes

* **Client:** formatting caused offset in prediction
([#2241](#2241))
([d65db5a](d65db5a))
* **Client:** Log remaining data when shutdown the dataset consumer
([#2269](#2269))
([d78963e](d78963e)),
closes [#2189](#2189)
* validate predictions fails on text2text
([#2271](#2271))
([f68856e](f68856e)),
closes [#2252](#2252)


### Visual enhancements

* Fine tune menu record card
([#2240](#2240))
([62148e5](62148e5)),
closes [#2224](#2224)
* Rely on box-shadow to provide the secondary underline
([#2283](#2283))
([d786171](d786171)),
closes [#2282](#2282)
[#2282](#2282)


### Documentation

* Add deploy on Spaces buttons
([#2293](#2293))
([60164a0](60164a0))
* fix typo in documentation
([#2296](#2296))
([ab8e85e](ab8e85e))
* Improve deployment and quickstart docs and tutorials
([#2201](#2201))
([075bf94](075bf94)),
closes [#2162](#2162)
* More spaces! ([#2309](#2309))
([f02eb60](f02eb60))
* Remove cut-off sentence in docs codeblock
([#2287](#2287))
([7e87f20](7e87f20))
* Rephrase `to know more` into `to learn more` in Quickstart login page
([#2305](#2305))
([6082a26](6082a26))
* Replace leftover `rubrix.apikey` with `argilla.apikey`
([#2286](#2286))
([4871127](4871127)),
closes [#2254](#2254)
[#2254](#2254)
* Simplify token attributions code block
([#2322](#2322))
([4cb6ae1](4cb6ae1))
* Tutorial buttons
([#2310](#2310))
([d6e02de](d6e02de))
* Update colab guide
([#2320](#2320))
([e48a7cc](e48a7cc))
* Update HF Spaces creation image
([#2314](#2314))
([e4b2a04](e4b2a04))


## As always, thanks to our amazing contributors!


- add repr method for Rule, Dataset. (#2148) by @Ankush-Chander
- opensearch docker compose file doesn't run (#2228) by @kayvane1
- Docs: fix typo in documentation (#2296) by @anakin87
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

Successfully merging this pull request may close these issues.

feat: add str and __repr__ methods to Argilla classes like Rule and Datasets
4 participants