The app-blank template contains an initial state that does not execute any commands other than transitioning to the terminal state. This template is a starting point for implementing apps by adding more states and operations.
For registering and testing your apps or using other apps, please visit FeatureCloud.ai. And for more information about FeatureCloud architecture, please refer to The FeatureCloud AI Store for Federated Learning in Biomedicine and Beyond [1].
FeatureCloud library facilitates app development inside the FeatureCloud platform. To develop apps, developers should define their states and register them to the default app.
For defining new states, in general, developers can use AppState
which supports different communications, transitions, logging, and operations.
AppState
is the building block of FeatureCloud apps that covers
all the scenarios with the verifying mechanism. Each state of
the app should extend AppState
, which is an abstract class with two specific abstract methods:
register
: should be implemented by apps to register possible transitions between the current state to other states. This method is part of verifying mechanism in FeatureCloud apps that ensures logically eligible roles can participate in the current state and transition to other ones.run
: executes all operations and calls for communication between FeatureCloud clients.run
is another part of the verification mechanism in FeatureCloud library, that ensures the transitions to other states are logically correct by returning the name of the next state.
For each state, developers should extend one of the abstract states and call the helper function to automatically register the state in the default FeatureCloud app:
@app_state(name='initial', role=Role.BOTH, app_name='example')
class ExampleState(AppState):
def register(self):
self.register_transition('terminal', Role.BOTH)
def run(self):
self.read_config()
self.app.log(self.config)
return 'terminal'
Once app implementation is done, for building the docker image for testing, or adding it to FeatureCloud AI store, developers should provide following files.
For dockerizing apps, regardless of their applications, there should be some specific files:
Developers should ensure that these files with same structure and content are exist in the same directory as their app implementation.
All app-specific files should be included data or codes that are strictly dependent to app's functionality.
Each app should be implemented in a directory that includes the main.py
file which in turn includes either direct
implementation of states or importing them. Moreover, main
should import bottle
and api
package:
from bottle import Bottle
from api.http_ctrl import api_server
from api.http_web import web_server
import apps.examples.dice
from engine.app import app
server = Bottle()
Here we imported dice
app from our apps
package which because of putting
app_state
on top of state classes,
merely importing the states register them into the app
instance.
For running the app, inside a docker container, app.register()
should be called to register and verify all transitions; next, api and servers should mount at corresponding paths; and finally
server is ready to run the app.
app.register()
server.mount('/api', api_server)
server.mount('/web', web_server)
server.run(host='localhost', port=5000)
All of aforementioned codes, except for importing the app, or alternatively, implementing states, can be exactly same for all apps.
for installing required python libraries inside the docker image, developers should provide a list of libraries in requirements.txt. Some requirements are necessary for FeatureCloud library, which should always be listed, are:
bottle
jsonpickle
joblib
numpy
bios
pydot
pyyaml
And the rest should be all other app required libraries.
Each app may need some hyper-parameters or arguments that should be provided by the end-users. Such data should be included
in config.yml
which should be read and interpreted by the app.
[1] Matschinske, J., Späth, J., Nasirigerdeh, R., Torkzadehmahani, R., Hartebrodt, A., Orbán, B., Fejér, S., Zolotareva, O., Bakhtiari, M., Bihari, B. and Bloice, M., 2021. The FeatureCloud AI Store for Federated Learning in Biomedicine and Beyond. arXiv preprint arXiv:2105.05734.