Metadata-Version: 2.4
Name: fiftyone_pipeline_core
Version: 4.6.2
Summary: This package defines the essential components of the 51Degrees Pipeline API such as flow elements, flow data and evidence. It also packages together JavaScript served by a pipeline and allows for client side requests for additional data populated by evidence from the client side.
Author: 51Degrees Engineering
Author-email: engineering@51degrees.com
License: EUPL-1.2
Project-URL: Homepage, https://51degrees.com/build-your-own?utm_source=pypi&utm_medium=package&utm_campaign=51degrees-python&utm_content=fiftyone_pipeline_core&utm_term=homepage
Project-URL: Documentation, https://51degrees.com/documentation/_pipeline_api__index.html?utm_source=pypi&utm_medium=package&utm_campaign=51degrees-python&utm_content=fiftyone_pipeline_core&utm_term=documentation
Project-URL: Source, https://github.com/51Degrees/51degrees-python
Classifier: Development Status :: 5 - Production/Stable
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: License :: OSI Approved :: European Union Public Licence 1.2 (EUPL 1.2)
Classifier: Operating System :: OS Independent
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: chevron
Requires-Dist: jsmin
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: license
Dynamic: project-url
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# Pipeline Core

![51Degrees](https://raw.githubusercontent.com/51Degrees/51degrees-python/main/.github/images/logo-160.png "Data rewards the curious") **Python Pipeline Core**

[Developer Documentation](https://51degrees.com/documentation/_pipeline_api__concepts__pipeline_basics.html?utm_source=pypi&utm_medium=package&utm_campaign=51degrees-python&utm_content=fiftyone_pipeline_core&utm_term=pipeline-core "Developer Documentation")

## Introduction

The Pipeline is a generic web request intelligence and data processing solution with the ability to add a range of 51Degrees and/or custom plug ins (Engines) 

## This package fiftyone_pipeline_core

This package defines the essential components of the Pipeline API such as `flow elements`, `flow data` and `evidence`. It also packages together JavaScript served by a pipeline and allows for client side requests for additional data populated by evidence from the client side.

It can be used on its own or with the following additional packages.

- **fiftyone_pipeline_engines** - Adds a specialized type of flow element called an engine which allows for additional features including an auto-updating data file for properties, a service called when a requested property is missing and a caching system.

Engines created by 51Degrees:

- [**fiftyone_devicedetection**](https://pypi.org/project/fiftyone-devicedetection/) - Get details about the devices accessing your web page
- [**fiftyone_location**](https://pypi.org/project/fiftyone-location/) - Get postal address details from the location of devices accessing your web page

## Web integration

The `fiftyone_pipeline_core.web` module helps use a Pipeline in a Flask web
application. `webevidence` takes the evidence from a request,
`set_response_header` sets the response headers the results ask for, and
`javascript_response` and `json_response` answer the requests of the
client-side JavaScript.

A Flow Data cannot be used by two threads at once. Create one for each
request, use it only in the code that handles that request, and close it
when the request ends, which a `with` statement does. To hand work to
another thread or task, read the values it needs from the Flow Data first
and pass those values, not the Flow Data. The example below does both, with
a Pipeline that holds a device detection engine and a `concurrent.futures`
executor.

```python
@app.route("/")
def index():
    with pipeline.create_flowdata() as flowdata:
        flowdata.evidence.add_from_dict(webevidence(request))
        flowdata.process()

        # The other thread gets the browser name, not the Flow Data.
        browser = flowdata.device.browsername
        if browser.has_value():
            executor.submit(record_browser, browser.value())

        response = make_response(render_template("index.html", data=flowdata))
        set_response_header(flowdata, response)
        return response
```

## Element data is reused

Some flow elements reuse their element data from one request to the next. When a flow data is closed, by calling `close()` or at the end of a `with` block, its element data goes back to a pool, and a later request gets a copy of it. So read the values you need before the flow data is closed. A reference to element data, such as `flowdata.device`, that you keep after that raises an exception when you read a property from it, and never gives you another request's values. A value you've already read is unchanged.

## Requirements

* Python 3.8+
* The `flask` python library to run the web examples

## Find out more

- [Build your own](https://51degrees.com/build-your-own?utm_source=pypi&utm_medium=package&utm_campaign=51degrees-python&utm_content=fiftyone_pipeline_core&utm_term=find-out-more-build-your-own)
- [Pipeline API documentation](https://51degrees.com/documentation/_pipeline_api__concepts__pipeline_basics.html?utm_source=pypi&utm_medium=package&utm_campaign=51degrees-python&utm_content=fiftyone_pipeline_core&utm_term=find-out-more-documentation)
- [Pipeline API examples](https://51degrees.com/documentation/_pipeline_api__examples__index.html?utm_source=pypi&utm_medium=package&utm_campaign=51degrees-python&utm_content=fiftyone_pipeline_core&utm_term=find-out-more-examples)
- https://github.com/51Degrees/51degrees-python
