Changelog¶
Version 0.5.6¶
Link: https://developers.labsland.com/weblablib/en/0.5.6/ Date: May 23rd, 2020
Changes¶
- Support for bulk operation that obtains multiple reservations at the same time
Version 0.5.5¶
Link: https://developers.labsland.com/weblablib/en/0.5.5/ Date: April 25th, 2020
Changes¶
- Fixed compatibility with Werkzeug >= 1.0.0
- Fixed a bug where sometimes the loop would delete the task before running
- Fixed a potential bug in creating task identifiers
Version 0.5.4¶
Link: https://developers.labsland.com/weblablib/en/0.5.4/ Date: August 26th, 2019
Changes¶
- Fixed bug when storing information in the initialization of a session
Version 0.5.3¶
Link: https://developers.labsland.com/weblablib/en/0.5.3/ Date: August 23rd, 2019
Changes¶
- Before, any call would change current_user.data. Now this only applies to calls that actually modify current_user.data
Version 0.5.2¶
Link: https://developers.labsland.com/weblablib/en/0.5.2/ Date: January 25th, 2019
Bug fixes:¶
- Critical bugfix in get_task(func) not working
Version 0.5.1¶
Link: https://developers.labsland.com/weblablib/en/0.5.1/ Date: January 19th, 2019
Bug fixes:¶
- Critical bugfix in case of abrupt restart while keeping Redis information.
Version 0.5.0¶
Link: https://developers.labsland.com/weblablib/en/0.5.0/ Date: January 17th, 2019
General¶
weblab_usernow contains alsoweblab_user.request_client_dataandweblab_user.request_server_datawhich provides the data passed on theon_startmethod. Also it containsweblab_user.start_datewhich is the millisecond when it started according to WebLab.weblab_user.datahas two new methods:weblab_user.data.retrieve()andweblab_user.data.store(). Now, by default you can change things inweblab_user.datain your views or inon_startand weblablib will automatically push the information to the Redis server whenever the view has finished, as the standardflask.sessionobject. If you have a particularly long view, or you are inside a task, you may want to push data or pull data from redis at some point. For that, you can use those two methods. Note that, as before, there is no merging process: if youstoredata it will override whatever is there (asflask.session). If you changeweblab_user.datainside a task, by default it is not automatically stored unless you force it withstore.
Tasks¶
ensure_uniquehas been replaced byunique='global'. This allows us to put alsounique='user'for concurrent laboratories.WebLabTaskdoes not get updated automatically. This provides more reliability (until now, you could doif not task.finished: (something with task)but it may have finished by then. There are two ways to refresh the information:retrieve(inside or outside the running task) andstore(only inside the task).task.datareturn an immutable dictionary, to enforce the idea that only the task changes the contents of the task.
Bug fixes:¶
- If the
on_disposewas long, it would happen that WebLab would consider the experiment already finished.- UTC issues are fixed (if newer versions of WebLab are used)
- Reduce the verbosity of logs when Redis is restarting
Version 0.4.1¶
Link: https://developers.labsland.com/weblablib/en/0.4.1/ Date: August 19th, 2018
Bug fixes:¶
In some contexts, the poll message receives a temporary error (such as 502). In those cases we try a couple of seconds later instead of automatically kicking out the user.
Version 0.4¶
Link: https://developers.labsland.com/weblablib/en/0.4/ Date: September 6th, 2017
General¶
- Added
WEBLAB_NO_THREADwhich is equivalent toWEBLAB_AUTOCLEAN_THREAD=FalseandWEBLAB_TASK_THREADS_PROCESS=0.
Tasks¶
- A
WebLabTasksupports.join()method. It defaults to.join(timeout=None, error_on_timeout=True), raising an error, but can be configured with those parameters.- It also supports
run_sync(), with the optional named parametertimeout. This guarantees that you can run tasks in a background process such asflask weblab loop.- There is also now a
stop()method and astoppingflag. If you callstop,stoppingwill beTrue. There is also a property calledcurrent_task_stopping.@weblab.task()now supports@weblab.task(ensure_unique=True). If multiple threads attempt to raise the same task, only one will run it (and the rest will fail)- New methods in
WebLab:
weblab.get_running_task(function_or_name)(which returns the any orNone; use withensure_unique=True) andwebalb.get_running_tasks(func_or_name)to obtain all.weblab.join_tasks(function_or_name, timeout=None, stop=False)which callsstop()ifstopand joins all the tasks with that function (or name of function).
WebSockets¶
- Flask-SocketIO support through helpers:
socket_requires_loginandsocket_requires_activebehave similar torequires_loginandrequires_active; but callingdisconnectof Flask-SocketIOsocket_weblab_useris equivalent toweblab_user, but using it in real time without caching. This avoids the typical problems of a long-standing thread with WebSockets
Examples¶
- A new example,
complete, has been added. It includes:
- Example of WebSocket support, including in a task in a different process.
- Example of use of Flask-Babel for internationalization
- Example of use of Flask-Assets for minimizing the static files
CLI changes¶
- Similarly to other Flask projects, all the
weblablibcommands are in a single command group calledweblab. This way, in case of using multiple libraries which include their own commands (such as Flask-Migrate or Flask-Assets), the number of commands in the--helpare low, and there is a low chance of collision (e.g., you might be using a celery-like system that also has arun-taskscommand or aloopcommand). Therefore, since this version:
| Before weblablib 0.4 | Since weblablib 0.4 |
|---|---|
flask fake-new-user |
flask weblab fake new |
flask fake-dispose |
flask weblab fake dispose |
flask fake-status |
flask weblab fake status |
flask loop |
flask weblab loop |
flask run-tasks |
flask weblab run-tasks |
flask clean-expired-users |
flask weblab clean-expired-users |
- When running
flask weblab fake newthe default behavior is to open a web browser.--open-browserremoved, and a new--dont-open-browserflag is available.- Added
flask weblab loop --reload. If you change the source code of your application, it will restart the process automatically.
Version 0.3¶
Link: https://developers.labsland.com/weblablib/en/0.3/ Date: August 29th, 2017
- Added
weblab_user.localefor i18n processing.- Added
weblab_user.experiment_name,weblab_user.category_nameandweblab_user.experiment_idas more metadata about the context on how the laboratory is used.- Added
task.done,task.failed,task.finished,task.running,task.submittedso as to avoid playing with strings.WEBLAB_CALLBACK_URLis now optional, and/callbackby default.- Added
current_taskthat can be called inside a task to get thetask_idor update data.- Added
current_task.dataandcurrent_task.update_dataso as to update JSON-friendly data to measure the progress of the task.- Added
@weblab.user_loader. If set, you can later run sayuser = weblab_user.user, and it returns a user (e.g., from your database)- Supported arguments on
{{ weblab_poll_script() }}:logout_on_close, which logs out when you close the current window (by defaultFalse); andcallbackif you want to be notified when the time has passed or an error occurs.- Add
flask loopfor running tasks and thread cleaners concurrently.
Version 0.2¶
Link: https://developers.labsland.com/weblablib/en/0.2/ Date: August 26th, 2017
Version 0.1 was uploaded to Pypi, etc., but was not production ready (no tests, docs, some bugs, etc.)