ivoryos 1.0.9__py3-none-any.whl → 1.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of ivoryos might be problematic. Click here for more details.

Files changed (87) hide show
  1. ivoryos/__init__.py +26 -7
  2. ivoryos/routes/api/api.py +56 -0
  3. ivoryos/routes/auth/auth.py +5 -5
  4. ivoryos/routes/control/control.py +77 -372
  5. ivoryos/routes/control/control_file.py +36 -0
  6. ivoryos/routes/control/control_new_device.py +142 -0
  7. ivoryos/routes/control/templates/controllers.html +166 -0
  8. ivoryos/routes/control/templates/controllers_new.html +112 -0
  9. ivoryos/routes/control/utils.py +38 -0
  10. ivoryos/routes/data/data.py +129 -0
  11. ivoryos/routes/data/templates/components/step_card.html +13 -0
  12. ivoryos/routes/{database/templates/database → data/templates}/workflow_database.html +14 -8
  13. ivoryos/routes/{database/templates/database → data/templates}/workflow_view.html +3 -3
  14. ivoryos/routes/design/__init__.py +4 -0
  15. ivoryos/routes/design/design.py +298 -656
  16. ivoryos/routes/design/design_file.py +68 -0
  17. ivoryos/routes/design/design_step.py +145 -0
  18. ivoryos/routes/design/templates/components/action_form.html +53 -0
  19. ivoryos/routes/design/templates/components/actions_panel.html +25 -0
  20. ivoryos/routes/design/templates/components/autofill_toggle.html +10 -0
  21. ivoryos/routes/design/templates/components/canvas.html +5 -0
  22. ivoryos/routes/design/templates/components/canvas_footer.html +9 -0
  23. ivoryos/routes/design/templates/components/canvas_header.html +75 -0
  24. ivoryos/routes/design/templates/components/canvas_main.html +34 -0
  25. ivoryos/routes/design/templates/components/deck_selector.html +10 -0
  26. ivoryos/routes/design/templates/components/edit_action_form.html +38 -0
  27. ivoryos/routes/design/templates/components/instruments_panel.html +66 -0
  28. ivoryos/routes/design/templates/components/modals/drop_modal.html +17 -0
  29. ivoryos/routes/design/templates/components/modals/json_modal.html +22 -0
  30. ivoryos/routes/design/templates/components/modals/new_script_modal.html +17 -0
  31. ivoryos/routes/design/templates/components/modals/rename_modal.html +23 -0
  32. ivoryos/routes/design/templates/components/modals/saveas_modal.html +27 -0
  33. ivoryos/routes/design/templates/components/modals.html +6 -0
  34. ivoryos/routes/design/templates/components/python_code_overlay.html +39 -0
  35. ivoryos/routes/design/templates/components/sidebar.html +15 -0
  36. ivoryos/routes/design/templates/components/text_to_code_panel.html +20 -0
  37. ivoryos/routes/design/templates/experiment_builder.html +41 -0
  38. ivoryos/routes/execute/__init__.py +0 -0
  39. ivoryos/routes/execute/execute.py +317 -0
  40. ivoryos/routes/execute/execute_file.py +78 -0
  41. ivoryos/routes/execute/templates/components/error_modal.html +20 -0
  42. ivoryos/routes/execute/templates/components/logging_panel.html +31 -0
  43. ivoryos/routes/execute/templates/components/progress_panel.html +27 -0
  44. ivoryos/routes/execute/templates/components/run_panel.html +9 -0
  45. ivoryos/routes/execute/templates/components/run_tabs.html +17 -0
  46. ivoryos/routes/execute/templates/components/tab_bayesian.html +398 -0
  47. ivoryos/routes/execute/templates/components/tab_configuration.html +98 -0
  48. ivoryos/routes/execute/templates/components/tab_repeat.html +14 -0
  49. ivoryos/routes/execute/templates/experiment_run.html +294 -0
  50. ivoryos/routes/library/__init__.py +0 -0
  51. ivoryos/routes/library/library.py +159 -0
  52. ivoryos/routes/{database/templates/database/scripts_database.html → library/templates/library.html} +30 -22
  53. ivoryos/routes/main/main.py +1 -1
  54. ivoryos/routes/main/templates/{main/home.html → home.html} +4 -4
  55. ivoryos/socket_handlers.py +52 -0
  56. ivoryos/static/js/action_handlers.js +213 -0
  57. ivoryos/static/js/db_delete.js +23 -0
  58. ivoryos/static/js/script_metadata.js +39 -0
  59. ivoryos/static/js/sortable_design.js +89 -56
  60. ivoryos/static/js/ui_state.js +113 -0
  61. ivoryos/templates/base.html +4 -4
  62. ivoryos/utils/bo_campaign.py +179 -3
  63. ivoryos/utils/db_models.py +14 -5
  64. ivoryos/utils/form.py +5 -9
  65. ivoryos/utils/global_config.py +13 -1
  66. ivoryos/utils/py_to_json.py +225 -0
  67. ivoryos/utils/script_runner.py +49 -7
  68. ivoryos/utils/serilize.py +203 -0
  69. ivoryos/utils/task_runner.py +4 -1
  70. ivoryos/version.py +1 -1
  71. {ivoryos-1.0.9.dist-info → ivoryos-1.2.0.dist-info}/METADATA +5 -8
  72. ivoryos-1.2.0.dist-info/RECORD +105 -0
  73. ivoryos/routes/control/templates/control/controllers.html +0 -78
  74. ivoryos/routes/control/templates/control/controllers_home.html +0 -55
  75. ivoryos/routes/control/templates/control/controllers_new.html +0 -89
  76. ivoryos/routes/database/database.py +0 -306
  77. ivoryos/routes/database/templates/database/step_card.html +0 -7
  78. ivoryos/routes/design/templates/design/experiment_builder.html +0 -521
  79. ivoryos/routes/design/templates/design/experiment_run.html +0 -558
  80. ivoryos-1.0.9.dist-info/RECORD +0 -61
  81. /ivoryos/routes/auth/templates/{auth/login.html → login.html} +0 -0
  82. /ivoryos/routes/auth/templates/{auth/signup.html → signup.html} +0 -0
  83. /ivoryos/routes/{database → data}/__init__.py +0 -0
  84. /ivoryos/routes/main/templates/{main/help.html → help.html} +0 -0
  85. {ivoryos-1.0.9.dist-info → ivoryos-1.2.0.dist-info}/LICENSE +0 -0
  86. {ivoryos-1.0.9.dist-info → ivoryos-1.2.0.dist-info}/WHEEL +0 -0
  87. {ivoryos-1.0.9.dist-info → ivoryos-1.2.0.dist-info}/top_level.txt +0 -0
ivoryos/__init__.py CHANGED
@@ -3,17 +3,23 @@ import sys
3
3
  from typing import Union
4
4
 
5
5
  from flask import Flask, redirect, url_for, g, Blueprint
6
+ sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
6
7
 
7
8
  from ivoryos.config import Config, get_config
8
9
  from ivoryos.routes.auth.auth import auth, login_manager
9
10
  from ivoryos.routes.control.control import control
10
- from ivoryos.routes.database.database import database
11
- from ivoryos.routes.design.design import design, socketio
11
+ from ivoryos.routes.data.data import data
12
+ from ivoryos.routes.library.library import library
13
+ from ivoryos.routes.design.design import design
14
+ from ivoryos.routes.execute.execute import execute
15
+ from ivoryos.routes.api.api import api
16
+ from ivoryos.socket_handlers import socketio
12
17
  from ivoryos.routes.main.main import main
13
18
  # from ivoryos.routes.monitor.monitor import monitor
14
19
  from ivoryos.utils import utils
15
20
  from ivoryos.utils.db_models import db, User
16
21
  from ivoryos.utils.global_config import GlobalConfig
22
+ from ivoryos.optimizer.registry import OPTIMIZER_REGISTRY
17
23
  from ivoryos.utils.script_runner import ScriptRunner
18
24
  from ivoryos.version import __version__ as ivoryos_version
19
25
  from importlib.metadata import entry_points
@@ -35,10 +41,13 @@ def enforce_sqlite_foreign_keys(dbapi_connection, connection_record):
35
41
  url_prefix = os.getenv('URL_PREFIX', "/ivoryos")
36
42
  app = Flask(__name__, static_url_path=f'{url_prefix}/static', static_folder='static')
37
43
  app.register_blueprint(main, url_prefix=url_prefix)
38
- app.register_blueprint(auth, url_prefix=url_prefix)
39
- app.register_blueprint(control, url_prefix=url_prefix)
40
- app.register_blueprint(design, url_prefix=url_prefix)
41
- app.register_blueprint(database, url_prefix=url_prefix)
44
+ app.register_blueprint(auth, url_prefix=f'{url_prefix}/{auth.name}')
45
+ app.register_blueprint(library, url_prefix=f'{url_prefix}/{library.name}')
46
+ app.register_blueprint(control, url_prefix=f'{url_prefix}/instruments')
47
+ app.register_blueprint(design, url_prefix=f'{url_prefix}')
48
+ app.register_blueprint(execute, url_prefix=f'{url_prefix}')
49
+ app.register_blueprint(data, url_prefix=f'{url_prefix}')
50
+ app.register_blueprint(api, url_prefix=f'{url_prefix}/{api.name}')
42
51
 
43
52
  @login_manager.user_loader
44
53
  def load_user(user_id):
@@ -86,6 +95,12 @@ def create_app(config_class=None):
86
95
  def redirect_to_prefix():
87
96
  return redirect(url_for('main.index', version=ivoryos_version)) # Assuming 'index' is a route in your blueprint
88
97
 
98
+ @app.template_filter('format_name')
99
+ def format_name(name):
100
+ name = name.split(".")[-1]
101
+ text = ' '.join(word for word in name.split('_'))
102
+ return text.capitalize()
103
+
89
104
  return app
90
105
 
91
106
 
@@ -136,7 +151,7 @@ def run(module=None, host="0.0.0.0", port=None, debug=None, llm_server=None, mod
136
151
  app.config["LOGGERS_PATH"] = logger_output_name or app.config["LOGGERS_PATH"] # default.log
137
152
  logger_path = os.path.join(app.config["OUTPUT_FOLDER"], app.config["LOGGERS_PATH"])
138
153
  dummy_deck_path = os.path.join(app.config["OUTPUT_FOLDER"], app.config["DUMMY_DECK"])
139
-
154
+ global_config.optimizers = OPTIMIZER_REGISTRY
140
155
  if module:
141
156
  app.config["MODULE"] = module
142
157
  app.config["OFF_LINE"] = False
@@ -195,6 +210,10 @@ def load_installed_plugins(app, socketio):
195
210
  def load_plugins(blueprints: Union[list, Blueprint], app, socketio):
196
211
  """
197
212
  Dynamically load installed plugins and attach Flask-SocketIO.
213
+ :param blueprints: Union[list, Blueprint] list of Blueprint objects or a single Blueprint object
214
+ :param app: Flask application instance
215
+ :param socketio: Flask-SocketIO instance
216
+ :return: list of plugin names
198
217
  """
199
218
  plugin_names = []
200
219
  if not isinstance(blueprints, list):
@@ -0,0 +1,56 @@
1
+ import os
2
+ from flask import Blueprint, jsonify, request, current_app
3
+
4
+ from ivoryos.routes.control.control import find_instrument_by_name
5
+ from ivoryos.utils.form import create_form_from_module
6
+ from ivoryos.utils.global_config import GlobalConfig
7
+ from ivoryos.utils.db_models import Script, WorkflowRun, SingleStep, WorkflowStep
8
+
9
+ from ivoryos.socket_handlers import abort_pending, abort_current, pause, retry, runner
10
+ from ivoryos.utils.task_runner import TaskRunner
11
+
12
+ api = Blueprint('api', __name__)
13
+ global_config = GlobalConfig()
14
+ task_runner = TaskRunner()
15
+
16
+ #TODO: add authentication and authorization to the API endpoints
17
+
18
+
19
+ @api.route("/control/", strict_slashes=False, methods=['GET'])
20
+ @api.route("/control/<string:instrument>", methods=['POST'])
21
+ def backend_control(instrument: str=None):
22
+ """
23
+ .. :quickref: Backend Control; backend control
24
+
25
+ backend control through http requests
26
+
27
+ .. http:get:: /api/control/
28
+
29
+ :param instrument: instrument name
30
+ :type instrument: str
31
+
32
+ .. http:post:: /api/control/
33
+
34
+ """
35
+ if instrument:
36
+ inst_object = find_instrument_by_name(instrument)
37
+ forms = create_form_from_module(sdl_module=inst_object, autofill=False, design=False)
38
+
39
+ if request.method == 'POST':
40
+ method_name = request.form.get("hidden_name", None)
41
+ form = forms.get(method_name, None)
42
+ if form:
43
+ kwargs = {field.name: field.data for field in form if field.name not in ['csrf_token', 'hidden_name']}
44
+ wait = request.form.get("hidden_wait", "true") == "true"
45
+ output = task_runner.run_single_step(component=instrument, method=method_name, kwargs=kwargs, wait=wait,
46
+ current_app=current_app._get_current_object())
47
+ return jsonify(output), 200
48
+
49
+ snapshot = global_config.deck_snapshot.copy()
50
+ # Iterate through each instrument in the snapshot
51
+ for instrument_key, instrument_data in snapshot.items():
52
+ # Iterate through each function associated with the current instrument
53
+ for function_key, function_data in instrument_data.items():
54
+ # Convert the function signature to a string representation
55
+ function_data['signature'] = str(function_data['signature'])
56
+ return jsonify(snapshot), 200
@@ -6,10 +6,10 @@ from ivoryos.utils.db_models import Script, User, db
6
6
  from ivoryos.utils.utils import post_script_file
7
7
  login_manager = LoginManager()
8
8
 
9
- auth = Blueprint('auth', __name__, template_folder='templates/auth')
9
+ auth = Blueprint('auth', __name__, template_folder='templates')
10
10
 
11
11
 
12
- @auth.route('/auth/login', methods=['GET', 'POST'])
12
+ @auth.route('/login', methods=['GET', 'POST'])
13
13
  def login():
14
14
  """
15
15
  .. :quickref: User; login user
@@ -46,11 +46,11 @@ def login():
46
46
  return redirect(url_for('main.index'))
47
47
  else:
48
48
  flash("Incorrect username or password")
49
- return redirect(url_for('auth.login')), 401
49
+ return redirect(url_for('auth.login'))
50
50
  return render_template('login.html')
51
51
 
52
52
 
53
- @auth.route('/auth/signup', methods=['GET', 'POST'])
53
+ @auth.route('/signup', methods=['GET', 'POST'])
54
54
  def signup():
55
55
  """
56
56
  .. :quickref: User; signup for a new account
@@ -84,7 +84,7 @@ def signup():
84
84
  return render_template('signup.html')
85
85
 
86
86
 
87
- @auth.route("/auth/logout")
87
+ @auth.route("/logout")
88
88
  @login_required
89
89
  def logout():
90
90
  """