Skip to main content
Version: 12.9.0

Upgrades

This document lists all current deprecations, with upgrade steps and planned removal. When the deprecation is removed with a major update, it will be moved under its corresponding header.

This version

U68 - Remove require_all_fields on buttons

  • deprecated since: v12.9.0
  • planned removal: v13
  • automated code fix available: yes

Current behaviour + reason for change

The argument require_all_fields can be specified on an action button, however it is not implemented in the platform. This argument could cause confusion and makes the SDK reference less readable.

New behaviour

The require_all_fields argument will be removed. The following fields are affected:

  • DownloadButton
  • SetParamsButton
  • ActionButton (AnalyseButton)
  • OptimizationButton (OptimiseButton)

Conversion

The following conversion has to be performed, which can be done automatically by using the CLI command viktor-cli fix -u 68:

- download_button = DownloadButton("Download X", method="download_x", require_all_fields=True)
+ download_button = DownloadButton("Download X", method="download_x")

U67 - GEOLIB hosting by VIKTOR will be terminated

  • deprecated since: v12.9.0
  • automated code fix available: yes

Current behaviour + reason for change

Deltares' GEOLIB is currently hosted by VIKTOR to make it available for its clients. The GEOLIB (>= 0.1.6) has now become publicly available on pypi, removing the need to host it ourselves.

New behaviour

The GEOLIB can be installed directly from pypi by pointing to the correct package in the app's requirements.txt.

Conversion

In case you are not using the GEOLIB in your app, no action is required. Otherwise, update requirements.txt which can be done automatically by using the CLI command viktor-cli fix -u 67:

  # viktor==X.X.X
- geolib==0.1.6
+ d-geolib==0.1.6
...
caution

GEOLIB is available on pypi from version >= 0.1.6. With the termination of the hosting by VIKTOR, older versions will become unavailable. If your app uses a version older than 0.1.6, please update your code accordingly.

U66 - NumberField.Variant replaced with str-type

  • deprecated since: v12.8.0
  • planned removal: v13
  • automated code fix available: yes

Current behaviour + reason for change

The variant of a NumberField is currently set with NumberField.Variant, which is of type Enum. To make the product easier to understand and use, also for starting programmers, this is updated to a simple str-type.

New behaviour

The variant of a NumberField can be set with a simple str-type ('slider', 'standard').

Conversion

The following conversion has to be performed, which can be done automatically by using the CLI command viktor-cli fix -u 66:

- NumberField("MyField", min=10, max=20, variant=NumberField.Variant.SLIDER)
+ NumberField("MyField", min=10, max=20, variant='slider')
- NumberField("MyField", variant=NumberField.Variant.STANDARD)
+ NumberField("MyField", variant='standard') # or just NumberField("MyField")

U65 - Entity selection fields return Entity object

  • deprecated since: v12.8.0
  • planned removal: v13
  • automated code fix available: partly

Current behaviour + reason for change

The value of the entity selection fields as returned in the params is of type integer. Returning objects in the params will become the standard behavior. This allows for already existing fields, such as the entity selection fields, to return more logical types.

New behaviour

Returned values in the params will be strictly of type Entity in the future. By defining viktor_convert_entity_field = True on a controller, this behavior can be simulated.

The following fields are affected:

  • ChildEntityOptionField
  • SiblingEntityOptionField
  • ChildEntityMultiSelectField
  • SiblingEntityMultiSelectField

Note that if viktor_convert_entity_field is defined, not only the params of the current controller are converted, but also the params obtained from API calls. In the example below, the params of an entity of EntityTypeA are converted when retrieved in an entity of EntityTypeB.

class ControllerA(ViktorController)  # EntityTypeA

viktor_convert_entity_field = False
...

def func(self, params, **kwargs):
entity = params['child_entity_option_field'] # of type int!


class ControllerB(ViktorController) # EntityTypeB

viktor_convert_entity_field = True
...

def func(self, params, **kwargs):
params_entity_a = ... # API call to retrieve params of EntityTypeA
entity = params_entity_a['child_entity_option_field'] # of type Entity!

Conversion

Add a viktor_convert_entity_field class attribute on the Controller. This can be done automatically by using the CLI command viktor-cli fix -u 65:

class MyController(ViktorController):

+ viktor_convert_entity_field = True
caution

Unfortunately we cannot automatically fix your app logic. Please update the affected code manually, for example:

entity = params.tab.section.child_entity
- entity = API().get_entity(entity)

An Entity is not serializable meaning that it cannot be used as input of a memoized function. In case you are passing the complete params as input, a conversion is required:

- memoized_func(params=params)
+ params_ = copy.deepcopy(params)
+ del params_['tab']['section']['child_entity']
+ memoized_func(params=params_)

U64 - Replace PrivilegedAPI by explicit privileged flag

  • deprecated since: v12.6.0
  • planned removal: v13
  • automated code fix available: no

Current behaviour + reason for change

Privileged API calls are done by using the PrivilegedAPI class. A danger of this approach is that the object may be instantiated well in advance of the actual API call, such that it is no longer transparent whether that call is privileged or not. Furthermore, PrivilegedAPI and the default API could be mixed within a method which can also result in unwanted privileged calls.

New behaviour

The PrivilegedAPI class will be removed and privileged API calls should be done by adding an explicit privileged flag in the corresponding method (e.g. entity.children(privileged=True)). The following methods are affected:

  • API.get_entity()
  • API.get_entity_file()
  • API.get_root_entities()
  • Entity.parent()
  • Entity.children()
  • Entity.siblings()
caution

If not used properly, (confidential) information which SHOULD NOT be accessible by a user may leak (for instance by including data in a view). Please consider the following when using the privileged flag:

  • Make sure the app's admin is aware that the code circumvents certain permissions at specific places.
  • Make sure to test the implementation thoroughly, to ensure no confidential data is leaked.

Conversion

- api = PrivilegedAPI()
- privileged_root_entities = api.get_root_entities()
+ api = API()
+ privileged_root_entities = api.get_root_entities(privileged=True)

U63 - Remove prefix and suffix on DateField

  • deprecated since: v12.5.0
  • planned removal: v13
  • automated code fix available: no

Current behaviour + reason for change

A prefix and / or suffix can be defined on a DateField, which is not relevant for this type of field. The attributes will therefore be removed.

New behaviour

It will not be possible to use prefix and suffix on a DateField.

Conversion

- DateField('Some date', suffix='XYZ')
+ DateField('Some date (XYZ)')

U62 - Renamed threejs_visualisation() to visualize_geometry()

  • deprecated since: v12.5.0
  • planned removal: v13
  • automated code fix available: yes

Current behaviour + reason for change

A SoilLayout2D or SoilLayer2D can be visualized by calling threejs_visualisation() on the corresponding object. The "threejs" part in this name is no longer relevant and might be unclear to the developer.

New behaviour

Both methods return the geometric representation of the object, which can be used in a GeometryView. Therefore the methods are renamed to visualize_geometry():

  • SoilLayout2D.threejs_visualisation() -> SoilLayout2D.visualize_geometry()
  • SoilLayer2D.threejs_visualisation() -> SoilLayer2D.visualize_geometry()

Conversion

The following conversion has to be performed, which can be done automatically by using the CLI command viktor-cli fix -u 62:

  layout = SoilLayout2D(...)
- geometry, labels = layout.threejs_visualisation(...)
+ geometry, labels = layout.visualize_geometry(...)

U61 - Move entity-type information from manifest to Controller

  • deprecated since: v12.3.0
  • planned removal: v13
  • automated code fix available: yes

Current behaviour + reason for change

The entity-type information is currently partly described in the corresponding Controller (parametrization / views / summary), but some data is defined in the manifest.yml (label, children, show_children_as). This manifest is a concept which is often hard to grasp for a starting developer. In order to improve the onboarding of new developers, as well as consistency of where to define entity-type information, we would like to get rid of the manifest completely.

The first step is to move the definition of the following keys to the corresponding controller:

  • label (required)
  • children (if present)
  • show_children_as (if present)

New behaviour

The keys will become simple class attributes, similar as parametrization and summary:

class EntityTypeController(ViktorController):
label = 'Label of the entity-type'
children = ['SomeType', 'AnotherType']
show_children_as = 'Cards' # or 'Table'

If they are still present in the manifest, you may expect the following warning:

Entity.label is present in manifest.yml but is overwritten by the app logic. Remove entry from manifest.

Note, when you are defining label on the Controller, the SDK will also try to get children + show_children_as or use the default of "no children" if not found. Therefore you cannot define label on the Controller, while keeping children and show_children_as in the manifest!

Conversion

The following conversion has to be performed, which can be done automatically by using the CLI command viktor-cli fix -u 61:

# manifest.yml
version: '1'
entity_types:
EntityTypeA:
- label: This is A
- show_children_as: Cards
- children:
- - EntityTypeB
...
EntityTypeB:
- label: This is B
...
# entity_type_a/controller.py
class EntityTypeAController(ViktorController):
+ label = 'This is A'
+ children = ['EntityTypeB']
+ show_children_as = 'Cards'

...

# entity_type_b/controller.py
class EntityTypeBController(ViktorController):
+ label = 'This is B'

...