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

Chore/rename task fields #994

Merged
merged 9 commits into from
Jul 17, 2024
Merged

Conversation

luisaadanttas
Copy link
Contributor

This pull request addresses issue #938

Signed-off-by: luisaadanttas <maria.luisa.dantas@ccc.ufcg.edu.br>
Signed-off-by: luisaadanttas <maria.luisa.dantas@ccc.ufcg.edu.br>
Signed-off-by: luisaadanttas <maria.luisa.dantas@ccc.ufcg.edu.br>
@yoavkatz
Copy link
Member

yoavkatz commented Jul 8, 2024

Thanks for your contribution Maria! The changes look right. However, the proposed change is not backward compatible (require changes to user code). Since we don't want to make abrupt changes, we should keep the original fields in Task , but add them as deprecated. Then we should check in the Task. prepare() that either the old fields or new fields are set (but not both). It's good that you changed all the existing documentation and examples, so people will follow the new approach from now on. Finally, we should add one test that uses the old fields and see it continues works.

Do you think you can proceed with these changes.

@luisaadanttas
Copy link
Contributor Author

Yes, that makes a lot of sense. Thank you!

I can implement those changes :)

@elronbandel
Copy link
Member

@luisaadanttas thanks again! notice you mark the old fields with DeprectedField.
See this example for reference:

use_query: bool = DeprecatedField(

…d for compatibility

Signed-off-by: luisaadanttas <maria.luisa.dantas@ccc.ufcg.edu.br>
…in Task

Signed-off-by: luisaadanttas <maria.luisa.dantas@ccc.ufcg.edu.br>
metrics: List[str]
prediction_type: Optional[str] = None
augmentable_inputs: List[str] = []
defaults: Optional[Dict[str, Any]] = None

def prepare(self):
super().prepare()
if (self.input_fields is not None and self.reference_fields is not None) and (
Copy link
Member

@yoavkatz yoavkatz Jul 15, 2024

Choose a reason for hiding this comment

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

I suggest separating into two checks, because people can mix only one pair of fields.

if (self.input_fields is not None and self.inputs is not None):
aise ValueError(
"Conflicting attributes: 'input_fields' cannot be set simultaneously with 'inputs'. Use only 'input_fields'"
)

if (self.output_fields is not None and self.reference_fields is not None):
aise ValueError(
"Conflicting attributes: 'reference_fields' cannot be set simultaneously with 'output'. Use only 'reference_fields'"
)

Copy link
Member

@yoavkatz yoavkatz left a comment

Choose a reason for hiding this comment

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

Thanks for making the changes. I added two minor comments regarding error checking - and then I think we are good to merge.

Signed-off-by: luisaadanttas <maria.luisa.dantas@ccc.ufcg.edu.br>
Signed-off-by: luisaadanttas <maria.luisa.dantas@ccc.ufcg.edu.br>
@luisaadanttas
Copy link
Contributor Author

Thanks for making the changes. I added two minor comments regarding error checking - and then I think we are good to merge.

Thanks for your review and suggestions! I've incorporated your feedback on the field checks and updated the tests accordingly :)

@yoavkatz
Copy link
Member

yoavkatz commented Jul 16, 2024

Thanks for making the changes. I approved it, but the check failed.

{'file': '/home/runner/work/unitxt/unitxt/src/unitxt/catalog/cards/atta_q.json', 'diff': 'diff'}
{'file': '/home/runner/work/unitxt/unitxt/src/unitxt/catalog/cards/attaq_500.json', 'diff': 'diff'}
{'file': '/home/runner/work/unitxt/unitxt/src/unitxt/catalog/cards/bold.json', 'diff': 'diff'}

The prepare/attaq_.py has

task=Task(
    inputs=["input"], outputs=["input_label"], metrics=["metrics.safety_metric"]
),

https://github.com/luisaadanttas/unitxt/blob/chore/rename-task-fields/prepare/cards/atta_q.py
These should be replaced to the new field names (in the 3 files).

Then you need to run:

utils/prepare_all_artifacts.py to update the json files.

Signed-off-by: luisaadanttas <maria.luisa.dantas@ccc.ufcg.edu.br>
@yoavkatz yoavkatz enabled auto-merge (squash) July 17, 2024 06:18
@yoavkatz yoavkatz merged commit 40d0a96 into IBM:main Jul 17, 2024
8 checks passed
@yoavkatz
Copy link
Member

Changes are merged.

Thank you Maria for your contribution!

csrajmohan pushed a commit that referenced this pull request Aug 29, 2024
* chore: Rename Task inputs and outputs fields

Signed-off-by: luisaadanttas <maria.luisa.dantas@ccc.ufcg.edu.br>

* docs: Rename Task inputs and outputs fields

Signed-off-by: luisaadanttas <maria.luisa.dantas@ccc.ufcg.edu.br>

* chore: update remaining input_fields and reference_fields in Tasks

Signed-off-by: luisaadanttas <maria.luisa.dantas@ccc.ufcg.edu.br>

* refactor: handle deprecated input/output fields and add prepare method for compatibility

Signed-off-by: luisaadanttas <maria.luisa.dantas@ccc.ufcg.edu.br>

* test: add tests for deprecated inputs/outputs and conflicting fields in Task

Signed-off-by: luisaadanttas <maria.luisa.dantas@ccc.ufcg.edu.br>

* test: update tests for task initialization with detailed field checks

Signed-off-by: luisaadanttas <maria.luisa.dantas@ccc.ufcg.edu.br>

* refactor: separate checks for input_fields and reference_fields

Signed-off-by: luisaadanttas <maria.luisa.dantas@ccc.ufcg.edu.br>

* fix:update field names in atta_q, attaq_500, and bold cards

Signed-off-by: luisaadanttas <maria.luisa.dantas@ccc.ufcg.edu.br>

---------

Signed-off-by: luisaadanttas <maria.luisa.dantas@ccc.ufcg.edu.br>
Co-authored-by: Yoav Katz <68273864+yoavkatz@users.noreply.github.com>
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.

3 participants