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

Use both valueType text and url in labeling interface #6580

Open
DrissiReda opened this issue Oct 30, 2024 · 7 comments
Open

Use both valueType text and url in labeling interface #6580

DrissiReda opened this issue Oct 30, 2024 · 7 comments

Comments

@DrissiReda
Copy link

I'm trying to support both valueTypes for my labeling interface since I'm receiving tasks that can either be an s3 path to a text file, or just text. so my tasks will look like this:

{
    "data": {
      "text_url": "s3://textfiles/file.txt"
    }
}

Or this:

{
    "data": {
      "text": "This is some inline text, do not worry"
    }
}

Here is my labeling interface:

<View>
  <Labels name="label" toName="text">
    <Label value="PER" background="red"/>
    <Label value="ORG" background="darkorange"/>
    <Label value="LOC" background="orange"/>
    <Label value="MISC" background="green"/>
  </Labels>

  <Text name="text_url" value="$text_url" valueType="url" granularity="word"/>
  <Text name="text" value="$text" granularity="word"/>
</View>

This works correctly for the text_url task files. But displays URL() not valid for text task files. Which means it doesn't find text_url field in my task.json and either passes an empty string or "None" or something like that and interprets it as a wrong URL.

Is it possible to either check for which field is present and go with that? Or just ignore text_url if it's not valid? Even though the second option will prevent me from seeing any relevant errors linked to a genuinely invalid URL.

@heidi-humansignal
Copy link
Collaborator

Hello,

You probably have to preprocessing your task data so that all tasks use the same data field or you can have some sort of value in text_url field. It be just python script that will fill out the fields as necessary before importing them into LS

Thank you,
Abu

Comment by Abubakar Saad
Workflow Run

@DrissiReda
Copy link
Author

Thanks, however on the UI I have this text: "To select which field(s) to label you need to upload the data. Alternatively, you can provide it using Code mode." This leads me to think I can use multiple fields. Isn't it possible to just ignore the url error? I want to avoid preprocessing for this. Since it involves creating an endpoint accessible by my label studio container which returns 200 and an empty body every time.

@heidi-humansignal
Copy link
Collaborator

You could use multliple fields, but the data should be presented in Labeling template. For example, based on the option you choose in choices, you can have other options become available. You can checkout conditional template in playground. As long as you include both of values in the json and can set one of them blank:

{ "data": { "text": "This is some inline text, do not worry", "text_url": "" }}

This will work. But if one of the value is missing, it should throw an error.

Thank you,
Abu

Comment by Abubakar Saad
Workflow Run

@DrissiReda
Copy link
Author

This doesn't work, I get URL is invalid. If I insert a non valid URL(aka empty string). I get NetworkError, could not fetch resource.

@heidi-humansignal
Copy link
Collaborator

That seems like a issue. Would it be possible to try something like this:

{ "data": { "text": "This is some inline text", "text_url": "about:blank" } }

Providing about:blank as a default URL prevents the "URL is invalid" error because it's a valid URL that results in a blank page.

The only thing I would say, its having some default url or doing a preprocessing of the data.

Thank you,
Abu

Comment by Abubakar Saad
Workflow Run

@DrissiReda
Copy link
Author

That seems like a issue. Would it be possible to try something like this:

{ "data": { "text": "This is some inline text", "text_url": "about:blank" } }

Providing about:blank as a default URL prevents the "URL is invalid" error because it's a valid URL that results in a blank page.

Great idea, however unfortunately I'm getting an invalid error: URL(about:blank) is not valid.
What would be the intended behavior? Or is this something that requires a PR?

@heidi-humansignal
Copy link
Collaborator

Yes, it seems we are going to need a PR for this. Another solution to be a test file in the storage and just link that as url. Its happening because there is validation logic that checks to make sure its proper url.

Thank you,
Abu

Comment by Abubakar Saad
Workflow Run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants