Skip to content
This repository has been archived by the owner on Nov 1, 2024. It is now read-only.

Make dynascore metric weights settable in task owner interface #763

Closed

Conversation

kokrui
Copy link
Contributor

@kokrui kokrui commented Oct 7, 2021

Created a draft PR first because I'm sort of at a crossroads and wanted to get some opinions on a few things @douwekiela @TristanThrush . A big part of my approach for this PR was to try introduce the functionality while ensuring that this change introduced 0 extra effort to the process of adding new metrics (since ease of adding metrics was mentioned as a strength in the Dynaboard paper).

I suppose if one were to ignore that the simplest implementation would be to add 5 columns in task, 1 for each existing metric, ala the Score model. But what I tried to do (and what you can see on this PR so far) was to implement a DefaultMetricWeight model that shares a many-to-one relationship with Task. Would appreciate your thoughts on what I've got so far - is it too clunky/over-engineered?

I was thinking that if a long-term goal was to modularise metrics (since we're planning to modularise Aggregated Metrics anyways as per #761) and create a TaskMetric model or something (where as a corollary a task owner can perhaps customise what metrics they want to be considered at all per round, rather than having to manually set the weights of a hypothetically far larger N possible metrics to 0), I might as well try to jump straight to that instead of having this DefaultMetricWeight model.

Thanks in advance for the help and hope this makes sense - in the meantime I'll work on the frontend interface + other issues.

@kokrui kokrui linked an issue Oct 7, 2021 that may be closed by this pull request
Comment on lines 426 to 428
default_metric_weights = db.orm.relationship(
"DefaultMetricWeight", backref="task", lazy="dynamic"
)
Copy link
Contributor Author

@kokrui kokrui Oct 7, 2021

Choose a reason for hiding this comment

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

just curious - is there a reason why we don't use orm.relationships to allow parents to access their children in a one-to-many/many-to-many relationship?

eg.

dm = DatasetModel()
dataset_list = []
datasets = dm.getByTid(tid)

def getByTid(self, task_id):
try:
return self.dbs.query(Dataset).filter(Dataset.tid == task_id).all()

in contrast to the examples in sqlalchemy's relationship documentation (which I temporarily implemented here as an example, and allows one to access the default_metric_weights of a specific task using some_task.default_metric_weights

tried to look up performance differences but couldn't find anything, so thought I'd ask

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not aware of a good reason for this. We could ask Douwe when he gets back.

@kokrui
Copy link
Contributor Author

kokrui commented Oct 7, 2021

tl;dr for the word vomit above - in my head the options to implement the feature are:

  • just add 5 columns to Task (1 per metric)
  • have a DefaultMetricWeight class to store default_weights (which is what I have now, and works)
  • expand this into something larger, skip the DefaultMetricWeight and just go straight for a TaskMetric class (which would contain type + weight + round + task) (anything else?)

and not sure which one you'd prefer I go with. I'm thinking 2 or 3

@TristanThrush
Copy link
Contributor

tl;dr for the word vomit above - in my head the options to implement the feature are:

  • just add 5 columns to Task (1 per metric)
  • have a DefaultMetricWeight class to store default_weights (which is what I have now, and works)
  • expand this into something larger, skip the DefaultMetricWeight and just go straight for a TaskMetric class (which would contain type + weight + round + task) (anything else?)

and not sure which one you'd prefer I go with. I'm thinking 2 or 3

I think that it could make most sense to implement this feature in two steps:

-Enable to task owner to modify the aggregation metric part of the annotation config whenever they want (the thing at e.g., task-owner-interface/nli#advanced).
-Store the weights in the constructor_args for the dynascore.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 13, 2021
@kokrui kokrui closed this Oct 14, 2021
@kokrui kokrui force-pushed the task_owner_set_default_weights branch from 2ae914e to 79981d5 Compare October 14, 2021 07:32
@kokrui kokrui reopened this Oct 14, 2021
@kokrui kokrui changed the title Make dynascore metric/dataset weights settable in task owner interface Make dynascore metric weights settable in task owner interface Oct 18, 2021
@kokrui kokrui marked this pull request as ready for review October 18, 2021 18:07
@kokrui
Copy link
Contributor Author

kokrui commented Oct 18, 2021

This PR allows the dynascore aggregation metric to have settable weights for its subsidiary metrics.

set_default_weight

Known issue: the Task Configuration UI element above the Edit Task Configuration card requires a reload for the annotation_config_json to be updated. Not sure how I should go about doing that (if it needs to be done).

bug

I'll implement dataset weight setter in a separate PR or later here once any kinks have been worked out for the metric weight setter

Copy link
Contributor

@TristanThrush TristanThrush left a comment

Choose a reason for hiding this comment

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

This PR is looking great! But I think that a decent amount of the affected code will change when we modularize the aggregation_metric code. Let's just make this PR as basic as possible, for now. Instead of adding a new UI component for the aggregation_metric, we could just make the annotation_config_json editable, and return an error message if someone tries to modify anything besides the aggregation_metric. Does that sound ok? Also, I left a comment below. Thanks!

@@ -417,6 +417,52 @@ def update(credentials, tid):
return util.json_encode({"success": "ok"})


@bottle.put("/tasks/update_annotation_config/<tid:int>")
@_auth.requires_auth
def update_annotation_config(credentials, tid):
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this would be more scalable if we just allowed the user to update the object with the field "aggregation_metric" in annotation_config_json. So you don't need to do anything here with metric_default_weights or aggregation_metric type. Before saving the update, we could still check to make sure it's valid with "verify_annotation_config".

@kokrui
Copy link
Contributor Author

kokrui commented Nov 15, 2021

replaced by #825

@kokrui kokrui closed this Nov 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make dynascore weights settable in task owner interface
3 participants