Giter VIP home page Giter VIP logo

brick-example-server's People

Contributors

ctrando avatar dependabot[bot] avatar jbkoh avatar reapor-yurnero avatar tc-imba avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

brick-example-server's Issues

Supporting Brick v1.1.0

Hey Brick-server,

Really interesting project you've got going here. I'd love to learn more, and contribute!

So firstly, I have been able to pull brick-server, adjust my configuration, run the docker-compose up, get a jwt token with docker exec -t brickserver /app/tools/get_jwt_token update the pytest.ini with said jwt and run the tests successfully pytest -c pytest.ini tests/remote

The first thing I wanted to do was to make my own small Brick RDF graph, load it into the system do some entity queries against it, and then write a custom database adapter for it to fetch real BMS system data stored in another system I use.

I can get my test working with version Brick v1.0.3 (see below) but when trying to run the application with v1.1.0 gave me some errors that i haven't been able to address...

I tried setting the configuration.json to this:

    "brick": {
        "dbtype": "virtuoso",
        "host": "http://brickserver-virtuoso:8890/sparql",
        "brick_version": "1.1.0",
        "base_ns": "bldg",
        "base_graph": "brick-base-graph"
    },

But keep getting this error...

aiosparql.client.SPARQLRequestFailed: 500, message='SPARQL Request Failed', url=URL('http://brickserver-virtuoso:8890/sparql'), explanation='Virtuoso HT404 Error Resource "http://brickschema.org/schema/1.1.0/Brick.ttl" not found\n\nSPARQL query:\ndefine sql:big-data-const 0 PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n\nprefix : <bldg>\nprefix base: <bldg>\nprefix brick: <https://brickschema.org/schema/1.1.0/Brick#>\nprefix bf: <https://brickschema.org/schema/1.1.0/BrickFrame#>\nprefix brick_tag: <https://brickschema.org/schema/1.1.0/BrickTag#>\nprefix brick_use: <https://brickschema.org/schema/1.1.0/BrickUse#>\nprefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>\nprefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\nprefix owl: <http://www.w3.org/2002/07/owl#>\nprefix foaf: <http://xmlns.com/foaf/0.1/>\nprefix prov: <http://www.w3.org/ns/prov#>\n\nLOAD <http://brickschema.org/schema/1.1.0/Brick.ttl> into <brick-base-graph>

But when I change my generation file to 1.0.3, as seen here I use this script to generate my Brick schema building graph .ttl

import pdb
from rdflib import RDF, RDFS, OWL, Namespace, Graph, Literal

# of some use: https://github.com/RDFLib/rdflib/tree/master/examples

g = Graph()

BLDG = Namespace("https://example.com/customer_1/building_1#")
g.bind("bldg", BLDG)

BRICK = Namespace("https://brickschema.org/schema/1.0.3/Brick#")
g.bind("brick", BRICK)

# # Should we use BRICK.Tag to get Spectral Timeseries Identifier in the system?
g.add((BRICK.TimeseriesUUID, RDF.type, OWL.Class))
# # We can make TimeseriesUUID a subclass of the more generic "Tag" class.
# # It is easy to change this later.
g.add((BRICK.TimeseriesUUID, RDFS.subClassOf, BRICK.Tag))

# (subject, predicate, object)
g.add((BLDG.BUILDING, RDF.type, BRICK.Building))

# Ability to add information to the nodes via a custom class...
g.add((BLDG.BUILDING, BRICK.TimeseriesUUID, Literal("UUID-1")))
print(f"The value BRICK.TimeseriesUUID on BLDG.BUILDING is {g.value(BLDG.BUILDING,BRICK.TimeseriesUUID)}")

g.add((BLDG.BLOCK_A, RDF.type, BRICK.Space))

g.add((BLDG.DISTRICT_HEATING, RDF.type, BRICK.Boiler))
g.add((BLDG.DISTRICT_HEATING, BRICK.feeds, BLDG.PRIMARY_HOT_WATER))

g.add((BLDG.PRIMARY_HOT_WATER, BRICK.isFedBy, BLDG.DISTRICT_HEATING))
g.add((BLDG.PRIMARY_HOT_WATER, RDF.type, BRICK.Water_Distribution))
g.add((BLDG.PRIMARY_COLD_WATER, RDF.type, BRICK.Water_Distribution))

g.add((BLDG.AHU_A, RDF.type, BRICK.Air_Handler_Unit))

g.add((BLDG["AHU_A.FAN_COIL"], RDF.type, BRICK.Fan_Coil_Unit))

g.add((BLDG["AHU_A.CALCULATED_SETPOINT"], RDF.type, BRICK.Air_Temperature_Setpoint))

g.add((BLDG["AHU_A.CALCULATED_SETPOINT.X1"], RDF.type, BRICK.Outside_Air_Temperature_Low_Reset_Setpoint))

g.add((BLDG["AHU_A.CALCULATED_SETPOINT.X2"], RDF.type, BRICK.Outside_Air_Temperature_High_Reset_Setpoint))
g.add((BLDG["AHU_A.CALCULATED_SETPOINT.Y1"], RDF.type, BRICK.Supply_Air_Temperature_Low_Reset_Setpoint))
g.add((BLDG["AHU_A.CALCULATED_SETPOINT.Y2"], RDF.type, BRICK.Supply_Air_Temperature_High_Reset_Setpoint))


for floor in range(9):
    g.add((BLDG[f"FLOOR_{floor}"], RDF.type, BRICK.Floor))
    g.add((BLDG.BUILDING, BRICK.hasPart, BLDG[f"FLOOR_{floor}"]))
    for sub_valve in range(3):
        g.add((BLDG[f"VAV_A_{floor}_{sub_valve}"], RDF.type, BRICK.Variable_Air_Volume_Box))
        g.add((BLDG[f"HVAC_Zone_A_{floor}_{sub_valve}"], RDF.type, BRICK.HVAC_Zone))
        g.add((BLDG[f"VAV_A_{floor}_{sub_valve}"], BRICK.feeds, BLDG[f"HVAC_Zone_A_{floor}_{sub_valve}"]))
        g.add((BLDG[f"VAV_A_{floor}_{sub_valve}.DPR"], RDF.type, BRICK.Damper))
        g.add((BLDG[f"VAV_A_{floor}_{sub_valve}.DPRPOS"], RDF.type, BRICK.Damper_Position_Setpoint))
        g.add((BLDG[f"VAV_A_{floor}_{sub_valve}.DPR"], BRICK.isControlledBy, BLDG[f"VAV_A_{floor}_{sub_valve}.DPRPOS"]))

g.add((BLDG.AHU_A, BRICK.feeds, BLDG.BLOCK_A))

g.add((BLDG["AHU_A.SUPPLY_TEMPERATURE"], RDF.type, BRICK.Supply_Air_Temperature_Sensor))
g.add((BLDG["AHU_A.CALCULATED_SETPOINT"], BRICK.isMeasuredBy, BLDG["AHU_A.SUPPLY_TEMPERATURE"]))

g.add((BLDG.AHU_A_CALCULATED_SETPOINT, BRICK.hasPoint, BLDG.AHU_A_CALCULATED_SETPOINT_X1))
g.add((BLDG.AHU_A_CALCULATED_SETPOINT, BRICK.hasPoint, BLDG.AHU_A_CALCULATED_SETPOINT_X2))
g.add((BLDG.AHU_A_CALCULATED_SETPOINT, BRICK.hasPoint, BLDG.AHU_A_CALCULATED_SETPOINT_Y1))
g.add((BLDG.AHU_A_CALCULATED_SETPOINT, BRICK.hasPoint, BLDG.AHU_A_CALCULATED_SETPOINT_Y2))

# g.parse("../Brick.ttl", format="ttl")

# basic selection
sensors = g.query(
    """SELECT ?sensor WHERE {
    ?sensor rdf:type brick:Supply_Air_Temperature_Sensor
}"""
)

def display_subject_results(subject, results):
    for row in results:
        import pdb; pdb.set_trace()
        print(f"Subject {subject} -> Predicate {row.p} -> Object {row.o}")


display_subject_results("bldg:DISTRICT_HEATING", g.query("SELECT ?p ?o {bldg:DISTRICT_HEATING ?p ?o}"))
import pdb; pdb.set_trace()

# building = g.query("""SELECT ?building WHERE {?building rdf:type brick:Building}""")
# boiler = g.query("""SELECT ?boiler WHERE {?boiler rdf:type brick:Boiler}""")

res = g.query(
            """
                SELECT ?s WHERE { 
                    ?s brick:isFedBy bldg:DISTRICT_HEATING . 
                    ?s rdf:type brick:Water_Distribution
                }
            """
        )


for row in res:
    print(row.s)

"""
We can "serialize" this model to a file if we want to load it into another program.
"""
with open("custom_brick_v103_sample_graph.ttl", "wb") as f:
    # the Turtle format strikes a balance beteween being compact and easy to read
    f.write(g.serialize(format="ttl"))

So for convenience I write another "test" to try to run a simple sparql query against this graph (one which is confirmed in a pure rdflib toy example in the generation code).

Basically my own version of this test.

def test_load_ttl():
    with open('examples/data/custom_brick_v103_sample_graph.ttl', 'rb') as fp:
        headers = authorize_headers({
            'Content-Type': 'text/turtle',
        })
        resp = requests.post(ENTITY_BASE + '/upload', headers=headers, data=fp, allow_redirects=False)
        assert resp.status_code == 200

        qstr = """
            select ?s where {
              ?s a brick:Supply_Air_Temperature_Sensor
            }
        """

    headers = authorize_headers({
        'Content-Type': 'sparql-query'
    })
    resp2 = requests.post(QUERY_BASE + '/sparql', data=qstr, headers=headers)

    import pdb; pdb.set_trace()

(Pdb) resp2.json()
{'head': {'link': [], 'vars': ['s']}, 'results': {'distinct': False, 'ordered': True, 'bindings': [{'s': {'type': 'uri', 'value': 'https://example.com/customer_1/building_1#AHU_A.SUPPLY_TEMPERATURE'}}]}}

Question: How to initialize Entity/Relation data

I am trying to make mymodel.ttl using brick-example-server.

I have uploaded the initial model(ttl) with v1.03, then I have newly uploaded v1.1 version of the model(ttl).

It seems that the old relationship (v1.03) still remains.

How I can initilaize the model database(Entity/Relationship)

brickserver unable to connect brickserver-postgres

Hi @gtfierro and @jbkoh !

I'm using docker container to setup the brick-server, after docker-composer up all container build up successfully except brickserver, the error log said could not connect to server: Connection refused. Is the server running on host "brickserver-postgres" (172.18.0.3) and accepting TCP/IP connections on port 5432? but I check the ip of container brickserver-postgres and it match the ip as the error log. Do I need to config something to let. the brickserver connect to brickserver-postgres? There are my config.file, error log and some information:

config.json

{
    "timeseries": {
        "dbtype": "timescaledb",
        "dbname": "brick",
        "user": "bricker",
        "password": "brick-demo",
        "host": "brickserver-postgres",
        "port": 5432
    },
    "lockmanager": {
        "dbname": "brick",
        "user": "bricker",
        "password": "brick-demo",
        "host": "brickserver-postgres",
        "port": 5432,
        "dbtype": "postgresql"
    },
    "brick": {
        "dbtype": "virtuoso",
        "host": "http://brickserver-virtuoso:8890/sparql",
        "brick_version": "1.0.3",
        "base_ns": "bldg",
        "base_graph": "brick-base-graph"
    },
    "users": {
        "dbtype": "mongo",
        "host": "mongodb://brickserver-mongo:27017",
        "dbname": "brickserver"
    },
    "hostname": "https://YOUR_HOSTNAME.COM:8000",
    "auth": {
        "jwt": {
            "privkey_path": "/app/configs/jwtRS256.key",
            "pubkey_path": "/app/configs/jwtRS256.key.pub"
        }
    }
}

brickserver error log:

[2020-06-24 19:06:43 +0000] [11] [ERROR] Exception in worker process
brickserver             | Traceback (most recent call last):
brickserver             |   File "/usr/local/lib/python3.7/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
brickserver             |     worker.init_process()
brickserver             |   File "/usr/local/lib/python3.7/site-packages/uvicorn/workers.py", line 57, in init_process
brickserver             |     super(UvicornWorker, self).init_process()
brickserver             |   File "/usr/local/lib/python3.7/site-packages/gunicorn/workers/base.py", line 129, in init_process
brickserver             |     self.load_wsgi()
brickserver             |   File "/usr/local/lib/python3.7/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi
brickserver             |     self.wsgi = self.app.wsgi()
brickserver             |   File "/usr/local/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
brickserver             |     self.callable = self.load()
brickserver             |   File "/usr/local/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load
brickserver             |     return self.load_wsgiapp()
brickserver             |   File "/usr/local/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
brickserver             |     return util.import_app(self.app_uri)
brickserver             |   File "/usr/local/lib/python3.7/site-packages/gunicorn/util.py", line 350, in import_app
brickserver             |     __import__(module)
brickserver             |   File "/app/main.py", line 3, in <module>
brickserver             |     from brick_server import app
brickserver             |   File "/app/brick_server/__init__.py", line 8, in <module>
brickserver             |     from .services.entities import entity_router
brickserver             |   File "/app/brick_server/services/entities.py", line 22, in <module>
brickserver             |     from ..dbs import BrickSparqlAsync
brickserver             |   File "/app/brick_server/dbs.py", line 25, in <module>
brickserver             |     lockmanager_configs['password'],
brickserver             |   File "/app/brick_server/extensions/lockmanager.py", line 21, in __init__
brickserver             |     self.conn = psycopg2.connect(conn_str)
brickserver             |   File "/usr/local/lib/python3.7/site-packages/psycopg2/__init__.py", line 126, in connect
brickserver             |     conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
brickserver             | psycopg2.OperationalError: could not connect to server: Connection refused
brickserver             | 	Is the server running on host "brickserver-postgres" (172.18.0.3) and accepting
brickserver             | 	TCP/IP connections on port 5432?
brickserver             | 
brickserver             | [2020-06-24 19:06:43 +0000] [11] [INFO] Worker exiting (pid: 11)
brickserver             | {"loglevel": "\"debug\"", "workers": 2, "bind": "0.0.0.0:80", "workers_per_core": 1.0, "host": "0.0.0.0", "port": "80"}
brickserver             | [2020-06-24 19:06:44 +0000] [10] [ERROR] Exception in worker process
brickserver             | Traceback (most recent call last):
brickserver             |   File "/usr/local/lib/python3.7/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
brickserver             |     worker.init_process()
brickserver             |   File "/usr/local/lib/python3.7/site-packages/uvicorn/workers.py", line 57, in init_process
brickserver             |     super(UvicornWorker, self).init_process()
brickserver             |   File "/usr/local/lib/python3.7/site-packages/gunicorn/workers/base.py", line 129, in init_process
brickserver             |     self.load_wsgi()
brickserver             |   File "/usr/local/lib/python3.7/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi
brickserver             |     self.wsgi = self.app.wsgi()
brickserver             |   File "/usr/local/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
brickserver             |     self.callable = self.load()
brickserver             |   File "/usr/local/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load
brickserver             |     return self.load_wsgiapp()
brickserver             |   File "/usr/local/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
brickserver             |     return util.import_app(self.app_uri)
brickserver             |   File "/usr/local/lib/python3.7/site-packages/gunicorn/util.py", line 350, in import_app
brickserver             |     __import__(module)
brickserver             |   File "/app/main.py", line 3, in <module>
brickserver             |     from brick_server import app
brickserver             |   File "/app/brick_server/__init__.py", line 8, in <module>
brickserver             |     from .services.entities import entity_router
brickserver             |   File "/app/brick_server/services/entities.py", line 22, in <module>
brickserver             |     from ..dbs import BrickSparqlAsync
brickserver             |   File "/app/brick_server/dbs.py", line 25, in <module>
brickserver             |     lockmanager_configs['password'],
brickserver             |   File "/app/brick_server/extensions/lockmanager.py", line 21, in __init__
brickserver             |     self.conn = psycopg2.connect(conn_str)
brickserver             |   File "/usr/local/lib/python3.7/site-packages/psycopg2/__init__.py", line 126, in connect
brickserver             |     conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
brickserver             | psycopg2.OperationalError: could not connect to server: Connection refused
brickserver             | 	Is the server running on host "brickserver-postgres" (172.18.0.3) and accepting
brickserver             | 	TCP/IP connections on port 5432?
brickserver             | 
brickserver             | [2020-06-24 19:06:44 +0000] [10] [INFO] Worker exiting (pid: 10)
brickserver             | {"loglevel": "\"debug\"", "workers": 2, "bind": "0.0.0.0:80", "workers_per_core": 1.0, "host": "0.0.0.0", "port": "80"}
brickserver             | [2020-06-24 19:06:44 +0000] [1] [INFO] Shutting down: Master
brickserver             | [2020-06-24 19:06:44 +0000] [1] [INFO] Reason: Worker failed to boot.
brickserver             | {"loglevel": "\"debug\"", "workers": 2, "bind": "0.0.0.0:80", "workers_per_core": 1.0, "host": "0.0.0.0", "port": "80"}```

IP and other information about containers:
<img width="1280" alt="Screenshot 2020-06-25 at 4 03 31 AM" src="https://user-images.githubusercontent.com/47412725/85622077-ddc23d00-b698-11ea-9a4b-b9a6485e4b41.png">


Thanks a lot !

Clarify local development setup for contributors

So after commenting out the brickserver container from the docker-compose.yml and running: sh docker/start.sh I get:

Error: '/gunicorn_conf.py' doesn't exist

So I docker exec -it brickserver /bin/bash and found the file in the container because I couldn't divine where it came from via the image...

My goal is to run the three other containers (mongo/postgres/virtuoso) as images and develop locally on the application layer. I'll post other issues I run into here hopefully to streamline the solutions eventual PR.

Docker-compose configuration doesn't work out the box

Using the default docker-compose configuration the brick-server fails because to many connections to Postgres.
Same situation as here #5 (comment)

My workaround is setting the max_connections parameters for the Postgres instance.

Here the snippet in my docker-compose.yml

 brickserver-postgres:
     container_name: brickserver-postgres
     image: "jbkoh/brickserver-postgresql:latest"
     command: postgres -c 'max_connections=300'
     environment: # Below secrets should be matched with the information in `configs.json` too.
       - POSTGRES_USER=bricker
       - POSTGRES_PASSWORD=brick-demo
       - POSTGRES_DB=brick

the interesting line is:

command: postgres -c 'max_connections=300'

Default configuration causes crash in Brickserver due to no OAuth configuration

I'm trying with a fresh clone of the repository, and am using the default docker-compose.yml and configs.json that are copied from the provided template files. Running docker-compose up results in the following error in the brickserver trace:

brickserver             | [2020-06-24 21:04:45 +0000] [1] [INFO] Starting gunicorn 19.9.0
brickserver             | [2020-06-24 21:04:45 +0000] [1] [INFO] Listening at: http://0.0.0.0:80 (1)
brickserver             | [2020-06-24 21:04:45 +0000] [1] [INFO] Using worker: uvicorn.workers.UvicornWorker
brickserver             | [2020-06-24 21:04:45 +0000] [10] [INFO] Booting worker with pid: 10
brickserver             | [2020-06-24 21:04:45 +0000] [11] [INFO] Booting worker with pid: 11
brickserver             | [2020-06-24 21:04:45 +0000] [12] [INFO] Booting worker with pid: 12
brickserver             | [2020-06-24 21:04:45 +0000] [13] [INFO] Booting worker with pid: 13
brickserver             | [2020-06-24 21:04:45 +0000] [14] [INFO] Booting worker with pid: 14
brickserver             | [2020-06-24 21:04:45 +0000] [15] [INFO] Booting worker with pid: 15
brickserver             | [2020-06-24 21:04:45 +0000] [10] [ERROR] Exception in worker process
brickserver             | Traceback (most recent call last):
brickserver             |   File "/usr/local/lib/python3.7/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
brickserver             |     worker.init_process()
brickserver             |   File "/usr/local/lib/python3.7/site-packages/uvicorn/workers.py", line 57, in init_process
brickserver             |     super(UvicornWorker, self).init_process()
brickserver             |   File "/usr/local/lib/python3.7/site-packages/gunicorn/workers/base.py", line 129, in init_process
brickserver             |     self.load_wsgi()
brickserver             |   File "/usr/local/lib/python3.7/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi
brickserver             |     self.wsgi = self.app.wsgi()
brickserver             |   File "/usr/local/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
brickserver             |     self.callable = self.load()
brickserver             |   File "/usr/local/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load
brickserver             |     return self.load_wsgiapp()
brickserver             |   File "/usr/local/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
brickserver             |     return util.import_app(self.app_uri)
brickserver             |   File "/usr/local/lib/python3.7/site-packages/gunicorn/util.py", line 350, in import_app
brickserver             |     __import__(module)
brickserver             |   File "/app/main.py", line 3, in <module>
brickserver             |     from brick_server import app
brickserver             |   File "/app/brick_server/__init__.py", line 8, in <module>
brickserver             |     from .services.entities import entity_router
brickserver             |   File "/app/brick_server/services/entities.py", line 18, in <module>
brickserver             |     from .models import Entity, Relationships, EntityIds, Entities, IsSuccess
brickserver             |   File "/app/brick_server/services/models.py", line 7, in <module>
brickserver             |     from ..auth.authorization import auth_scheme
brickserver             |   File "/app/brick_server/auth/authorization.py", line 30, in <module>
brickserver             |     google_config = configs['auth']['oauth_connections']['google']
brickserver             | KeyError: 'google'
brickserver             | [2020-06-24 21:04:45 +0000] [10] [INFO] Worker exiting (pid: 10)
brickserver             | {"loglevel": "\"debug\"", "workers": 12, "bind": "0.0.0.0:80", "workers_per_core": 1.0, "host": "0.0.0.0", "port": "80"}

If I remove the oauth_connections entry from the configs.json file, then I get this error:

brickserver             | [2020-06-24 21:05:47 +0000] [10] [ERROR] Exception in worker process
brickserver             | Traceback (most recent call last):
brickserver             |   File "/usr/local/lib/python3.7/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
brickserver             |     worker.init_process()
brickserver             |   File "/usr/local/lib/python3.7/site-packages/uvicorn/workers.py", line 57, in init_process
brickserver             |     super(UvicornWorker, self).init_process()
brickserver             |   File "/usr/local/lib/python3.7/site-packages/gunicorn/workers/base.py", line 129, in init_process
brickserver             |     self.load_wsgi()
brickserver             |   File "/usr/local/lib/python3.7/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi
brickserver             |     self.wsgi = self.app.wsgi()
brickserver             |   File "/usr/local/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
brickserver             |     self.callable = self.load()
brickserver             |   File "/usr/local/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load
brickserver             |     return self.load_wsgiapp()
brickserver             |   File "/usr/local/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
brickserver             |     return util.import_app(self.app_uri)
brickserver             |   File "/usr/local/lib/python3.7/site-packages/gunicorn/util.py", line 350, in import_app
brickserver             |     __import__(module)
brickserver             |   File "/app/main.py", line 3, in <module>
brickserver             |     from brick_server import app
brickserver             |   File "/app/brick_server/__init__.py", line 12, in <module>
brickserver             |     from .auth.auth_server import auth_router
brickserver             |   File "/app/brick_server/auth/auth_server.py", line 13, in <module>
brickserver             |     from .authorization import FRONTEND_APP, oauth, _get_user, authenticated, _jwt_pub_key
brickserver             | ImportError: cannot import name 'oauth' from 'brick_server.auth.authorization' (/app/brick_server/auth/authorization.py)
brickserver             | [2020-06-24 21:05:47 +0000] [10] [INFO] Worker exiting (pid: 10)

It looks like the root cause is that auth_server.py imports oauth from authorization.py without ever checking that it is defined

install instruction error

After building local brick-server image, I failed at docker-compose.
It seems image name of brick-server on Step1 on the Readme.md is wrong.

org: DOCKER_BUILDKIT=1 docker build . -t brick_server:minimal

should be: DOCKER_BUILDKIT=1 docker build . -t brick-server:minimal

uploading timeseries sometimes fail. error 500 internal error

Thanks for great implementation!
I have tested using docker-compose on Centos7

When I try to upload relatively long timeseries ( two month of every minutes sensor data), the uploading by posting /data/timeseries does sometimes fails (500 internal error).

The brick server log says:

File "/app/brick_server/services/data.py", line 120, in post
await asyncio.gather(futures)
File "/usr/local/lib/python3.7/site-packages/brick_data/timeseries/asyncpg_wrapper.py", line 279, in add_data
await self._add_number_data(data)
File "/usr/local/lib/python3.7/site-packages/brick_data/timeseries/asyncpg_wrapper.py", line 237, in _add_number_data
res = await self._bulk_upsert_data(encoded_data, 'number')
File "/usr/local/lib/python3.7/site-packages/brick_data/timeseries/asyncpg_wrapper.py", line 249, in _bulk_upsert_data
async with self.pool.acquire() as conn:
AttributeError: 'AsyncpgTimeseries' object has no attribute 'pool'

More description for Ansible

@gtfierro Could you detail the instruction for Ansible a bit more? Especially what should a user fill in for "the remote host"? Is it the hostname of the server that we'd like to run the code?

ERROR: No matching distribution found for get==2019.4.13 -- Dockerfile fails to build

docker-compose up is not working for me. Here is the stack trace:

brickserver           | Timeseries Initialized
brickserver           | {"loglevel": "\"debug\"", "workers": 16, "bind": "0.0.0.0:80", "graceful_timeout": 120, "timeout": 120, "keepalive": 5, "errorlog": "-", "accesslog": "-", "workers_per_core": 1.0, "use_max_workers": null, "host": "0.0.0.0", "port": "80"}
brickserver           | Traceback (most recent call last):
brickserver           |   File "/usr/local/lib/python3.7/site-packages/gunicorn/arbiter.py", line 209, in run
brickserver           |     self.sleep()
brickserver           |   File "/usr/local/lib/python3.7/site-packages/gunicorn/arbiter.py", line 357, in sleep
brickserver           |     ready = select.select([self.PIPE[0]], [], [], 1.0)
brickserver           |   File "/usr/local/lib/python3.7/site-packages/gunicorn/arbiter.py", line 242, in handle_chld
brickserver           |     self.reap_workers()
brickserver           |   File "/usr/local/lib/python3.7/site-packages/gunicorn/arbiter.py", line 525, in reap_workers
brickserver           |     raise HaltServer(reason, self.WORKER_BOOT_ERROR)
brickserver           | gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
brickserver           |
brickserver           | During handling of the above exception, another exception occurred:
brickserver           |
brickserver           | Traceback (most recent call last):
brickserver           |   File "/usr/local/bin/gunicorn", line 8, in <module>
brickserver           |     sys.exit(run())
brickserver           |   File "/usr/local/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 58, in run
brickserver           |     WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
brickserver           |   File "/usr/local/lib/python3.7/site-packages/gunicorn/app/base.py", line 228, in run
brickserver           |     super().run()
brickserver           |   File "/usr/local/lib/python3.7/site-packages/gunicorn/app/base.py", line 72, in run
brickserver           |     Arbiter(self).run()
brickserver           |   File "/usr/local/lib/python3.7/site-packages/gunicorn/arbiter.py", line 229, in run
brickserver           |     self.halt(reason=inst.reason, exit_status=inst.exit_status)
brickserver           |   File "/usr/local/lib/python3.7/site-packages/gunicorn/arbiter.py", line 342, in halt
brickserver           |     self.stop()
brickserver           |   File "/usr/local/lib/python3.7/site-packages/gunicorn/arbiter.py", line 393, in stop
brickserver           |     time.sleep(0.1)
brickserver           |   File "/usr/local/lib/python3.7/site-packages/gunicorn/arbiter.py", line 242, in handle_chld
brickserver           |     self.reap_workers()
brickserver           |   File "/usr/local/lib/python3.7/site-packages/gunicorn/arbiter.py", line 525, in reap_workers
brickserver           |     raise HaltServer(reason, self.WORKER_BOOT_ERROR)
brickserver           | gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
brickserver           | [2021-11-03 16:45:55 +0000] [16] [INFO] Waiting for application shutdown.

I tried updating docker-compose.yml with:

  brickserver:
    container_name: brickserver
    build:
      dockerfile: Dockerfile
    # image: "jbkoh/brickserver:0.1"
    ports:
      - "8000:80"

and modifying Dockerfile by updating the FROM line to FROM tiangolo/uvicorn-gunicorn-fastapi:python3.9

But that leads to requirements.txt referencing modules that are no longer on pypi. The problem packages are:

  • get
  • post

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.