'Cant create a number format in Docker using Apache Superset
I am trying to create a BRL number format (R$123,345,789.22) for my big number charts but i don't know how to do that... I looked at this solution here: Customise the number format in Apache superset but I can't make it work. I think it is because the superset is installed locally via docker containers so it just downloads the images and it doesn't matter if I change my local superset files it doesn't change anything in the app (don't know much about docker btw). here is the docker-compose file to build superset
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You 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.
#
x-superset-image: &superset-image apache/superset:${TAG:-latest-dev}
x-superset-depends-on: &superset-depends-on
- db
- redis
x-superset-volumes: &superset-volumes
# /app/pythonpath_docker will be appended to the PYTHONPATH in the final container
- ./docker:/app/docker
- superset_home:/app/superset_home
version: "3.7"
services:
redis:
image: redis:latest
container_name: superset_cache
restart: unless-stopped
volumes:
- redis:/data
db:
env_file: docker/.env-non-dev
image: postgres:10
container_name: superset_db
restart: unless-stopped
volumes:
- db_home:/var/lib/postgresql/data
superset:
env_file: docker/.env-non-dev
image: *superset-image
container_name: superset_app
command: ["/app/docker/docker-bootstrap.sh", "app-gunicorn"]
user: "root"
restart: unless-stopped
ports:
- 8088:8088
depends_on: *superset-depends-on
volumes: *superset-volumes
superset-init:
image: *superset-image
container_name: superset_init
command: ["/app/docker/docker-init.sh"]
env_file: docker/.env-non-dev
depends_on: *superset-depends-on
user: "root"
volumes: *superset-volumes
superset-worker:
image: *superset-image
container_name: superset_worker
command: ["/app/docker/docker-bootstrap.sh", "worker"]
env_file: docker/.env-non-dev
restart: unless-stopped
depends_on: *superset-depends-on
user: "root"
volumes: *superset-volumes
superset-worker-beat:
image: *superset-image
container_name: superset_worker_beat
command: ["/app/docker/docker-bootstrap.sh", "beat"]
env_file: docker/.env-non-dev
restart: unless-stopped
depends_on: *superset-depends-on
user: "root"
volumes: *superset-volumes
volumes:
superset_home:
external: false
db_home:
external: false
redis:
external: false
the modified file as in Customise the number format in Apache superset :
import {
createDurationFormatter,
createD3NumberFormatter,
getNumberFormatter,
getNumberFormatterRegistry,
NumberFormats,
getTimeFormatterRegistry,
smartDateFormatter,
smartDateVerboseFormatter,
} from '@superset-ui/core';
export default function setupFormatters() {
getNumberFormatterRegistry()
// Add shims for format strings that are deprecated or common typos.
// Temporary solution until performing a db migration to fix this.
.registerValue(',0', getNumberFormatter(',.4~f'))
.registerValue('null', getNumberFormatter(',.4~f'))
.registerValue('%', getNumberFormatter('.0%'))
.registerValue('.', getNumberFormatter('.4~f'))
.registerValue(',f', getNumberFormatter(',d'))
.registerValue(',r', getNumberFormatter(',.4f'))
.registerValue('0f', getNumberFormatter(',d'))
.registerValue(',#', getNumberFormatter(',.4~f'))
.registerValue('$,f', getNumberFormatter('$,d'))
.registerValue('0%', getNumberFormatter('.0%'))
.registerValue('f', getNumberFormatter(',d'))
.registerValue(',.', getNumberFormatter(',.4~f'))
.registerValue('.1%f', getNumberFormatter('.1%'))
.registerValue('1%', getNumberFormatter('.0%'))
.registerValue('3%', getNumberFormatter('.0%'))
.registerValue(',%', getNumberFormatter(',.0%'))
.registerValue('.r', getNumberFormatter('.4~f'))
.registerValue('$,.0', getNumberFormatter('$,d'))
.registerValue('$,.1', getNumberFormatter('$,.1~f'))
.registerValue(',0s', getNumberFormatter(',.4~f'))
.registerValue('%%%', getNumberFormatter('.0%'))
.registerValue(',0f', getNumberFormatter(',d'))
.registerValue('+,%', getNumberFormatter('+,.0%'))
.registerValue('$f', getNumberFormatter('$,d'))
.registerValue('+,', getNumberFormatter(NumberFormats.INTEGER_SIGNED))
.registerValue(',2f', getNumberFormatter(',.4~f'))
.registerValue(',g', getNumberFormatter(',.4~f'))
.registerValue('int', getNumberFormatter(NumberFormats.INTEGER))
.registerValue('.0%f', getNumberFormatter('.1%'))
.registerValue('$,0', getNumberFormatter('$,.4f'))
.registerValue('$,0f', getNumberFormatter('$,.4f'))
.registerValue('$,.f', getNumberFormatter('$,.4f'))
.registerValue('DURATION', createDurationFormatter())
.registerValue(
'DURATION_SUB',
createDurationFormatter({ formatSubMilliseconds: true }),
);
.registerValue(
'CURRENCY_BRAZIL',
createD3NumberFormatter({
locale: {
decimal: ',',
thousands: '.',
currency: ['R$', ''],
},
formatString: '$,.2f',
}),
)
getTimeFormatterRegistry()
.registerValue('smart_date', smartDateFormatter)
.registerValue('smart_date_verbose', smartDateVerboseFormatter)
.setDefaultKey('smart_date');
}
so my question is: How can i create a custom number format on docker superset?
I have got this answer from a fellow gentleman made-of-imposter-syndr : " From what I can see, you are using docker-compose-non-dev.yml as your compose file, which uses pre-built frontend assets, which is why you are not able to see the changes you make.
Try running docker-compose -f docker-compose.yml up or simply, docker-compose up (If a file with the name docker-compose.yml file exists, docker-compose up automatically picks that up)"
however, I tried running "docker-compose up" to run superset but now whenever I go to localhost:8088 it shows a weird blank screen:
so I cant run superset using docker-compose.yml, it only runs with docker-compose-non-dev.yml but as mentioned above apparently I can't change the code that way.
this is the link of the docker-compose up output logs on my terminal:
can someone help me solve this blank screen?
Solution 1:[1]
From what I can see, you are using docker-compose-non-dev.yml as your compose file, which uses pre-built frontend assets, which is why you are not able to see the changes you make.
Try running docker-compose -f docker-compose.yml up or simply, docker-compose up (If a file with the name docker-compose.yml file exists, docker-compose up automatically picks that up)
More information about that here, in superset documentation
If you are interested in learning more about docker in general, this tutorial was quite useful for me
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | made_of_imposter_syndr |
