neulab/docprompting-conala huggingface dataset:
TESTING  
Enable testing mode. Exceptions are propagated rather than handled by the the app’s error handlers. Extensions may also change their behavior to facilitate easier testing. You should enable this in your own tests. Default: False
TRAP_BAD_REQUEST_ERRORS  
Trying to access a key that doesn’t exist from request dicts like args and form will return a 400 Bad Request error page. Enable this to treat the error as an unhandled exception instead so that you get the interactive debugger. This is a more specific version of TRAP_HTTP_EXCEPTIONS. If unset, it is enabled in debug mode. Default: None
TRAP_HTTP_EXCEPTIONS  
If there is no handler for an HTTPException-type exception, re-raise it to be handled by the interactive debugger instead of returning it as a simple error response. Default: False
flask.url_for(endpoint, **values)  
Generates a URL to the given endpoint with the method provided. Variable arguments that are unknown to the target endpoint are appended to the generated URL as query arguments. If the value of a query argument is None, the whole pair is skipped. In case blueprints are active you can shortcut references to the same blueprint by prefixing the local endpoint with a dot (.). This will reference the index function local to the current blueprint: url_for('.index')
 See URL Building. Configuration values APPLICATION_ROOT and SERVER_NAME are only used when generating URLs outside of a request context. To integrate applications, Flask has a hook to intercept URL build errors through Flask.url_build_error_handlers. The url_for function results in a BuildError when the current app does not have a URL for the given endpoint and values. When it does, the current_app calls its url_build_error_handlers if it is not None, which can return a string to use as the result of url_for (instead of url_for’s default to raise the BuildError exception) or re-raise the exception. An example: def external_url_handler(error, endpoint, values):
    "Looks up an external URL when `url_for` cannot build a URL."
    # This is an example of hooking the build_error_handler.
    # Here, lookup_url is some utility function you've built
    # which looks up the endpoint in some external URL registry.
    url = lookup_url(endpoint, **values)
    if url is None:
        # External lookup did not have a URL.
        # Re-raise the BuildError, in context of original traceback.
        exc_type, exc_value, tb = sys.exc_info()
        if exc_value is error:
            raise exc_type(exc_value).with_traceback(tb)
        else:
            raise error
    # url_for will use this result, instead of raising BuildError.
    return url

app.url_build_error_handlers.append(external_url_handler)
 Here, error is the instance of BuildError, and endpoint and values are the arguments passed into url_for. Note that this is for building URLs outside the current application, and not for handling 404 NotFound errors.  Changelog New in version 0.10: The _scheme parameter was added.   New in version 0.9: The _anchor and _method parameters were added.   New in version 0.9: Calls Flask.handle_build_error() on BuildError.   Parameters 
 
endpoint (str) – the endpoint of the URL (name of the function) 
values (Any) – the variable arguments of the URL rule 
_external – if set to True, an absolute URL is generated. Server address can be changed via SERVER_NAME configuration variable which falls back to the Host header, then to the IP and port of the request. 
_scheme – a string specifying the desired URL scheme. The _external parameter must be set to True or a ValueError is raised. The default behavior uses the same scheme as the current request, or PREFERRED_URL_SCHEME if no request context is available. This also can be set to an empty string to build protocol-relative URLs. 
_anchor – if provided this is added as anchor to the URL. 
_method – if provided this explicitly specifies an HTTP method.   Return type 
str
USE_X_SENDFILE  
When serving files, set the X-Sendfile header instead of serving the data with Flask. Some web servers, such as Apache, recognize this and serve the data more efficiently. This only makes sense when using such a server. Default: False
uWSGI uWSGI is a deployment option on servers like nginx, lighttpd, and cherokee; see FastCGI and Standalone WSGI Containers for other options. To use your WSGI application with uWSGI protocol you will need a uWSGI server first. uWSGI is both a protocol and an application server; the application server can serve uWSGI, FastCGI, and HTTP protocols. The most popular uWSGI server is uwsgi, which we will use for this guide. Make sure to have it installed to follow along.  Watch Out Please make sure in advance that any app.run() calls you might have in your application file are inside an if __name__ ==
'__main__': block or moved to a separate file. Just make sure it’s not called because this will always start a local WSGI server which we do not want if we deploy that application to uWSGI.  Starting your app with uwsgi uwsgi is designed to operate on WSGI callables found in python modules. Given a flask application in myapp.py, use the following command: $ uwsgi -s /tmp/yourapplication.sock --manage-script-name --mount /yourapplication=myapp:app
 The --manage-script-name will move the handling of SCRIPT_NAME to uwsgi, since it is smarter about that. It is used together with the --mount directive which will make requests to /yourapplication be directed to myapp:app. If your application is accessible at root level, you can use a single / instead of /yourapplication. myapp refers to the name of the file of your flask application (without extension) or the module which provides app. app is the callable inside of your application (usually the line reads app = Flask(__name__). If you want to deploy your flask application inside of a virtual environment, you need to also add --virtualenv /path/to/virtual/environment. You might also need to add --plugin python or --plugin python3 depending on which python version you use for your project. Configuring nginx A basic flask nginx configuration looks like this: location = /yourapplication { rewrite ^ /yourapplication/; }
location /yourapplication { try_files $uri @yourapplication; }
location @yourapplication {
  include uwsgi_params;
  uwsgi_pass unix:/tmp/yourapplication.sock;
}
 This configuration binds the application to /yourapplication. If you want to have it in the URL root its a bit simpler: location / { try_files $uri @yourapplication; }
location @yourapplication {
    include uwsgi_params;
    uwsgi_pass unix:/tmp/yourapplication.sock;
}
class flask.views.View  
Alternative way to use view functions. A subclass has to implement dispatch_request() which is called with the view arguments from the URL routing system. If methods is provided the methods do not have to be passed to the add_url_rule() method explicitly: class MyView(View):
    methods = ['GET']

    def dispatch_request(self, name):
        return f"Hello {name}!"

app.add_url_rule('/hello/<name>', view_func=MyView.as_view('myview'))
 When you want to decorate a pluggable view you will have to either do that when the view function is created (by wrapping the return value of as_view()) or you can use the decorators attribute: class SecretView(View):
    methods = ['GET']
    decorators = [superuser_required]

    def dispatch_request(self):
        ...
 The decorators stored in the decorators list are applied one after another when the view function is created. Note that you can not use the class based decorators since those would decorate the view class and not the generated view function!  
classmethod as_view(name, *class_args, **class_kwargs)  
Converts the class into an actual view function that can be used with the routing system. Internally this generates a function on the fly which will instantiate the View on each request and call the dispatch_request() method on it. The arguments passed to as_view() are forwarded to the constructor of the class.  Parameters 
 
name (str) –  
class_args (Any) –  
class_kwargs (Any) –    Return type 
Callable   
  
decorators: List[Callable] = []  
The canonical way to decorate class-based views is to decorate the return value of as_view(). However since this moves parts of the logic from the class declaration to the place where it’s hooked into the routing system. You can place one or more decorators in this list and whenever the view function is created the result is automatically decorated.  Changelog New in version 0.8.  

  
dispatch_request()  
Subclasses have to override this method to implement the actual view function code. This method is called with all the arguments from the URL rule.  Return type 
Union[Response, AnyStr, Dict[str, Any], Generator[AnyStr, None, None], Tuple[Union[Response, AnyStr, Dict[str, Any], Generator[AnyStr, None, None]], Union[Headers, Dict[str, Union[str, List[str], Tuple[str, …]]], List[Tuple[str, Union[str, List[str], Tuple[str, …]]]]]], Tuple[Union[Response, AnyStr, Dict[str, Any], Generator[AnyStr, None, None]], int], Tuple[Union[Response, AnyStr, Dict[str, Any], Generator[AnyStr, None, None]], int, Union[Headers, Dict[str, Union[str, List[str], Tuple[str, …]]], List[Tuple[str, Union[str, List[str], Tuple[str, …]]]]]], WSGIApplication]   
  
methods: Optional[List[str]] = None  
A list of methods this view can handle. 
  
provide_automatic_options: Optional[bool] = None  
Setting this disables or force-enables the automatic options handling.
classmethod as_view(name, *class_args, **class_kwargs)  
Converts the class into an actual view function that can be used with the routing system. Internally this generates a function on the fly which will instantiate the View on each request and call the dispatch_request() method on it. The arguments passed to as_view() are forwarded to the constructor of the class.  Parameters 
 
name (str) –  
class_args (Any) –  
class_kwargs (Any) –    Return type 
Callable
decorators: List[Callable] = []  
The canonical way to decorate class-based views is to decorate the return value of as_view(). However since this moves parts of the logic from the class declaration to the place where it’s hooked into the routing system. You can place one or more decorators in this list and whenever the view function is created the result is automatically decorated.  Changelog New in version 0.8.
dispatch_request()  
Subclasses have to override this method to implement the actual view function code. This method is called with all the arguments from the URL rule.  Return type 
Union[Response, AnyStr, Dict[str, Any], Generator[AnyStr, None, None], Tuple[Union[Response, AnyStr, Dict[str, Any], Generator[AnyStr, None, None]], Union[Headers, Dict[str, Union[str, List[str], Tuple[str, …]]], List[Tuple[str, Union[str, List[str], Tuple[str, …]]]]]], Tuple[Union[Response, AnyStr, Dict[str, Any], Generator[AnyStr, None, None]], int], Tuple[Union[Response, AnyStr, Dict[str, Any], Generator[AnyStr, None, None]], int, Union[Headers, Dict[str, Union[str, List[str], Tuple[str, …]]], List[Tuple[str, Union[str, List[str], Tuple[str, …]]]]]], WSGIApplication]
methods: Optional[List[str]] = None  
A list of methods this view can handle.
provide_automatic_options: Optional[bool] = None  
Setting this disables or force-enables the automatic options handling.
flask.cli.with_appcontext(f)  
Wraps a callback so that it’s guaranteed to be executed with the script’s application context. If callbacks are registered directly to the app.cli object then they are wrapped with this function by default unless it’s disabled.
class flask.ctx._AppCtxGlobals  
A plain object. Used as a namespace for storing data during an application context. Creating an app context automatically creates this object, which is made available as the g proxy.   'key' in g
 
Check whether an attribute is present.  Changelog New in version 0.10.  

   iter(g)
 
Return an iterator over the attribute names.  Changelog New in version 0.10.  

  
get(name, default=None)  
Get an attribute by name, or a default value. Like dict.get().  Parameters 
 
name (str) – Name of attribute to get. 
default (Optional[Any]) – Value to return if the attribute is not present.   Return type 
Any    Changelog New in version 0.10.  

  
pop(name, default=<object object>)  
Get and remove an attribute by name. Like dict.pop().  Parameters 
 
name (str) – Name of attribute to pop. 
default (Any) – Value to return if the attribute is not present, instead of raising a KeyError.   Return type 
Any    Changelog New in version 0.11.  

  
setdefault(name, default=None)  
Get the value of an attribute if it is present, otherwise set and return a default value. Like dict.setdefault().  Parameters 
 
name (str) – Name of attribute to get. 
default (Optional[Any]) – Value to set and return if the attribute is not present.   Return type 
Any    Changelog New in version 0.11.
get(name, default=None)  
Get an attribute by name, or a default value. Like dict.get().  Parameters 
 
name (str) – Name of attribute to get. 
default (Optional[Any]) – Value to return if the attribute is not present.   Return type 
Any    Changelog New in version 0.10.
pop(name, default=<object object>)  
Get and remove an attribute by name. Like dict.pop().  Parameters 
 
name (str) – Name of attribute to pop. 
default (Any) – Value to return if the attribute is not present, instead of raising a KeyError.   Return type 
Any    Changelog New in version 0.11.
setdefault(name, default=None)  
Get the value of an attribute if it is present, otherwise set and return a default value. Like dict.setdefault().  Parameters 
 
name (str) – Name of attribute to get. 
default (Optional[Any]) – Value to set and return if the attribute is not present.   Return type 
Any    Changelog New in version 0.11.
action(*, permissions=None, description=None)  
 New in Django 3.2.  This decorator can be used for setting specific attributes on custom action functions that can be used with actions: @admin.action(
    permissions=['publish'],
    description='Mark selected stories as published',
)
def make_published(self, request, queryset):
    queryset.update(status='p')
 This is equivalent to setting some attributes (with the original, longer names) on the function directly: def make_published(self, request, queryset):
    queryset.update(status='p')
make_published.allowed_permissions = ['publish']
make_published.short_description = 'Mark selected stories as published'
 Use of this decorator is not compulsory to make an action function, but it can be useful to use it without arguments as a marker in your source to identify the purpose of the function: @admin.action
def make_inactive(self, request, queryset):
    queryset.update(is_active=False)
 In this case it will add no attributes to the function.
class AdminSite(name='admin')  
A Django administrative site is represented by an instance of django.contrib.admin.sites.AdminSite; by default, an instance of this class is created as django.contrib.admin.site and you can register your models and ModelAdmin instances with it. If you want to customize the default admin site, you can override it. When constructing an instance of an AdminSite, you can provide a unique instance name using the name argument to the constructor. This instance name is used to identify the instance, especially when reversing admin URLs. If no instance name is provided, a default instance name of admin will be used. See Customizing the AdminSite class for an example of customizing the AdminSite class.
AdminSite.add_action(action, name=None)  
Some actions are best if they’re made available to any object in the admin site – the export action defined above would be a good candidate. You can make an action globally available using AdminSite.add_action(). For example: from django.contrib import admin

admin.site.add_action(export_selected_objects)
 This makes the export_selected_objects action globally available as an action named “export_selected_objects”. You can explicitly give the action a name – good if you later want to programmatically remove the action – by passing a second argument to AdminSite.add_action(): admin.site.add_action(export_selected_objects, 'export_selected')
AdminSite.app_index_template  
Path to a custom template that will be used by the admin site app index view.
AdminSite.disable_action(name)  
If you need to disable a site-wide action you can call AdminSite.disable_action(). For example, you can use this method to remove the built-in “delete selected objects” action: admin.site.disable_action('delete_selected')
 Once you’ve done the above, that action will no longer be available site-wide. If, however, you need to re-enable a globally-disabled action for one particular model, list it explicitly in your ModelAdmin.actions list: # Globally disable delete selected
admin.site.disable_action('delete_selected')

# This ModelAdmin will not have delete_selected available
class SomeModelAdmin(admin.ModelAdmin):
    actions = ['some_other_action']
    ...

# This one will
class AnotherModelAdmin(admin.ModelAdmin):
    actions = ['delete_selected', 'a_third_action']
    ...
AdminSite.each_context(request)  
Returns a dictionary of variables to put in the template context for every page in the admin site. Includes the following variables and values by default:  
site_header: AdminSite.site_header  
site_title: AdminSite.site_title  
site_url: AdminSite.site_url  
has_permission: AdminSite.has_permission()  
available_apps: a list of applications from the application registry available for the current user. Each entry in the list is a dict representing an application with the following keys:  
app_label: the application label 
app_url: the URL of the application index in the admin 
has_module_perms: a boolean indicating if displaying and accessing of the module’s index page is permitted for the current user 
models: a list of the models available in the application  Each model is a dict with the following keys:  
model: the model class 
object_name: class name of the model 
name: plural name of the model 
perms: a dict tracking add, change, delete, and view permissions 
admin_url: admin changelist URL for the model 
add_url: admin URL to add a new model instance     Changed in Django 4.0: The model variable for each model was added.
AdminSite.empty_value_display  
The string to use for displaying empty values in the admin site’s change list. Defaults to a dash. The value can also be overridden on a per ModelAdmin basis and on a custom field within a ModelAdmin by setting an empty_value_display attribute on the field. See ModelAdmin.empty_value_display for examples.
AdminSite.enable_nav_sidebar  
A boolean value that determines whether to show the navigation sidebar on larger screens. By default, it is set to True.
AdminSite.final_catch_all_view  
 New in Django 3.2.  A boolean value that determines whether to add a final catch-all view to the admin that redirects unauthenticated users to the login page. By default, it is set to True.  Warning Setting this to False is not recommended as the view protects against a potential model enumeration privacy issue.
AdminSite.has_permission(request)  
Returns True if the user for the given HttpRequest has permission to view at least one page in the admin site. Defaults to requiring both User.is_active and User.is_staff to be True.
AdminSite.index_template  
Path to a custom template that will be used by the admin site main index view.
AdminSite.index_title  
The text to put at the top of the admin index page (a string). By default, this is “Site administration”.
AdminSite.login_form  
Subclass of AuthenticationForm that will be used by the admin site login view.
AdminSite.login_template  
Path to a custom template that will be used by the admin site login view.
AdminSite.logout_template  
Path to a custom template that will be used by the admin site logout view.
AdminSite.password_change_done_template  
Path to a custom template that will be used by the admin site password change done view.
AdminSite.password_change_template  
Path to a custom template that will be used by the admin site password change view.
AdminSite.register(model_or_iterable, admin_class=None, **options)  
Registers the given model class (or iterable of classes) with the given admin_class. admin_class defaults to ModelAdmin (the default admin options). If keyword arguments are given – e.g. list_display – they’ll be applied as options to the admin class. Raises ImproperlyConfigured if a model is abstract. and django.contrib.admin.sites.AlreadyRegistered if a model is already registered.
AdminSite.site_header  
The text to put at the top of each admin page, as an <h1> (a string). By default, this is “Django administration”.
AdminSite.site_title  
The text to put at the end of each admin page’s <title> (a string). By default, this is “Django site admin”.
AdminSite.site_url  
The URL for the “View site” link at the top of each admin page. By default, site_url is /. Set it to None to remove the link. For sites running on a subpath, the each_context() method checks if the current request has request.META['SCRIPT_NAME'] set and uses that value if site_url isn’t set to something other than /.
AdminSite.unregister(model_or_iterable)  
Unregisters the given model class (or iterable of classes). Raises django.contrib.admin.sites.NotRegistered if a model isn’t already registered.
class apps.AdminConfig  
This is the default AppConfig class for the admin. It calls autodiscover() when Django starts.
class apps.SimpleAdminConfig  
This class works like AdminConfig, except it doesn’t call autodiscover().  
default_site  
A dotted import path to the default admin site’s class or to a callable that returns a site instance. Defaults to 'django.contrib.admin.sites.AdminSite'. See Overriding the default admin site for usage.
default_site  
A dotted import path to the default admin site’s class or to a callable that returns a site instance. Defaults to 'django.contrib.admin.sites.AdminSite'. See Overriding the default admin site for usage.
autodiscover()  
This function attempts to import an admin module in each installed application. Such modules are expected to register models with the admin. Typically you won’t need to call this function directly as AdminConfig calls it when Django starts.
display(*, boolean=None, ordering=None, description=None, empty_value=None)  
 New in Django 3.2.  This decorator can be used for setting specific attributes on custom display functions that can be used with list_display or readonly_fields: @admin.display(
    boolean=True,
    ordering='-publish_date',
    description='Is Published?',
)
def is_published(self, obj):
    return obj.publish_date is not None
 This is equivalent to setting some attributes (with the original, longer names) on the function directly: def is_published(self, obj):
    return obj.publish_date is not None
is_published.boolean = True
is_published.admin_order_field = '-publish_date'
is_published.short_description = 'Is Published?'
 Also note that the empty_value decorator parameter maps to the empty_value_display attribute assigned directly to the function. It cannot be used in conjunction with boolean – they are mutually exclusive. Use of this decorator is not compulsory to make a display function, but it can be useful to use it without arguments as a marker in your source to identify the purpose of the function: @admin.display
def published_year(self, obj):
    return obj.publish_date.year
 In this case it will add no attributes to the function.
InlineModelAdmin.can_delete  
Specifies whether or not inline objects can be deleted in the inline. Defaults to True.
InlineModelAdmin.classes  
A list or tuple containing extra CSS classes to apply to the fieldset that is rendered for the inlines. Defaults to None. As with classes configured in fieldsets, inlines with a collapse class will be initially collapsed and their header will have a small “show” link.