README.md 3.94 KB
Newer Older
Chad Leong's avatar
Chad Leong committed
1
2
# LAS Loader utility for Wellbore DDMS

3
## :exclamation: This is currently in development
Chad Leong's avatar
Chad Leong committed
4

Chad Leong's avatar
Chad Leong committed
5
6
7
8
9
## Description

1. This will be the OSDU LAS loader utility to support Wellbore DDMS.

2. This is a wrapper behind the Wellbore DDMS [API](https://community.opengroup.org/osdu/platform/domain-data-mgmt-services/wellbore/wellbore-domain-services/-/blob/master/spec/generated/openapi.json)
10
11
12

## Development

13
The application uses a virtual environment managed by pipenv. To execute the application and run the tests you will need to install Python 3.9 and pipenv.
14
15
16
The source code and unit test are stored in the `src` folder.

To download the package dependencies for the virtual environment change to the src folder and run:
17

18
19
20
21
22
```
pipenv install --dev
```

To run the tests and flake8 linting:
23

24
25
```
pipenv run flake8
Gregory Harris's avatar
Gregory Harris committed
26
pipenv run pytest
27
28
```

Greg Harris's avatar
Greg Harris committed
29
Alternatively, an interactive shell in the virtual environment can be created by running:
30

31
32
33
34
35
36
37
```
pipenv shell
```

### Adding package dependencies

Package dependencies are added using the pipenv command. Dependencies required for only the unit tests should be added to the `[dev-packages]` of the `Pipfile` by using:
38

39
40
41
```
pipenv install --dev package_name
```
42

43
Production packages should be installed using:
44

45
46
```
pipenv install package_name
47
```
Gregory Harris's avatar
Gregory Harris committed
48
49
50
51
52

### Usage via the command line interface

To invoke the CLI using the virtual environment and from within the `src` folder:
```
Greg Harris's avatar
Greg Harris committed
53
pipenv run python -m lasloader.lascli <group> <command> <options>
Gregory Harris's avatar
Gregory Harris committed
54
```
Niall McDaid's avatar
Niall McDaid committed
55
Available groups are `fileload`, `ingest`, `list`, `update` and `download`. Help can be obtained with the `-h` option.
Gregory Harris's avatar
Gregory Harris committed
56
```
Greg Harris's avatar
Greg Harris committed
57
58
59
pipenv run python -m lasloader.lascli -h
pipenv run python -m lasloader.lascli fileload -h
pipenv run python -m lasloader.lascli fileload convert -h
Gregory Harris's avatar
Gregory Harris committed
60
61
```

Niall McDaid's avatar
Niall McDaid committed
62
63
A token is required to access an OSDU instance. The `-t/--token` option is used to specify the token, this is a string. As tokens are long strings we recommend that the token is stored in an environment variable.
For example, on a Windows PowerShell prompt:
Greg Harris's avatar
Greg Harris committed
64
65
```
set OSDUTOKEN <token>
Greg Harris's avatar
Greg Harris committed
66
pipenv run python -m lasloader.lascli ingest wellbore -t $OSDUTOKEN
Greg Harris's avatar
Greg Harris committed
67
```
Niall McDaid's avatar
Niall McDaid committed
68
Or Windows command prompt:
Greg Harris's avatar
Greg Harris committed
69
70
```
set OSDUTOKEN=<token>
Greg Harris's avatar
Greg Harris committed
71
pipenv run python -m lasloader.lascli ingest wellbore -t %OSDUTOKEN%
Greg Harris's avatar
Greg Harris committed
72
73
```

Niall McDaid's avatar
Niall McDaid committed
74
75
76
Many commands require a bearer token and filepath to a configuration file. If these are set as environment variables (named 
'OSDUTOKEN' and 'CONFIGPATH' respectively), it is not necessary to provide them as arguments for commands (the CLI defaults to
use the environment variable).
Gregory Harris's avatar
Gregory Harris committed
77

78
79
80
81
82
83
84
85
86
## Deploy

Before build and deploy ensure that the setup.py and the pipfile.lock dependencies synced, by running:
```
pipenv-setup sync
```

Check that the version number in the `src/lasloader/__init__.py` file is correct.

Gregory Harris's avatar
Gregory Harris committed
87
### Install from repository source
88

Gregory Harris's avatar
Gregory Harris committed
89
The lasloader module can be installed in edit mode on the command line by running the following command in the root folder of the repository:
90
91
92
```
pip install -e .
```
Gregory Harris's avatar
Gregory Harris committed
93

94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
The LAS CLI can then be accessed using the command:
```
lascli
```

Or alternatively using a virtual environment, install with:
```
pipenv install -e .
```

This installs the package in a virtual environment. The CLI can then be run using:
```
pipenv run lascli
```

### Creating distribution archives

To create a distribution run:

```
python setup.py sdist bdist_wheel
```

This will create both source and binary wheel distributions. The package can then be deployed using:
```
pip install .
```

### Publish the package distribution

To be determined...

## Config file
Gregory Harris's avatar
Gregory Harris committed
127

Greg Harris's avatar
Greg Harris committed
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
The LASCLI requires a configuration file that has the following JSON structure:
```
{
    "data_partition_id": "opendes",
    "acl_domain": "contoso.com",
    "legal":
    {
        "legaltags": ["opendes-public-usa-dataset-7643990"],
        "otherRelevantDataCountries": ["US"],
        "status": "compliant"    
    },
    "data": {
        "default": {
            "viewers": [ "data.default.viewers@opendes.contoso.com" ],
            "owners": [ "data.default.owners@opendes.contoso.com" ]
        }
    }
}
```