Skip to content

Commit

Permalink
Merge branch 'main' of github.com:ageller/Firefly
Browse files Browse the repository at this point in the history
  • Loading branch information
ageller committed Mar 6, 2024
2 parents 8ba9cb0 + c3f0ddf commit 0852f4e
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 12 deletions.
9 changes: 6 additions & 3 deletions src/firefly/data_reader/json_utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pandas as pd
import os
import json

def write_to_json(dictionary,path=None):
"""Simple utility function to write a dictionary to a path as :code:`.json` file.
Expand All @@ -25,7 +26,9 @@ def load_from_json(path):
:return: dictionary
:rtype: dict
"""
if os.path.isfile(path):
with open(path,'r') as handle:
dictionary=pd.io.json.loads(''.join(handle.readlines()))
if not os.path.isfile(path):
raise FileNotFoundError(path)

with open(path,'r') as handle:
dictionary = json.load(handle)
return dictionary
20 changes: 18 additions & 2 deletions src/firefly/ntbks/minimal_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,30 @@
"from firefly.server import spawnFireflyServer,quitAllFireflyServers"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "bbdc4f84",
"metadata": {},
"outputs": [],
"source": [
"# depending on how you installed Firefly, you may need to define a directory path to send to the spawnFireflyServer command\n",
"# the directory should point to the location of the \"static\" directory in your firefly distribution, \n",
"# e.g., in our GitHub repo that is \"Firefly/src/firefly\"\n",
"# if you are running the notebook from Firefly/src/firefly/ntbks you could define the directory as\n",
"import os\n",
"directory = os.path.join(os.getcwd(),'..') \n",
"print(directory)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6e2fa016-019c-482a-a039-114816ecee37",
"metadata": {},
"outputs": [],
"source": [
"process = spawnFireflyServer()"
"process = spawnFireflyServer(directory = directory)"
]
},
{
Expand Down Expand Up @@ -151,7 +167,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.6"
"version": "3.10.11"
}
},
"nbformat": 4,
Expand Down
14 changes: 7 additions & 7 deletions src/firefly/static/js/gui/initGUI.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ function makeUI(local=false){
if (GUIParams.cameraNeedsUpdate) updateGUICamera();
createUI();
}
// attempt to fix the issue where the GUI and viewer don't connect to the socket
// this might result in some infinite loop of reloads...
if (GUIParams.GUItries > 5 && GUIparams.usingSocket){
console.log('ERROR IN CREATING GUI. TRYING AGAIN.');
GUIParams.GUItries = 0;
location.reload();
}
// // attempt to fix the issue where the GUI and viewer don't connect to the socket
// // this might result in some infinite loop of reloads...
// if (GUIParams.GUItries > 5 && GUIParams.usingSocket){
// console.log('ERROR IN CREATING GUI. TRYING AGAIN.');
// GUIParams.GUItries = 0;
// location.reload();
// }
}, 1000);


Expand Down
1 change: 1 addition & 0 deletions src/firefly/static/js/misc/socketParams.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ function defineSocketParams(){
// Connect to the Socket.IO server.
// The connection URL has the following format:
// http[s]://<domain>:<port>[/<namespace>]

this.socket = io.connect(location.protocol + '//' + document.domain + ':' + location.port + this.namespace,
{
rememberTransport: false,
Expand Down

0 comments on commit 0852f4e

Please sign in to comment.