Metadata-Version: 2.1
Name: fracx
Version: 0.1.16
Summary: FracX is a library that can be used to interface with PDS Energy's FracX platform for exchanging frac schedules.
Home-page: https://github.com/la-mar/permian-frac-exchange
License: MIT
Keywords: fracx,frac,oil,gas
Author: Brock Friedrich
Author-email: brocklfriedrich@gmail.com
Requires-Python: >=3.6.5,<4.0.0
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Provides-Extra: mssql
Requires-Dist: aiocontextvars (>=0.2.2,<0.3.0)
Requires-Dist: attr (>=0.3.1,<0.4.0)
Requires-Dist: attrdict (>=2.0.1,<3.0.0)
Requires-Dist: attrs (>=19.3.0,<20.0.0)
Requires-Dist: click (>=7.0,<8.0)
Requires-Dist: colorama (>=0.4.3,<0.5.0)
Requires-Dist: coverage[toml] (>=5.0.2,<6.0.0)
Requires-Dist: cython (>=0.29.14,<0.30.0); extra == "mssql"
Requires-Dist: datadog (>=0.33.0,<0.34.0)
Requires-Dist: flask-sqlalchemy (>=2.4.1,<3.0.0)
Requires-Dist: json_log_formatter (>=0.2.0,<0.3.0)
Requires-Dist: logutils (>=0.3.5,<0.4.0)
Requires-Dist: psycopg2-binary (>=2.8.4,<3.0.0)
Requires-Dist: pymssql (>=2.1.4,<3.0.0); extra == "mssql"
Requires-Dist: pyparsing (>=2.4.6,<3.0.0)
Requires-Dist: python-dateutil (>=2.8.1,<3.0.0)
Requires-Dist: python-dotenv (>=0.10.3,<0.11.0)
Requires-Dist: pyyaml (>=5.2,<6.0)
Requires-Dist: sqlalchemy (>=1.3.12,<2.0.0)
Requires-Dist: tomlkit (>=0.5.8,<0.6.0)
Requires-Dist: xlrd (>=1.2.0,<2.0.0)
Project-URL: Repository, https://github.com/la-mar/permian-frac-exchange
Description-Content-Type: text/markdown

# permian-frac-exchange

<div style="text-align:center;">
  <table >
    <tr>
      <a href="https://pypi.python.org/pypi/fracx/">
        <img src="https://img.shields.io/pypi/pyversions/fracx.svg" />
      </a>
      <a href="https://codecov.io/gh/la-mar/permian-frac-exchange">
        <img src="https://codecov.io/gh/la-mar/permian-frac-exchange/branch/master/graph/badge.svg" />
      </a>
      <a href="https://circleci.com/gh/la-mar/permian-frac-exchange">
        <img src="https://circleci.com/gh/la-mar/permian-frac-exchange.svg?style=svg" />
      </a>
    </tr>

  </table>
</div>

<p>The FracX Python library is a tool to interface with <a href="https://pdsenergy.com/frac-interference-exchange"/>PDS Energy's</a> FracX platform, used to submit and download frac schedules. Currently, the project interfaces with the FTP import/export service provided by PDS. As other means of integration become available from PDS, those means will be incorporated into this project as additional ways to import and export data from FracX.</p>

Available on <a href="https://pypi.python.org/pypi/fracx/">PyPI</a> and <a href="https://hub.docker.com/repository/docker/driftwood/fracx">Docker</a>

<br/>

## Installation

Install with pipx:

```bash
pipx install fracx
```

   <br/>

## Usage

#### Set environment variables:

```bash

export FRACX_FTP_USERNAME=my_fracx_username
export FRACX_FTP_PASSWORD=my_fracx_password
export FRACX_DATABASE_USERNAME=my_database_username
export FRACX_DATABASE_PASSWORD=my_database_passowrd
export FRACX_DATABASE_HOST=my.host.db
export FRACX_DATABASE_NAME=my_database
export FRACX_DATABASE_SCHEMA=my_schema
export FRACX_TABLE_NAME=frac_schedules

```

####

Initialize the database:

```bash
fracx db init
```

Initialization creates one table and one view in the target database:

- frac_schedules (or the value of FRACX_TABLE_NAME)
- frac_schedules_by_api10 (or the value of FRACX_TABLE_NAME+"\_by_api10")

Re-running the db init command will attempt to create the table or view if they dont already exist. It will NOT drop an existing table or view. This must be done manually.

#### Run the app

Run the app:

```bash
fracx run collector
```

A successful execution will yield the following output:

<pre>
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                app config: fracx.config.ProductionConfig
                flask app: fracx.manage.py
                flask env: production
                backend: postgres://fracx:***@db:5432/driftwood
                collector: sftp.pdswdx.com
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Starting download from sftp.pdswdx.com...
Download successful (download size: 70.58 KB, download_time: 0.0s)
frac_schedules.core_insert_update_on_conflict: inserted 625 records (1.28s)
</pre>
<br/>

## Configuration Reference

Environment variables reference:

| name                    | default         | description                               |
| ----------------------- | --------------- | ----------------------------------------- |
| FRACX_FTP_URL           | sftp.pdswdx.com | url to the remote ftp server              |
| FRACX_FTP_PORT          | 21              | port for the ftp server connection        |
| FRACX_FTP_INPATH        | /Inbound        | ftp directory where uploads will be saved |
| FRACX_FTP_OUTPATH       | /Outbound       | ftp directory to look for downloads in    |
| FRACX_FTP_USERNAME      | ""              | username for ftp authentication           |
| FRACX_FTP_PASSWORD      | ""              | password for ftp authentication           |
| FRACX_DATABASE_USERNAME | ""              | username for database authentication      |
| FRACX_DATABASE_PASSWORD | ""              | password for database authentication      |
| FRACX_DATABASE_DIALECT  | postgres        | database dialect ("postgres" or "mssql")  |
| FRACX_DATABASE_HOST     | localhost       | database host name                        |
| FRACX_DATABASE_PORT     | 5432            | database port                             |
| FRACX_DATABASE_NAME     | postgres        | database name                             |
| FRACX_TABLE_NAME        | frac_schedules  | database table to store frac schedules    |

<!--
The application can be configured with environment variables that are passed into the container at runtime. Environment variables can either be defined at the system level or in a file named '.env' in the project's root directory.
<br/>

### Saving output to a Postgres database

<br/>

##### Using a .env file

Example configuration with .env file:

.env

When specifying configuration in a .env file, include it in docker-compose so the configuration is passed into the container at runtime.

docker-compose.yml

```yaml
version: "3.7"

services:
  collector:
    image: driftwood/fracx
    env_file: .env
```

<br/>
<br/>
##### Using docker-compose.yml

Example configuration directly in the docker-compose.yml file:

```yaml
services:
  collector:
    image: driftwood/fracx
    environment:
      FRACX_FTP_USERNAME: YOUR_FRACX_FTP_UERNAME
      FRACX_FTP_PASSWORD: YOUR_FRACX_FTP_PASSWORD
      FRACX_DATABASE_USERNAME: YOUR_DATABASE_USERNAME
      FRACX_DATABASE_PASSWORD: YOUR_DATABASE_PASSWORD
      FRACX_DATABASE_HOST: YOUR_DATABASE_HOST
      FRACX_DATABASE_NAME: YOUR_DATABASE_NAME
      FRACX_DATABASE_SCHEMA: fracx
      FRACX_TABLE_NAME: frac_schedules
``` -->

