model_chunking.py 2.18 KB
Newer Older
Luc Yriarte's avatar
Luc Yriarte committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# Copyright 2021 Schlumberger
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

15
from typing import Optional, List
Luc Yriarte's avatar
Luc Yriarte committed
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36

from fastapi import Query


class GetDataParams:
    ''' All parameters to query welllog data. '''

    def __init__(
        self,
        offset: Optional[int] = Query(
            default=None,
            ge=0,
            description='The number of rows that are to be skipped and not included in the result.',
            example=5),
        limit: Optional[int] = Query(
            default=None,
            ge=1,
            description='The maximum number of rows to be returned.',
            example=100),
        curves: Optional[str] = Query(
            default=None,
Jeremie Hallal's avatar
Jeremie Hallal committed
37
            description='Filters curves. List of curves to be returned. The curves are returned in the same order as it is given.',
Luc Yriarte's avatar
Luc Yriarte committed
38
39
40
41
42
43
44
45
46
47
48
49
            example='MD,GR'),
        describe: Optional[bool] = Query(
            default=False,
            description='The "describe" query option allows clients to request a description of the matching result. '
            '(number of rows, columns name)',
            example='false'),
    ) -> None:
        self.offset = offset
        self.limit = limit
        self.curves = curves
        self.describe = describe
        # orient if json ?
50
51
52
53

    def get_curves_list(self) -> List[str]:
        """parse the curves query parameter and return the list of requested curves"""
        if self.curves:
Jeremie Hallal's avatar
Jeremie Hallal committed
54
            # split and remove emty
55
56
57
58
            curves = list(filter(None, map(str.strip, self.curves.split(','))))
            # remove duplicates but maintain order
            return list(dict.fromkeys(curves))
        return []