Skip to content

ComboBoxEntry

ComboBoxEntry

Bases: BaseClassWithFieldData

ComboBoxEntries represent the available options in a list field

Attributes:

Name Type Description
id str

id of the column

name str

name of the column

files List[File]

List of files belonging to this comboboxentry. See File for more information.

fielddata List[FieldData]

List of field data belonging to this comboboxentry. See FieldData for more information.

_fetched bool

This is a Boolean attribute indicating whether all attributes have been retrieved from the server or only the name and ID are present.

Source code in furthrmind\collection\comboboxentry.py
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
class ComboBoxEntry(BaseClassWithFieldData):
    """
    ComboBoxEntries represent the available options in a list field

    Attributes
    ----------
    id : str
        id of the column
    name : str
        name of the column
    files : List[File]
        List of files belonging to this comboboxentry. See [File](file.md) for more information.
    fielddata : List[FieldData]
        List of field data belonging to this comboboxentry. See [FieldData](fielddata.md) for more information.
    _fetched : bool
        This is a Boolean attribute indicating whether all attributes have been retrieved from the server or only
        the name and ID are present.
    """

    id = ""
    name = ""
    files: List["File"] = []
    fielddata: List["FieldData"] = []

    _attr_definition = {
        "files": {"class": "File"},
        "fielddata": {"class": "FieldData"}
    }

    def __init__(self, id=None, data=None):
        super().__init__(id, data)

    def _get_url_instance(self, project_id=None):
        project_url = ComboBoxEntry.fm.get_project_url(project_id)
        url = f"{project_url}/comboboxentry/{self.id}"
        return url

    @classmethod
    def _get_url_class(cls, id, project_id=None):
        project_url = cls.fm.get_project_url(project_id)
        url = f"{project_url}/comboboxentry/{id}"
        return url

    @classmethod
    def _get_all_url(cls, project_id=None):
        project_url = cls.fm.get_project_url(project_id)
        url = f"{project_url}/comboboxentry"
        return url

    @classmethod
    def _post_url(cls, project_id=None):
        project_url = cls.fm.get_project_url(project_id)
        url = f"{project_url}/comboboxentry"
        return url

    @classmethod
    def get(cls, id: str = "", project_id: str = "") -> Self:
        """
        Method to get one combobox entry
        If called on an instance of the class, the id of the instance is used

        Parameters
        ----------
        id : str
            id of the requested comboboxentry
        project_id : str
            Optionally, to get a comboboxentry from another project as the furthrmind sdk was initiated with

        Returns
        -------
        Self
            Instance of the ComboBoxEntry class

        Raises
        ------
        AssertionError
            If used as class method and id not specified

        """

        if isclass(cls):
            assert id, "id must be specified"

        return cls._get(id, project_id=project_id)

    # noinspection PyMethodOverriding
    @classmethod
    def get_many(cls, ids: List[str] = (), project_id: str = "") -> List[Self]:
        """
        This method is a class method that retrieves multiple comboboxentries belonging to one project.

        Parameters
        ----------
        ids : List[str]
            List with ids.

        project_id : str, optional
            Optionally to get comboboxentries from another project as the furthrmind sdk was initiated with,
            defaults to an empty string.

        Returns
        -------
        List[Self]
            List with instances of experiment class.

        Raises
        ------
        AssertError
            If `ids` list is empty.

        """

        assert ids, "ids must be specified"
        return cls._get_many(ids, project_id=project_id)

    @classmethod
    def get_all(cls, project_id: str = "") -> List[Self]:
        """
        Method to get all comboboxentries belonging to one project.

        Parameters
        ----------
        project_id : str, optional
            Optionally to get comboboxentries from another project as the furthrmind sdk was initiated with

        Returns
        -------
        List[Self]
            A list containing instances of the comboboxentry class.
        """

        return cls._get_all(project_id=project_id)

    @classmethod
    @BaseClass._create_instances_decorator(_fetched=False)
    def create(cls, name: str, field_name: str = "", field_id: str = "", project_id: str = "") -> Self:
        """
        Method to create a new combobox entry

        Parameters
        ----------
        name: str
            Name of the combobox entry.
        field_name: str, optional
            Name of the field where the combobox entry should belong to. Either the field name or id must be provided.
        field_id: str, optional
            Id of the field where the combobox entry should belong to. Either the field name or id must be provided.
        project_id: str, optional
            Id of the project where the combobox entry should be created. This is only required if the combobox entry needs to
            be created in a different project than the one the SDK was initiated with.

        Returns
        -------
        Self
            Instance of the column comboboxentry class.

        Raises
        ------
        ValueError
            If the name is not specified.
        ValueError
            If neither field_name nor field_id is provided.
        ValueError
            If the field with the given name is not found.
        """

        from furthrmind.collection.field import Field

        if not name:
            raise ValueError("Name must be specified")
        if not field_name and not field_id:
            raise ValueError("Either field_name or field_id must be provided")

        if field_name:
            fields = Field._get_all(project_id)
            for field in fields:
                if field.name.lower() == field_name.lower():
                    field_id = field.id
                    break

            if not field_id:
                raise ValueError("Field with given name not found")

        data = {"name": name, "field": {"id": field_id}}
        id = cls._post(data, project_id)
        data["id"] = id
        return data

    @classmethod
    @BaseClass._create_instances_decorator(_fetched=False)
    def create_many(cls, data_list: List[Dict], project_id: str = "") -> List[Self]:
        """
        Method to create many new combobox entries

        Parameters
        ----------
        data_list : List[Dict]
            List of dictionaries containing the data for creating instances of comboboxentry class. Each dictionary
            should have the following keys:

            - "name" (str): Name of the combobox entry.
            - "field_name" (str, optional): Name of the field where the combobox entry should belong to. Either
                "field_name" or "field_id" must be provided.
            - "field_id" (str, optional): ID of the field where the combobox entry should belong to. Either "field_name"
                or "field_id" must be provided.

        project_id : str, optional
            ID of the project where the combobox entries should be created. If not provided, the items will be created
            in the current project.

        Returns
        -------
        List[Self]
            List of instances of comboboxentry class that were created.

        Raises
        ------
        ValueError
            If any of the following conditions are met:

            - "name" is missing in any of the dictionaries in "data_list".
            - Both "field_name" and "field_id" are missing in any of the dictionaries in "data_list".
            - The provided "field_name" does not match any existing field in the project.

        """

        from furthrmind.collection.field import Field

        look_for_field_ids = False
        for data in data_list:
            if not data.get("name"):
                raise ValueError("Name must be specified")

            if data.get("field_name"):
                look_for_field_ids = True
                break

        if look_for_field_ids:
            fields = Field._get_all(project_id)
            for data in data_list:
                field_name = data.get("field_name")
                field_id = data.get("field_id")
                if not field_name and not field_id:
                    raise ValueError("Either field_name or field_id must be provided")
                if field_name:
                    for field in fields:
                        if field.name.lower() == field_name.lower():
                            field_id = field.id
                            data["field_id"] = field_id
                            break
                        if not data.get("field_id"):
                            raise ValueError(f"Field with given name '{field_name}' not found")

        new_data_list = []
        for data in data_list:
            new_data_list.append({
                "name": data.get("name"),
                "field": {"id": data.get("field_id")}
            })

        id_list = cls._post(new_data_list, project_id, force_list=True)
        for data, id in zip(new_data_list, id_list):
            data["id"] = id

        return new_data_list

add_field(field_name='', field_type='', field_id='', value=None, unit=None, position=None)

Method to add a field to the current item

Parameters:

Name Type Description Default
field_name str

Name of field that should be added. If fieldname provided, also fieldtype must be specified. Either fieldname and fieldtype or field_id must be specified.

''
field_type str

Type of field. Must be one of:

  • Numeric fields: numeric, numeric-field, numeric_field
  • Date fields: date, date_field, date-field, datefield
  • Text fields: singleline, singlelinefield, text, text-field, text_field, textfield
  • List fields: combobox, comboboxfield, list, list-field, list_field, listfield
  • Notebook fields: multiline, notebook, notebookfield, notebook-field, notebook_field
  • Checkbox fields: checkbox, checkbox-field, checkbox_field, checkboxfield
  • Calculation fields: calculation, calculation-field, calculation_field, calculationfield
''
field_id str

Id of field that should be added.

''
value Any

Value of the field. The data type of the value depends on the field_type:

  • Numeric fields: float or int, or a string convertible to a float
  • Date fields: datetime, date object, unix timestamp, or string with iso format
  • Text fields: string
  • List fields: dictionary with id or name as key, or string with name, or string with id
  • Notebook fields: dictionary with content as key, or string
  • Checkbox fields: boolean
None
unit Union[Dict, str]

Dictionary with id or name, or string representing the name, or string representing the id.

None
position int

The position where the field should be added in the card. Starting at "0". Optionally.

None

Returns:

Type Description
FieldData

The new FieldData object that was created.

Source code in furthrmind\collection\baseclass.py
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
def add_field(
    self,
    field_name: str = "",
    field_type: str = "",
    field_id: str = "",
    value: Any = None,
    unit: Union[Dict, str] = None,
    position: int = None,
) -> "FieldData":
    """
    Method to add a field to the current item

    Parameters
    ----------
    field_name : str
        Name of field that should be added. If fieldname provided, also fieldtype must be specified.
        Either fieldname and fieldtype or field_id must be specified.
    field_type : str
        Type of field. Must be one of:

        - Numeric fields: numeric, numeric-field, numeric_field
        - Date fields: date, date_field, date-field, datefield
        - Text fields: singleline, singlelinefield, text, text-field, text_field, textfield
        - List fields: combobox, comboboxfield, list, list-field, list_field, listfield
        - Notebook fields: multiline, notebook, notebookfield, notebook-field, notebook_field
        - Checkbox fields: checkbox, checkbox-field, checkbox_field, checkboxfield
        - Calculation fields: calculation, calculation-field, calculation_field, calculationfield
    field_id : str
        Id of field that should be added.
    value : Any
        Value of the field. The data type of the value depends on the field_type:

        - Numeric fields: float or int, or a string convertible to a float
        - Date fields: datetime, date object, unix timestamp, or string with iso format
        - Text fields: string
        - List fields: dictionary with id or name as key, or string with name, or string with id
        - Notebook fields: dictionary with content as key, or string
        - Checkbox fields: boolean

    unit : Union[Dict, str]
        Dictionary with id or name, or string representing the name, or string representing the id.

    position: int
        The position where the field should be added in the card. Starting at "0". Optionally.

    Returns
    -------
    FieldData
        The new FieldData object that was created.

    """

    from .fielddata import FieldData

    if not self._fetched:
        self._get()

    fielddata = FieldData.create(field_name, field_type, field_id, value, unit)

    new_field_data_list = list(self.fielddata)
    if position is not None:
        assert type(position) is int, "Position must be an integer"
        new_field_data_list.insert(position, fielddata)
    else:
        new_field_data_list.append(fielddata)

    self.fielddata = new_field_data_list

    data = {"id": self.id, "fielddata": [{"id": f.id} for f in self.fielddata]}
    self._post(data)
    return fielddata

add_many_fields(data_list)

Method to add many fields to the current item

Parameters:

Name Type Description Default
data_list List[Dict]

List of dictionaries containing the information about the fields to be added. Each dictionary should have the following keys:

  • field_name: Name of the field to be added. Either field_name and field_type or field_id must be specified.
  • field_type: Type of the field. Must be one of the following:

    • Numeric fields: numeric, numeric-field, numeric_field
    • Date fields: date, date_field, date-field, datefield
    • Text fields: singleline, singlelinefield, text, text-field, text_field, textfield
    • List fields: combobox, comboboxfield, list, list-field, list_field, listfield
    • Notebook fields: multiline, notebook, notebookfield, notebook-field, notebook_field
    • Checkbox fields: checkbox, checkbox-field, checkbox_field, checkboxfield
    • Calculation fields: calculation, calculation-field, calculation_field, calculationfield
  • field_id: ID of the field to be added.

  • value: Value of the field. The required format depends on the field_type:

    • Numeric: float or int, or a string convertible to a float.
    • Date: datetime, date object, Unix timestamp, or string in ISO format.
    • SingleLine: string.
    • ComboBoxEntry: Dictionary with ID or name as key, or string with name, or string with ID.
    • MultiLine: Dictionary with content as key, or string.
    • CheckBox: Boolean.
  • unit: Dictionary with ID or name as key, or string with name, or string with ID.

  • position: int, The position where the field should be added in the card. Starting at "0". Optionally.
required

Returns:

Type Description
List[FieldData]

List of FieldData objects representing the added fields.

Source code in furthrmind\collection\baseclass.py
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
def add_many_fields(self, data_list: List[Dict]) -> List["FieldData"]:
    """
    Method to add many fields to the current item

    Parameters
    ----------
    data_list: List[Dict]
        List of dictionaries containing the information about the fields to be added. Each dictionary should have the following keys:

        - field_name: Name of the field to be added. Either field_name and field_type or field_id must be specified.
        - field_type:
            Type of the field. Must be one of the following:

            - Numeric fields: numeric, numeric-field, numeric_field
            - Date fields: date, date_field, date-field, datefield
            - Text fields: singleline, singlelinefield, text, text-field, text_field, textfield
            - List fields: combobox, comboboxfield, list, list-field, list_field, listfield
            - Notebook fields: multiline, notebook, notebookfield, notebook-field, notebook_field
            - Checkbox fields: checkbox, checkbox-field, checkbox_field, checkboxfield
            - Calculation fields: calculation, calculation-field, calculation_field, calculationfield

        - field_id: ID of the field to be added.
        - value: Value of the field. The required format depends on the field_type:

            - Numeric: float or int, or a string convertible to a float.
            - Date: datetime, date object, Unix timestamp, or string in ISO format.
            - SingleLine: string.
            - ComboBoxEntry: Dictionary with ID or name as key, or string with name, or string with ID.
            - MultiLine: Dictionary with content as key, or string.
            - CheckBox: Boolean.

        - unit: Dictionary with ID or name as key, or string with name, or string with ID.
        - position: int, The position where the field should be added in the card. Starting at "0". Optionally.

    Returns
    -------
    List["FieldData"]
        List of FieldData objects representing the added fields.

    """

    from .fielddata import FieldData

    if not self._fetched:
        self._get()

    fielddata_list = FieldData.create_many(data_list)

    new_field_data_list = list(self.fielddata)
    for fielddata, data in zip(fielddata_list, data_list):
        if "position" in data:
            assert type(data["position"]) is int, "Position must be an integer"
            new_field_data_list.insert(data["position"], fielddata)
        else:
            new_field_data_list.append(fielddata)

    self.fielddata = new_field_data_list

    data = {"id": self.id, "fielddata": [{"id": f.id} for f in self.fielddata]}
    self._post(data)
    return fielddata_list

create(name, field_name='', field_id='', project_id='') classmethod

Method to create a new combobox entry

Parameters:

Name Type Description Default
name str

Name of the combobox entry.

required
field_name str

Name of the field where the combobox entry should belong to. Either the field name or id must be provided.

''
field_id str

Id of the field where the combobox entry should belong to. Either the field name or id must be provided.

''
project_id str

Id of the project where the combobox entry should be created. This is only required if the combobox entry needs to be created in a different project than the one the SDK was initiated with.

''

Returns:

Type Description
Self

Instance of the column comboboxentry class.

Raises:

Type Description
ValueError

If the name is not specified.

ValueError

If neither field_name nor field_id is provided.

ValueError

If the field with the given name is not found.

Source code in furthrmind\collection\comboboxentry.py
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
@classmethod
@BaseClass._create_instances_decorator(_fetched=False)
def create(cls, name: str, field_name: str = "", field_id: str = "", project_id: str = "") -> Self:
    """
    Method to create a new combobox entry

    Parameters
    ----------
    name: str
        Name of the combobox entry.
    field_name: str, optional
        Name of the field where the combobox entry should belong to. Either the field name or id must be provided.
    field_id: str, optional
        Id of the field where the combobox entry should belong to. Either the field name or id must be provided.
    project_id: str, optional
        Id of the project where the combobox entry should be created. This is only required if the combobox entry needs to
        be created in a different project than the one the SDK was initiated with.

    Returns
    -------
    Self
        Instance of the column comboboxentry class.

    Raises
    ------
    ValueError
        If the name is not specified.
    ValueError
        If neither field_name nor field_id is provided.
    ValueError
        If the field with the given name is not found.
    """

    from furthrmind.collection.field import Field

    if not name:
        raise ValueError("Name must be specified")
    if not field_name and not field_id:
        raise ValueError("Either field_name or field_id must be provided")

    if field_name:
        fields = Field._get_all(project_id)
        for field in fields:
            if field.name.lower() == field_name.lower():
                field_id = field.id
                break

        if not field_id:
            raise ValueError("Field with given name not found")

    data = {"name": name, "field": {"id": field_id}}
    id = cls._post(data, project_id)
    data["id"] = id
    return data

create_many(data_list, project_id='') classmethod

Method to create many new combobox entries

Parameters:

Name Type Description Default
data_list List[Dict]

List of dictionaries containing the data for creating instances of comboboxentry class. Each dictionary should have the following keys:

  • "name" (str): Name of the combobox entry.
  • "field_name" (str, optional): Name of the field where the combobox entry should belong to. Either "field_name" or "field_id" must be provided.
  • "field_id" (str, optional): ID of the field where the combobox entry should belong to. Either "field_name" or "field_id" must be provided.
required
project_id str

ID of the project where the combobox entries should be created. If not provided, the items will be created in the current project.

''

Returns:

Type Description
List[Self]

List of instances of comboboxentry class that were created.

Raises:

Type Description
ValueError

If any of the following conditions are met:

  • "name" is missing in any of the dictionaries in "data_list".
  • Both "field_name" and "field_id" are missing in any of the dictionaries in "data_list".
  • The provided "field_name" does not match any existing field in the project.
Source code in furthrmind\collection\comboboxentry.py
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
@classmethod
@BaseClass._create_instances_decorator(_fetched=False)
def create_many(cls, data_list: List[Dict], project_id: str = "") -> List[Self]:
    """
    Method to create many new combobox entries

    Parameters
    ----------
    data_list : List[Dict]
        List of dictionaries containing the data for creating instances of comboboxentry class. Each dictionary
        should have the following keys:

        - "name" (str): Name of the combobox entry.
        - "field_name" (str, optional): Name of the field where the combobox entry should belong to. Either
            "field_name" or "field_id" must be provided.
        - "field_id" (str, optional): ID of the field where the combobox entry should belong to. Either "field_name"
            or "field_id" must be provided.

    project_id : str, optional
        ID of the project where the combobox entries should be created. If not provided, the items will be created
        in the current project.

    Returns
    -------
    List[Self]
        List of instances of comboboxentry class that were created.

    Raises
    ------
    ValueError
        If any of the following conditions are met:

        - "name" is missing in any of the dictionaries in "data_list".
        - Both "field_name" and "field_id" are missing in any of the dictionaries in "data_list".
        - The provided "field_name" does not match any existing field in the project.

    """

    from furthrmind.collection.field import Field

    look_for_field_ids = False
    for data in data_list:
        if not data.get("name"):
            raise ValueError("Name must be specified")

        if data.get("field_name"):
            look_for_field_ids = True
            break

    if look_for_field_ids:
        fields = Field._get_all(project_id)
        for data in data_list:
            field_name = data.get("field_name")
            field_id = data.get("field_id")
            if not field_name and not field_id:
                raise ValueError("Either field_name or field_id must be provided")
            if field_name:
                for field in fields:
                    if field.name.lower() == field_name.lower():
                        field_id = field.id
                        data["field_id"] = field_id
                        break
                    if not data.get("field_id"):
                        raise ValueError(f"Field with given name '{field_name}' not found")

    new_data_list = []
    for data in data_list:
        new_data_list.append({
            "name": data.get("name"),
            "field": {"id": data.get("field_id")}
        })

    id_list = cls._post(new_data_list, project_id, force_list=True)
    for data, id in zip(new_data_list, id_list):
        data["id"] = id

    return new_data_list

delete(id='', project_id='') classmethod

Method to delete an item. Can be called as a classmethod with providing the id to be deleted or on the instance of a class

Parameters:

Name Type Description Default
id str

The id of the resource to delete

''
project_id str

Optionally to delete an item in another project as the furthrmind sdk was initiated with

''

Returns:

Type Description
str

The id of the item

Source code in furthrmind\collection\baseclass.py
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
@classmethod
def delete(cls, id: str = "", project_id: str = "") -> str:
    """
    Method to delete an item. Can be called as a classmethod with providing the id to be deleted or on the instance
    of a class

    Parameters
    ----------
    id : str
        The id of the resource to delete
    project_id : str, optional
        Optionally to delete an item in another project as the furthrmind sdk was initiated with

    Returns
    -------
    str
        The id of the item
    """

    if isclass(cls):
        return cls._delete_class_method(id, project_id)
    else:
        self = cls
        return self._delete_instance_method(project_id)

get(id='', project_id='') classmethod

Method to get one combobox entry If called on an instance of the class, the id of the instance is used

Parameters:

Name Type Description Default
id str

id of the requested comboboxentry

''
project_id str

Optionally, to get a comboboxentry from another project as the furthrmind sdk was initiated with

''

Returns:

Type Description
Self

Instance of the ComboBoxEntry class

Raises:

Type Description
AssertionError

If used as class method and id not specified

Source code in furthrmind\collection\comboboxentry.py
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
@classmethod
def get(cls, id: str = "", project_id: str = "") -> Self:
    """
    Method to get one combobox entry
    If called on an instance of the class, the id of the instance is used

    Parameters
    ----------
    id : str
        id of the requested comboboxentry
    project_id : str
        Optionally, to get a comboboxentry from another project as the furthrmind sdk was initiated with

    Returns
    -------
    Self
        Instance of the ComboBoxEntry class

    Raises
    ------
    AssertionError
        If used as class method and id not specified

    """

    if isclass(cls):
        assert id, "id must be specified"

    return cls._get(id, project_id=project_id)

get_all(project_id='') classmethod

Method to get all comboboxentries belonging to one project.

Parameters:

Name Type Description Default
project_id str

Optionally to get comboboxentries from another project as the furthrmind sdk was initiated with

''

Returns:

Type Description
List[Self]

A list containing instances of the comboboxentry class.

Source code in furthrmind\collection\comboboxentry.py
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
@classmethod
def get_all(cls, project_id: str = "") -> List[Self]:
    """
    Method to get all comboboxentries belonging to one project.

    Parameters
    ----------
    project_id : str, optional
        Optionally to get comboboxentries from another project as the furthrmind sdk was initiated with

    Returns
    -------
    List[Self]
        A list containing instances of the comboboxentry class.
    """

    return cls._get_all(project_id=project_id)

get_many(ids=(), project_id='') classmethod

This method is a class method that retrieves multiple comboboxentries belonging to one project.

Parameters:

Name Type Description Default
ids List[str]

List with ids.

()
project_id str

Optionally to get comboboxentries from another project as the furthrmind sdk was initiated with, defaults to an empty string.

''

Returns:

Type Description
List[Self]

List with instances of experiment class.

Raises:

Type Description
AssertError

If ids list is empty.

Source code in furthrmind\collection\comboboxentry.py
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
@classmethod
def get_many(cls, ids: List[str] = (), project_id: str = "") -> List[Self]:
    """
    This method is a class method that retrieves multiple comboboxentries belonging to one project.

    Parameters
    ----------
    ids : List[str]
        List with ids.

    project_id : str, optional
        Optionally to get comboboxentries from another project as the furthrmind sdk was initiated with,
        defaults to an empty string.

    Returns
    -------
    List[Self]
        List with instances of experiment class.

    Raises
    ------
    AssertError
        If `ids` list is empty.

    """

    assert ids, "ids must be specified"
    return cls._get_many(ids, project_id=project_id)

remove_field(field_name='', field_id='')

Removes a field from the current item.

Parameters:

Name Type Description Default
field_name str

Name of the field that should be removed. Either the field_name or field_id must be specified.

''
field_id str

ID of the field that should be removed.Either the field_name or field_id must be specified.

''

Returns:

Type Description
str

ID of the item after the field is removed.

Raises:

Type Description
ValueError

If no field is found with the given field_name or field_id.

Source code in furthrmind\collection\baseclass.py
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
def remove_field(self, field_name: str = "", field_id: str = ""):
    """
    Removes a field from the current item.

    Parameters
    ----------
    field_name : str, optional
        Name of the field that should be removed. Either the `field_name` or `field_id` must be specified.
    field_id : str, optional
        ID of the field that should be removed.Either the `field_name` or `field_id` must be specified.

    Returns
    -------
    str
        ID of the item after the field is removed.

    Raises
    ------
    ValueError
        If no field is found with the given `field_name` or `field_id`.
    """

    if not self._fetched:
        self._get()

    new_fielddata_list = []
    fielddata_to_be_removed = None
    for fielddata in self.fielddata:
        found = False
        if field_id:
            if fielddata.field_id == field_id:
                fielddata_to_be_removed = fielddata
                found = True
        elif field_name:
            if fielddata.field_name == field_name:
                fielddata_to_be_removed = fielddata
                found = True
        if not found:
            new_fielddata_list.append(fielddata)

    if not fielddata_to_be_removed:
        raise ValueError("No field found with the given fieldid or fieldname")

    self.fielddata = new_fielddata_list
    fielddata_list = [{"id": fd.id} for fd in new_fielddata_list]
    post_data = {"id": self.id, "fielddata": fielddata_list}
    id = self._post(post_data)
    return id

set_calculation_result(value, field_name='', field_id='', fielddata_id='')

Method to update a calculation result

Parameters:

Name Type Description Default
value dict

Dictionary containing the calculation result to be set for the field.

required
field_name str

Name of the field that should be updated. Either field_name, field_id, or fielddata_id must be specified.

''
field_id str

ID of the field that should be updated. Either field_name, field_id, or fielddata_id must be specified.

''
fielddata_id str

ID of the fielddata that should be updated. Either field_name, field_id, or fielddata_id must be specified.

''

Returns:

Type Description
id

The ID of the fielddata that was updated.

Raises:

Type Description
ValueError

If no field is found with the given field_id or field_name.

Source code in furthrmind\collection\baseclass.py
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
def set_calculation_result(
    self,
    value: dict,
    field_name: str = "",
    field_id: str = "",
    fielddata_id: str = "",
):
    """
    Method to update a calculation result

    Parameters
    ----------
    value : dict
        Dictionary containing the calculation result to be set for the field.
    field_name : str, optional
        Name of the field that should be updated. Either `field_name`, `field_id`, or `fielddata_id` must be specified.
    field_id : str, optional
        ID of the field that should be updated. Either `field_name`, `field_id`, or `fielddata_id` must be specified.
    fielddata_id : str, optional
        ID of the fielddata that should be updated. Either `field_name`, `field_id`, or `fielddata_id` must be specified.

    Returns
    -------
    id
        The ID of the fielddata that was updated.

    Raises
    ------
    ValueError
        If no field is found with the given `field_id` or `field_name`.
    """

    if not self._fetched:
        self._get()

    fielddata = None
    for item in self.fielddata:
        if fielddata:
            break
        if fielddata_id:
            if item.id == fielddata_id:
                fielddata = item
        if field_id:
            if item.field_id == field_id:
                fielddata = item
        elif field_name:
            if item.field_name.lower() == field_name.lower():
                fielddata = item

    if not fielddata:
        raise ValueError("No field found with the given field_id or field_name")

    return fielddata.set_calculation_result(value)

to_dict()

Converts the object's attributes to a dictionary representation.

Returns:

Type Description
dict

Dictionary containing the object's attributes (excluding private attributes, callable attributes, and attributes of type Furthrmind).

Source code in furthrmind\collection\baseclass.py
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
def to_dict(self):
    """
    Converts the object's attributes to a dictionary representation.

    Returns
    -------
    dict
        Dictionary containing the object's attributes (excluding private attributes, callable attributes, and attributes of type Furthrmind).
    """

    from furthrmind import Furthrmind

    data = {}
    for attr in dir(self):
        if attr.startswith("_"):
            continue
        value = getattr(self, attr)
        if callable(value):
            continue
        if isinstance(value, Furthrmind):
            continue
        data[attr] = self._convert(value)
    return data

update_field_unit(unit, field_name='', field_id='')

Method to update the unit of a field.

Parameters:

Name Type Description Default
unit Union[Dict, str]

Dictionary with id or name, or string representing the name, or string representing the id.

required
field_name str

The name of the field that should be updated. Either field_name or field_id must be specified.

''
field_id str

The ID of the field that should be updated. Either field_name or field_id must be specified.

''

Returns:

Type Description
id

The ID of the updated field.

Raises:

Type Description
ValueError

If no field is found with the given field_id or field_name.

Source code in furthrmind\collection\baseclass.py
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
def update_field_unit(
    self, unit: Union[Dict, str], field_name: str = "", field_id: str = ""
):
    """
    Method to update the unit of a field.

    Parameters
    ----------
    unit : Union[Dict, str]
        Dictionary with id or name, or string representing the name, or string representing the id.
    field_name : str, optional
        The name of the field that should be updated. Either `field_name` or `field_id` must be specified.
    field_id : str, optional
        The ID of the field that should be updated. Either `field_name` or `field_id` must be specified.

    Returns
    -------
    id
        The ID of the updated field.

    Raises
    ------
    ValueError
        If no field is found with the given `field_id` or `field_name`.

    """

    if not self._fetched:
        self._get()

    fielddata = None
    for item in self.fielddata:
        if fielddata is not None:
            break
        if field_id:
            if item.field_id == field_id:
                fielddata = item
        elif field_name:
            if item.field_name.lower() == field_name.lower():
                fielddata = item

    if not fielddata:
        raise ValueError("No field found with the given field_id or field_name")

    return fielddata.update_unit(unit)

update_field_value(value, field_name='', field_id='')

Parameters:

Name Type Description Default
value various data types

The value to be updated in the field.

  • Numeric fields: float or int, or a string convertible to a float
  • Date fields: datetime, date object, unix timestamp, or string with iso format
  • Text fields: string
  • List fields: dictionary with id or name as key, or string with name, or string with id
  • Notebook fields: dictionary with content as key, or string
  • Checkbox fields: boolean
required
field_name str

Name of the field that should be updated. Either field_name or field_id must be specified.

''
field_id str

ID of the field that should be updated. Either field_name or field_id must be specified.

''

Returns:

Type Description
int

The ID of the field that was updated.

Raises:

Type Description
ValueError

If no field is found with the given field_id or field_name.

Source code in furthrmind\collection\baseclass.py
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
def update_field_value(self, value, field_name: str = "", field_id: str = ""):
    """
    Parameters
    ----------
    value : various data types
        The value to be updated in the field.

        - Numeric fields: float or int, or a string convertible to a float
        - Date fields: datetime, date object, unix timestamp, or string with iso format
        - Text fields: string
        - List fields: dictionary with id or name as key, or string with name, or string with id
        - Notebook fields: dictionary with content as key, or string
        - Checkbox fields: boolean
    field_name : str, optional
        Name of the field that should be updated. Either `field_name` or `field_id` must be specified.
    field_id : str, optional
        ID of the field that should be updated. Either `field_name` or `field_id` must be specified.

    Returns
    -------
    int
        The ID of the field that was updated.

    Raises
    ------
    ValueError
        If no field is found with the given `field_id` or `field_name`.
    """

    if not self._fetched:
        self._get()

    fielddata = None
    for item in self.fielddata:
        if fielddata:
            break
        if field_id:
            if item.field_id == field_id:
                fielddata = item
        elif field_name:
            if item.field_name.lower() == field_name.lower():
                fielddata = item

    if not fielddata:
        raise ValueError("No field found with the given field_id or field_name")

    return fielddata.update_value(value)