Skip to content

Project Version module

Queries

Set of ProjectVersion queries.

Source code in kili/entrypoints/queries/project_version/__init__.py
class QueriesProjectVersion(BaseOperationEntrypointMixin):
    """Set of ProjectVersion queries."""

    # pylint: disable=too-many-arguments

    @overload
    def project_version(
        self,
        project_id: str,
        first: Optional[int] = None,
        skip: int = 0,
        fields: ListOrTuple[str] = ("createdAt", "id", "content", "name", "projectId"),
        disable_tqdm: Optional[bool] = None,
        *,
        as_generator: Literal[True],
    ) -> Generator[Dict, None, None]: ...

    @overload
    def project_version(
        self,
        project_id: str,
        first: Optional[int] = None,
        skip: int = 0,
        fields: ListOrTuple[str] = ("createdAt", "id", "content", "name", "projectId"),
        disable_tqdm: Optional[bool] = None,
        *,
        as_generator: Literal[False] = False,
    ) -> List[Dict]: ...

    @typechecked
    def project_version(
        self,
        project_id: str,
        first: Optional[int] = None,
        skip: int = 0,
        fields: ListOrTuple[str] = ("createdAt", "id", "content", "name", "projectId"),
        disable_tqdm: Optional[bool] = None,
        *,
        as_generator: bool = False,
    ) -> Iterable[Dict]:
        """Get a generator or a list of project versions respecting a set of criteria.

        Args:
            project_id: Filter on Id of project
            fields: All the fields to request among the possible fields for the project versions
                See [the documentation](https://docs.kili-technology.com/reference/graphql-api#projectVersions) # pylint:disable=line-too-long
                  for all possible fields.
            first: Number of project versions to query
            skip: Number of project versions to skip (they are ordered by their date
                of creation, first to last).
            disable_tqdm: If `True`, the progress bar will be disabled
            as_generator: If `True`, a generator on the project versions is returned.

        Returns:
            An iterable of dictionaries containing the project versions information.
        """
        where = ProjectVersionWhere(
            project_id=project_id,
        )
        disable_tqdm = disable_tqdm_if_as_generator(as_generator, disable_tqdm)
        options = QueryOptions(disable_tqdm, first, skip)
        project_versions_gen = ProjectVersionQuery(self.graphql_client, self.http_client)(
            where, fields, options
        )

        if as_generator:
            return project_versions_gen
        return list(project_versions_gen)

    @typechecked
    def count_project_versions(self, project_id: str) -> int:
        """Count the number of project versions.

        Args:
            project_id: Filter on ID of project

        Returns:
            The number of project versions with the parameters provided
        """
        where = ProjectVersionWhere(
            project_id=project_id,
        )
        return ProjectVersionQuery(self.graphql_client, self.http_client).count(where)

count_project_versions(self, project_id)

Count the number of project versions.

Parameters:

Name Type Description Default
project_id str

Filter on ID of project

required

Returns:

Type Description
int

The number of project versions with the parameters provided

Source code in kili/entrypoints/queries/project_version/__init__.py
@typechecked
def count_project_versions(self, project_id: str) -> int:
    """Count the number of project versions.

    Args:
        project_id: Filter on ID of project

    Returns:
        The number of project versions with the parameters provided
    """
    where = ProjectVersionWhere(
        project_id=project_id,
    )
    return ProjectVersionQuery(self.graphql_client, self.http_client).count(where)

project_version(self, project_id, first=None, skip=0, fields=('createdAt', 'id', 'content', 'name', 'projectId'), disable_tqdm=None, *, as_generator=False)

Get a generator or a list of project versions respecting a set of criteria.

Parameters:

Name Type Description Default
project_id str

Filter on Id of project

required
fields Union[List[str], Tuple[str, ...]]

All the fields to request among the possible fields for the project versions See the documentation # pylint:disable=line-too-long for all possible fields.

('createdAt', 'id', 'content', 'name', 'projectId')
first Optional[int]

Number of project versions to query

None
skip int

Number of project versions to skip (they are ordered by their date of creation, first to last).

0
disable_tqdm Optional[bool]

If True, the progress bar will be disabled

None
as_generator bool

If True, a generator on the project versions is returned.

False

Returns:

Type Description
Iterable[Dict]

An iterable of dictionaries containing the project versions information.

Source code in kili/entrypoints/queries/project_version/__init__.py
@typechecked
def project_version(
    self,
    project_id: str,
    first: Optional[int] = None,
    skip: int = 0,
    fields: ListOrTuple[str] = ("createdAt", "id", "content", "name", "projectId"),
    disable_tqdm: Optional[bool] = None,
    *,
    as_generator: bool = False,
) -> Iterable[Dict]:
    """Get a generator or a list of project versions respecting a set of criteria.

    Args:
        project_id: Filter on Id of project
        fields: All the fields to request among the possible fields for the project versions
            See [the documentation](https://docs.kili-technology.com/reference/graphql-api#projectVersions) # pylint:disable=line-too-long
              for all possible fields.
        first: Number of project versions to query
        skip: Number of project versions to skip (they are ordered by their date
            of creation, first to last).
        disable_tqdm: If `True`, the progress bar will be disabled
        as_generator: If `True`, a generator on the project versions is returned.

    Returns:
        An iterable of dictionaries containing the project versions information.
    """
    where = ProjectVersionWhere(
        project_id=project_id,
    )
    disable_tqdm = disable_tqdm_if_as_generator(as_generator, disable_tqdm)
    options = QueryOptions(disable_tqdm, first, skip)
    project_versions_gen = ProjectVersionQuery(self.graphql_client, self.http_client)(
        where, fields, options
    )

    if as_generator:
        return project_versions_gen
    return list(project_versions_gen)

Mutations

Set of ProjectVersion mutations.

Source code in kili/entrypoints/mutations/project_version/__init__.py
class MutationsProjectVersion(BaseOperationEntrypointMixin):
    """Set of ProjectVersion mutations."""

    graphql_client: GraphQLClient

    @typechecked
    def update_properties_in_project_version(
        self, project_version_id: str, content: Optional[str]
    ) -> Dict:
        """Update properties of a project version.

        Args:
            project_version_id: Identifier of the project version
            content: Link to download the project version

        Returns:
            A dictionary containing the updated project version.

        Examples:
            >>> kili.update_properties_in_project_version(
                    project_version_id=project_version_id,
                    content='test'
                )
        """
        variables = {
            "content": content,
            "id": project_version_id,
        }
        result = self.graphql_client.execute(GQL_UPDATE_PROPERTIES_IN_PROJECT_VERSION, variables)
        return self.format_result("data", result)

update_properties_in_project_version(self, project_version_id, content)

Update properties of a project version.

Parameters:

Name Type Description Default
project_version_id str

Identifier of the project version

required
content Optional[str]

Link to download the project version

required

Returns:

Type Description
Dict

A dictionary containing the updated project version.

Examples:

>>> kili.update_properties_in_project_version(
        project_version_id=project_version_id,
        content='test'
    )
Source code in kili/entrypoints/mutations/project_version/__init__.py
@typechecked
def update_properties_in_project_version(
    self, project_version_id: str, content: Optional[str]
) -> Dict:
    """Update properties of a project version.

    Args:
        project_version_id: Identifier of the project version
        content: Link to download the project version

    Returns:
        A dictionary containing the updated project version.

    Examples:
        >>> kili.update_properties_in_project_version(
                project_version_id=project_version_id,
                content='test'
            )
    """
    variables = {
        "content": content,
        "id": project_version_id,
    }
    result = self.graphql_client.execute(GQL_UPDATE_PROPERTIES_IN_PROJECT_VERSION, variables)
    return self.format_result("data", result)