Skip to content

Commit

Permalink
fix: Encode rule name in Weak Labeling API requests (#1649)
Browse files Browse the repository at this point in the history
This PR encodes the rule name to avoid errors in the API request

Closes #1645
  • Loading branch information
leiyre committed Jul 28, 2022
1 parent 3cb4c07 commit 4634df8
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions frontend/models/TextClassification.js
Expand Up @@ -153,7 +153,9 @@ class TextClassificationDataset extends ObservationDataset {

async _getRule({ query }) {
const { response } = await TextClassificationDataset.api().get(
`/datasets/${this.task}/${this.name}/labeling/rules/${query}`,
`/datasets/${this.task}/${this.name}/labeling/rules/${encodeURIComponent(
query
)}`,
{
// Ignore errors related to rule not found
validateStatus: function (status) {
Expand All @@ -169,7 +171,9 @@ class TextClassificationDataset extends ObservationDataset {

async _deleteRule({ query }) {
const { response } = await TextClassificationDataset.api().delete(
`/datasets/${this.task}/${this.name}/labeling/rules/${query}`
`/datasets/${this.task}/${this.name}/labeling/rules/${encodeURIComponent(
query
)}`
);
return response.data;
}
Expand Down Expand Up @@ -234,7 +238,9 @@ class TextClassificationDataset extends ObservationDataset {
);
if (response.status === 409) {
const apiResult = await TextClassificationDataset.api().patch(
`/datasets/${this.task}/${this.name}/labeling/rules/${query}`,
`/datasets/${this.task}/${
this.name
}/labeling/rules/${encodeURIComponent(query)}`,
{ labels, description }
);
response = apiResult.response;
Expand All @@ -244,7 +250,9 @@ class TextClassificationDataset extends ObservationDataset {
}

async _fetchRuleMetrics({ query, labels }) {
var url = `/datasets/${this.task}/${this.name}/labeling/rules/${query}/metrics`;
var url = `/datasets/${this.task}/${
this.name
}/labeling/rules/${encodeURIComponent(query)}/metrics`;
if (labels !== undefined) {
const urlLabels = labels.map((label) => `label=${label}`);
url += `?${urlLabels.join("&")}`;
Expand Down

0 comments on commit 4634df8

Please sign in to comment.