This commit is contained in:
David Brazda
2023-12-17 18:43:46 +01:00
parent 85d4916320
commit 17b9859a73
4 changed files with 28 additions and 22 deletions

View File

@ -17,7 +17,7 @@ TEST_SERVER_HOSTNAMES = ['tradingtest']
#TODO vybrane dat do config db a managovat pres GUI
#AGGREGATOR filter trades
#DEFAULT AGGREGATOR filter trades
#NOTE pridana F - Inter Market Sweep Order - obcas vytvarela spajky
AGG_EXCLUDED_TRADES = ['C','O','4','B','7','V','P','W','U','Z','F']

View File

@ -791,7 +791,7 @@ def delete_item(item_id: int) -> dict:
#model section
#UPLOAD MODEL
@app.post("/model/upload_model", dependencies=[Depends(api_key_auth)])
async def upload_model(file: UploadFile = File(...)):
async def _upload_model(file: UploadFile = File(...)):
# Specify the directory to save the file
#save_directory = DATA_DIR+'/models/'
save_directory = MODEL_DIR
@ -857,7 +857,8 @@ def download_model(model_name: str):
@app.get("/model/metadata/{model_name}", dependencies=[Depends(api_key_auth)])
def get_metadata(model_name: str):
try:
model_instance = ml.load_model(file=model_name, directory=MODEL_DIR)
#loadujeme pouze v modu cfg only
model_instance = ml.load_model(file=model_name, directory=MODEL_DIR, cfg_only = True)
try:
metadata = model_instance.metadata
except AttributeError:

View File

@ -810,6 +810,7 @@
<div class="form-group">
<label for="metadata-container" id="metadata_label" class="form-label">Metadata</label>
<div id="metadata-container" style="height:700px;border:1px solid black;">
<div id="metadata-container-info"></div>
<div id="toml-editor-container"></div>
<div id="python-editor-container"></div>
</div>

View File

@ -106,16 +106,17 @@ $(document).ready(function() {
xhr.setRequestHeader('X-API-Key', API_KEY);
},
success: function(response) {
$('#metadata-container-info').html("");
show_metadata(response, modelName)
},
error: function(xhr, status, error) {
$('#metadata-container').html('Error fetching metadata: ' + error + xhr.responseText + status);
show_metadata(xhr)
$('#metadata-container-info').html('Error fetching metadata: ' + error + xhr.responseText + status);
show_metadata(xhr, modelName, true)
}
});
}
function show_metadata(response, name) {
function show_metadata(response, name, error = false) {
// var formattedMetadata = '<pre>cfg:' + JSON.stringify(response.cfg, null, 4) + '</pre>';
// formattedMetadata += '<pre>arch_function:' + response.arch_function + '</pre>';
// $('#metadata-container').html(formattedMetadata);
@ -123,6 +124,8 @@ $(document).ready(function() {
console.log(JSON.stringify(response,null,4))
$('#metadata_label').html(name);
if (!error) {
console.log("init editoru", error)
require(["vs/editor/editor.main"], () => {
model_editor_json = monaco.editor.create(document.getElementById('toml-editor-container'), {
value: response.cfg_toml ? response.cfg_toml + ((response.history) ? "\nHISTORY:\n" + JSON.stringify(response.history,null,4) : "") : JSON.stringify(response,null,4),
@ -140,6 +143,7 @@ $(document).ready(function() {
});
});
}
}
// Fetch models on page load
fetchModels();