Skip to content

michaldeutch/cortex

Repository files navigation

build status coverage

cortex

Installation

  1. Clone the repository and enter it:

    $ git clone git@github.com:michaldeutch/cortex.git
    ...
    $ cd cortex/
  2. Run the installation script and activate the virtual environment:

    $ ./scripts/install.sh
    ...
    $ source .env/bin/activate
    [cortex] $ # you're good to go!
  3. To check that everything is working as expected, run the tests:

    [cortex] $ pytest tests/
    ...

Quick Start

  1. Run everything:

    [cortex] $ ./run_pipeline.sh
  2. Send you own .mind file (can be .mind.gz):

    [cortex] $ python -m cortex.client upload-sample <mind_file>
  3. Wait for it to finish and check out your browser at 'http://localhost:8080/'. keep refreshing!

HowTo add Parser?

  1. Add your on <parser>.py file here

  2. Declare in <parser>.py one of the two:

    • Class in the format:
    class MyParser:
       field = 'parser_name'
       def parse(self, data):
           ...
    • Method in the format:
    def parse_parser(data):
       ...
    
    parse_parser.field = 'parser_name'

Usage

  • Client

    from cortex.client import upload_sample
    
    upload_sample(host='127.0.0.1', port=8000, path='sample.mind.gz')

    or

    [cortex] $ python -m cortex.client upload-sample \
        -h/--host '127.0.0.1'             \
        -p/--port 8000                    \
        'snapshot.mind.gz'
    
  • Server

    from cortex.server import run_server
    def print_message(message):
      print(message)
    run_server(host='127.0.0.1', port=8000, publish=print_message)

    or

    [cortex] $ python -m cortex.server run-server \
        -h/--host '127.0.0.1'          \
        -p/--port 8000                 \
        'rabbitmq://127.0.0.1:5672/'
  • Parser

    from cortex.parsers import run_parser
    data = {'snapshot': ..., 'user_id': 1}
    result = run_parser('pose', data)

    or

    [cortex] $  python -m cortex.parsers parse 'pose' 'snapshot.raw' > 'pose.result'
    [cortex] $   python -m cortex.parsers run-parser 'pose' 'rabbitmq://127.0.0.1:5672/'
  • Saver

    from cortex.saver import Saver
    import json
    
    saver = Saver(database_url='mongodb://127.0.0.1/27017')
    saver.save('pose', json.dumps({
        'user_id': 1,
        'timestamp': 132,
        'content': 'data'
    }))

    or

    [cortex] $  python -m cortex.saver save                     \
        -d/--database 'postgresql://127.0.0.1:5432' \
       'pose'                                       \
       'pose.result' 
  • Saver

    from cortex.api import run_api_server
    
    run_api_server(
      host='127.0.0.1', 
      port=5000, 
      database_url='mongodb://127.0.0.1/27017')

    or

    [cortex] $  python -m cortex.api run-server \
        -h/--host '127.0.0.1'       \
        -p/--port 5000              \
        -d/--database 'mongodb://127.0.0.1/27017'
  • Cli

      $ python -m cortex.cli get-users
      …
      $ python -m cortex.cli get-user 1
      …
      $ python -m cortex.cli get-snapshots 1
      …
      $ python -m cortex.cli get-snapshot 1 2
      …
      $ python -m cortex.cli get-result 1 2 'pose'
  • Gui - React reflecting Api

    from cortex.gui import run_server
    
    run_server(
      host='127.0.0.1', 
      port=8080, 
      api_host='127.0.0.1',
      api_port=5000
    )

    or

    [cortex] $ python -m cortex.gui run-server \
        -h/--host '127.0.0.1'       \
        -p/--port 8080              \
        -H/--api-host '127.0.0.1'   \
        -P/--api-port 5000

About

Project for Advanced System Design, TAU

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages