Comments (2)
Hey there, @rmasters! I'm a bot designed to help you out with bugs, questions, and becoming a contributor. I'm here to assist you with the issue you've encountered while waiting for a human maintainer. Let's tackle this together!
To fix the "405 Method Not Allowed" error in the chart cache warm-up task for Superset version 4.0.1, ensure that the HTTP method used for the /warm_up_cache
endpoint is PUT
. The endpoint is defined to accept only PUT
requests.
Here is the relevant code snippet from superset/charts/api.py
:
@expose("/warm_up_cache", methods=("PUT",))
@protect()
@safe
@statsd_metrics
@event_logger.log_this_with_context(
action=lambda self, *args, **kwargs: f"{self.__class__.__name__}"
f".warm_up_cache",
log_to_statsd=False,
)
def warm_up_cache(self) -> Response:
"""Warm up the cache for the chart.
---
put:
summary: Warm up the cache for the chart
description: >-
Warms up the cache for the chart.
Note for slices a force refresh occurs.
In terms of the `extra_filters` these can be obtained from records in the JSON
encoded `logs.json` column associated with the `explore_json` action.
requestBody:
description: >-
Identifies the chart to warm up cache for, and any additional dashboard or
filter context to use.
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/ChartCacheWarmUpRequestSchema"
responses:
200:
description: Each chart's warmup status
content:
application/json:
schema:
$ref: "#/components/schemas/ChartCacheWarmUpResponseSchema"
400:
$ref: '#/components/responses/400'
404:
$ref: '#/components/responses/404'
500:
$ref: '#/components/responses/500'
"""
try:
body = ChartCacheWarmUpRequestSchema().load(request.json)
except ValidationError as error:
return self.response_400(message=error.messages)
try:
result = ChartWarmUpCacheCommand(
body["chart_id"],
body.get("dashboard_id"),
body.get("extra_filters"),
).run()
return self.response(200, result=[result])
except CommandException as ex:
return self.response(ex.status, message=ex.message)
Ensure that your request to warm up the cache uses the PUT
method. For example, using curl
:
curl -X PUT -H "Content-Type: application/json" -d '{"chart_id": 1, "dashboard_id": 2, "extra_filters": []}' http://your-superset-url/api/v1/chart/warm_up_cache
Or using Python's requests
library:
import requests
url = "http://your-superset-url/api/v1/chart/warm_up_cache"
data = {
"chart_id": 1,
"dashboard_id": 2,
"extra_filters": []
}
headers = {
"Content-Type": "application/json"
}
response = requests.put(url, json=data, headers=headers)
print(response.status_code, response.json())
Additionally, ensure that the cache warm-up task is correctly configured in superset/tasks/cache.py
. The fetch_url
function should use the PUT
method when making the request:
@celery_app.task(name="fetch_url")
def fetch_url(data: str, headers: dict[str, str]) -> dict[str, str]:
"""
Celery job to fetch url
"""
result = {}
try:
url = get_url_path("Superset.warm_up_cache")
logger.info("Fetching %s with payload %s", url, data)
req = request.Request(
url, data=bytes(data, "utf-8"), headers=headers, method="PUT"
)
response = request.urlopen( # pylint: disable=consider-using-with
req, timeout=600
)
logger.info(
"Fetched %s with payload %s, status code: %s", url, data, response.code
)
if response.code == 200:
result = {"success": data, "response": response.read().decode("utf-8")}
else:
result = {"error": data, "status_code": response.code}
logger.error(
"Error fetching %s with payload %s, status code: %s",
url,
data,
response.code,
)
except URLError as err:
logger.exception("Error warming up cache!")
result = {"error": data, "exception": str(err)}
return result
Make sure the request method is PUT
to avoid the "405 Method Not Allowed" error [1][2].
Details
About Dosu
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.
Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.
To continue the conversation, mention @dosu.
from superset.
We are also experiencing this problem here after upgrading from 2.x
to 3.1.3
. Will the changes be backported? 😃
from superset.
Related Issues (20)
- /lib64/libstdc++.so.6: cannot allocate memory in static TLS block HOT 1
- WARNING 'werkzeug.local.LocalProxy' is not mapped HOT 1
- Horizontal bar chart legend padding & sort order regression in 4.0.2rc2 HOT 3
- Exception: Unable to execute 'ecpg', you likely need to install it.' HOT 2
- The row limit set for the chart was reached. HOT 13
- Download to CSV shows a special characters in Arabic HOT 7
- ChartWarmUpCacheCommand still use legacy filter scopes HOT 3
- Superset API import dataset without SSH Tunnel not working ? HOT 1
- Unable to detect valid SELECT statement HOT 1
- UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd4 in position 6: invalid continuation byte HOT 8
- Tags on content do not get displayed in consistent order HOT 2
- Webpack build runs regardless of BUILD_SUPERSET_FRONTEND_IN_DOCKER cited in docker compose documentation HOT 2
- SQL with inline comment starting with `--` fails in dashboards `view query` and sqllab HOT 3
- Sequential color scheme for skewed data
- DATA URIs are stripped from href attribute HOT 2
- Stop button for queries doesn't work in SQL Lab HOT 1
- SQL Lab - Save button doesn't change its size based on label length HOT 1
- Chart Editor - Impossible to translate Time Grain dropdown contents HOT 1
- Chart Editor (Radar Chart) - Impossible to translate Label Position dropdown contents HOT 1
- Slack Notification - deprecated API HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from superset.