Skip to content
Snippets Groups Projects
Commit 980cf5b2 authored by ml bonhomme's avatar ml bonhomme :bee: Committed by Erwan Rouchet
Browse files

Update s3 URLs doc for ModelVersion endpoints

parent ca785670
No related branches found
No related tags found
1 merge request!2092Update s3 URLs doc for ModelVersion endpoints
......@@ -41,16 +41,14 @@ from arkindex.users.utils import get_max_level
description=(
'List available versions of a Machine Learning model.\n\n'
'Requires a **guest** access to the model, for versions that are available and have a tag,'
'and a **contributor** access otherwise.\n'
'`s3_put_url` is always set to null, `s3_url` is set for **contributors** on available models.'
'and a **contributor** access otherwise.'
),
),
post=extend_schema(
operation_id='CreateModelVersion',
description=(
'Create a new version for a Machine Learning model.\n'
'`s3_put_url` is always set to null, `s3_url` is set for users with a **contributor** access level.'
'The response includes an S3 URL that you can use to upload the archive containing the model.\n'
'Create a new version for a Machine Learning model.\n\n'
'The response includes an S3 URL that you can use to upload the archive containing the model.\n\n'
'Once the archive is successfully uploaded, you can set the size and hash attributes using '
'`PartialUpdateModelVersion`. The state of the model version will then be updated from `created` '
'to `available`, meaning it can be used in a process.\n\n'
......@@ -127,7 +125,6 @@ class ModelVersionsRetrieve(TrainingModelMixin, RetrieveUpdateDestroyAPIView):
Requires a **guest** access to the model, for versions that are available and have a tag,
and a **contributor** access otherwise.
`s3_url` and `s3_put_url` fields are only set for users with a **contributor** access level.
"""
permission_classes = (IsVerified, )
serializer_class = ModelVersionSerializer
......
......@@ -117,8 +117,8 @@ class ModelVersionSerializer(serializers.ModelSerializer):
configuration = serializers.JSONField(required=False, decoder=None, encoder=None, style={'base_template': 'textarea.html'})
tag = serializers.CharField(allow_null=True, max_length=50, required=False, default=None)
state = EnumField(ModelVersionState, read_only=True)
s3_url = serializers.SerializerMethodField(read_only=True)
s3_put_url = serializers.SerializerMethodField(read_only=True)
s3_url = serializers.SerializerMethodField(read_only=True, help_text='Only returned if the user has **contributor** access to the model, and the model is available.')
s3_put_url = serializers.SerializerMethodField(read_only=True, help_text='Only returned if the user has **contributor** access to the model, and the model is **not** available.')
class Meta:
model = ModelVersion
......@@ -152,7 +152,6 @@ class ModelVersionSerializer(serializers.ModelSerializer):
@extend_schema_field(serializers.CharField(allow_null=True))
def get_s3_url(self, obj):
# Only display s3_url to contributors, when the state is `Available`
if not self.context.get('is_contributor') or obj.state != ModelVersionState.Available:
return None
return obj.s3_url
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment