Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

D3_FORMATS PROBLEM #29251

Open
3 tasks done
iRoot13x18 opened this issue Jun 14, 2024 · 5 comments
Open
3 tasks done

D3_FORMATS PROBLEM #29251

iRoot13x18 opened this issue Jun 14, 2024 · 5 comments
Labels
change:backend Requires changing the backend

Comments

@iRoot13x18
Copy link

Bug description

When I change the configuration of the superset_config.py file and I want to change the number format to European when I reboot to apply the changes nothing comes up.

How to reproduce the bug

  1. go to superset_config.py or config.py
  2. add or edit this lines
  • D3_FORMATS = {

    'NUMBER': {

      'thousands': '.',
    
      'decimal': ','
    

    },

Screenshots/recordings

No response

Superset version

master / latest-dev

Python version

3.9

Node version

16

Browser

Chrome

Additional context

No response

Checklist

  • I have searched Superset docs and Slack and didn't find a solution to my problem.
  • I have searched the GitHub issue tracker and didn't find a similar bug report.
  • I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.
@dosubot dosubot bot added the change:backend Requires changing the backend label Jun 14, 2024
Copy link

dosubot bot commented Jun 14, 2024

To change the number format to European in Apache Superset, modifying the superset_config.py file alone might not be sufficient. Instead, you should update the D3FormatConfig.ts file in the frontend code. Here’s how you can do it:

  1. Locate the D3FormatConfig.ts file in the frontend codebase:

    superset-frontend/packages/superset-ui-core/src/number-format/D3FormatConfig.ts
    
  2. Update the DEFAULT_D3_FORMAT parameter to use a European format locale definition. Here’s an example:

    import { FormatLocaleDefinition } from 'd3-format';
    
    export const DEFAULT_D3_FORMAT: FormatLocaleDefinition = {
      decimal: ',',
      thousands: '.',
      grouping: [3],
      currency: ['€', ''],
    };

This change will ensure that the number format is applied globally across your Superset instance [1].

Additionally, ensure that there are no overriding configurations in other files such as superset_config_docker.py or any other local configuration files that might affect the D3_FORMATS settings [2][3][4].

To continue talking to Dosu, mention @dosu.

@rusackas
Copy link
Member

D3_FORMATS isn't a thing, as far as I know. There is D3_FORMAT in config.py, but that takes the parameters for a single format, not an array or object of various formats like you seem to be using.

@fabgat
Copy link

fabgat commented Jun 21, 2024

Hi,
I've modified the D3FormatConfig.ts file, as per follow:
import { FormatLocaleDefinition } from 'd3-format';

export const DEFAULT_D3_FORMAT: FormatLocaleDefinition = {
decimal: ',',
thousands: '.',
grouping: [3],
currency: ['€', ''],
};

I've modified also the config.py:

class D3Format(TypedDict, total=False):
decimal: str
thousands: str
grouping: list[int]
currency: list[str]

#D3_FORMAT: D3Format = {}

D3_FORMAT: D3Format = {
"decimal": ",",
"thousands": ".",
"grouping": [3],
"currency": ["€", ""]
}

no changes into: superset_config.py

After those activities I've restarted the docker, but everything is the same, no changes.

Where I'm wrong?

Regards

@rusackas
Copy link
Member

@dosu-bot

Copy link

dosubot bot commented Jun 21, 2024

To ensure that your changes to D3FormatConfig.ts and config.py are applied correctly, follow these steps:

  1. Recompile the Frontend Code:
    After modifying D3FormatConfig.ts, you need to recompile the frontend assets. You can do this using Docker commands provided in the Superset repository:

    docker-compose up

    Alternatively, you can use the js_build.sh script located in the superset-frontend directory to rebuild the frontend assets:

    cd superset-frontend
    ./js_build.sh
  2. Ensure Configuration is Loaded:
    Make sure that your custom superset_config.py is recognized by setting the SUPERSET_CONFIG_PATH environment variable to the full path of your superset_config.py file. For example:

    export SUPERSET_CONFIG_PATH=/app/superset_config.py

    If you are using Docker, you can add your overrides as shown below:

    COPY --chown=superset superset_config.py /app/
    ENV SUPERSET_CONFIG_PATH /app/superset_config.py
  3. Restart Services in Correct Order:
    Restart the services in the following order to ensure that the configuration changes are applied correctly:

    docker-compose restart redis db superset superset-init superset-worker superset-worker-beat
  4. Clear Cache:
    Clear the cache to ensure that the new configuration is applied. You can do this by adding the following lines to your superset_config.py:

    from superset.utils.cache_manager import cache_manager
    
    cache_manager.cache.clear()
    cache_manager.data_cache.clear()
    cache_manager.thumbnail_cache.clear()
    cache_manager.filter_state_cache.clear()
    cache_manager.explore_form_data_cache.clear()

    Alternatively, you can clear the cache manually using the following methods:

    cache_manager.cache.clear()
    cache_manager.data_cache.clear()
    cache_manager.thumbnail_cache.clear()
    cache_manager.filter_state_cache.clear()
    cache_manager.explore_form_data_cache.clear()

By following these steps, you should be able to apply the changes to the number format configuration successfully [1][2][3][4].

To continue talking to Dosu, mention @dosu.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
change:backend Requires changing the backend
Projects
None yet
Development

No branches or pull requests

3 participants