Skip to content

Commit 9c83a99

Browse files
Merge pull request #9 from octoenergy/docs
Various project improvements
2 parents b467056 + ed6a7fa commit 9c83a99

File tree

6 files changed

+77
-44
lines changed

6 files changed

+77
-44
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ version: 2.1
33
jobs:
44
build:
55
docker:
6-
- image: octoenergy/consumer-site-circle-docker:1.12
6+
- image: cimg/python:3.8.13
77
steps:
88
- checkout
99
- run:

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ eggs
1313
develop-eggs
1414

1515
# Testing and local development
16+
.python-version
1617
.idea
1718
.cache
19+
.hypothesis
1820

1921
# Local temporary files
2022
.DS_Store

Dockerfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.7.7-slim AS base
1+
FROM python:3.8.13-slim AS base
22

33
# Create virtualenv and add to path.
44
ENV VIRTUAL_ENV=/opt/venv
@@ -12,8 +12,7 @@ WORKDIR /opt/app
1212

1313
# Install Python requirements. README.md is required as the setup.py file
1414
# refers to it.
15-
COPY README.md .
16-
COPY setup.py .
15+
COPY . .
1716
RUN pip install -e .[dev,test]
1817

1918
# Run subsequent commands as non-root user

LICENSE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2016-2018 Octopus Energy Ltd and individual contributors.
1+
Copyright (c) 2016-2018 Kraken Technologies Ltd and individual contributors.
22
All rights reserved.
33

44
Redistribution and use in source and binary forms, with or without modification,
@@ -11,7 +11,7 @@ are permitted provided that the following conditions are met:
1111
notice, this list of conditions and the following disclaimer in the
1212
documentation and/or other materials provided with the distribution.
1313

14-
3. Neither the name of Octopus Energy Ltd nor the names of its contributors
14+
3. Neither the name of Kraken Technologies Ltd nor the names of its contributors
1515
may be used to endorse or promote products derived from this software without
1616
specific prior written permission.
1717

README.md

Lines changed: 60 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,32 @@
11
# xocto - utilities for Python services
22

3-
This repo houses various shared utilities for Python services at Octopus Energy.
3+
This repo houses various shared utilities for Python services at Kraken
4+
Technologies.
5+
6+
This library works with Python 3.8 and above.
47

58
CI status:
69

710
[![CircleCI](https://circleci.com/gh/octoenergy/xocto/tree/master.svg?style=svg)](https://circleci.com/gh/octoenergy/xocto/tree/master)
811

9-
PyPI detail page: https://pypi.python.org/pypi/xocto
12+
PyPI detail page: <https://pypi.python.org/pypi/xocto>
1013

1114
## Functionality
1215

1316
### Event publishing
1417

1518
Use `events.publish` to publish application events. These will be logged as JSON
16-
to a logger named "events".
19+
to a logger named "events".
1720

1821
Sample usage:
1922

2023
```python
2124
from xocto import events
2225

2326
events.publish(
24-
event="ACCOUNT.CREATED",
27+
event="ACCOUNT.CREATED",
2528
params={
26-
'name': 'Barry Chuckle',
29+
'name': 'Barry Chuckle',
2730
'quote_id': 'xyz123',
2831
},
2932
meta={
@@ -47,7 +50,7 @@ with events.Timer() as t:
4750
events.publish(
4851
event="SOMETHING.HAPPENED",
4952
meta={
50-
"duration_in_ms": t.duration_in_ms
53+
"duration_in_ms": t.duration_in_ms
5154
}
5255
)
5356
```
@@ -75,13 +78,15 @@ from xocto.ranges import Range, RangeBoundaries
7578
[<Range: [3,4)>, <Range: [4,5)>]
7679
```
7780

78-
See [xocto.ranges](xocto/ranges.py) for more details, including examples and in depth technical details.
81+
See [`xocto.ranges`](xocto/ranges.py) for more details, including examples and in
82+
depth technical details.
7983

8084
### Numbers
8185

8286
The `numbers` module is intended as your one-stop shop for all things numbers.
8387

8488
An example of rounding a number to an arbitrary integer base:
89+
8590
```python
8691
from xocto.numbers import quantise
8792

@@ -93,11 +98,14 @@ See [xocto.numbers](xocto/numbers.py) for more details, including examples and i
9398

9499
### The localtime module
95100

96-
This module is a battle tested and well reviewed module for working with dates, times and timezones.
101+
This module is a battle tested and well reviewed module for working with dates,
102+
times and timezones.
97103

98-
It's been over the years internally in Kraken Technologies, and is used heavily internally.
104+
It's been over the years internally in Kraken Technologies, and is used heavily
105+
internally.
99106

100-
The main API it presents is composed of a series of functions which accept a date/datetime object, and manipulate it in one form or another.
107+
The main API it presents is composed of a series of functions which accept a
108+
date/datetime object, and manipulate it in one form or another.
101109

102110
Examples of a few of those:
103111

@@ -114,43 +122,67 @@ from xocto import localtime
114122

115123
See [xocto.localtime](xocto/localtime.py) for more details, including examples and in depth technical details.
116124

125+
## Development
126+
127+
### Installation
128+
129+
Create and activate a Python 3.8 virtualenv then run:
130+
131+
```sh
132+
make install
133+
```
117134

118-
## Contributing
135+
to install the package including development and testing dependencies
119136

120-
Create and activate a virtualenv then:
137+
### Running tests
121138

122-
$ make
139+
Run the test suite with:
123140

124-
Test package locally with:
141+
```sh
142+
make test
143+
```
125144

126-
$ make test
145+
### Running static analysis
127146

128-
and:
147+
Use these make commands
129148

130-
$ make lint
149+
```sh
150+
make lint
151+
make black
152+
make isort
153+
```
131154

132-
Development docker images can be built with:
155+
Docker images for these jobs can be built with:
133156

134-
$ make docker_images
157+
```sh
158+
make docker_images
159+
```
135160

136-
which creates separate images for pytest, isort and black. Each can be run like so:
161+
This creates separate images for pytest, isort and black. Each can be run like
162+
so:
137163

138-
$ docker run -v `pwd`:/opt/app xocto/pytest
139-
$ docker run -v `pwd`:/opt/app xocto/isort
140-
$ docker run -v `pwd`:/opt/app xocto/black
164+
```sh
165+
docker run -v `pwd`:/opt/app xocto/pytest
166+
docker run -v `pwd`:/opt/app xocto/isort
167+
docker run -v `pwd`:/opt/app xocto/black
168+
```
141169

142-
## Release new version
170+
### Publishing
143171

144172
Release to PyPI by:
145173

146174
1. Bumping the version in `setup.py`
147175

148176
2. Updating `CHANGELOG.md`
149177

150-
3. Committing
178+
3. Committing:
151179

152-
$ git commit -am "Bump version to v..."
180+
```sh
181+
git commit -am "Bump version to v..."
182+
```
153183

154-
4. Running:
184+
4. Running:
155185

156-
$ make publish
186+
```sh
187+
make publish
188+
```

setup.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,36 +13,36 @@
1313
setup(
1414
name="xocto",
1515
version=VERSION,
16-
description="Octopus Energy Python service utilities",
16+
description="Kraken Technologies Python service utilities",
1717
long_description=long_description,
1818
long_description_content_type="text/markdown",
1919
url="https://github.com/octoenergy/xocto",
20-
author="Octopus Energy",
20+
author="Kraken Technologies",
2121
author_email="talent@octopus.energy",
2222
license="MIT",
2323
classifiers=[
2424
"Development Status :: 5 - Production/Stable",
2525
"Intended Audience :: Developers",
2626
"Topic :: Software Development :: Build Tools",
2727
"License :: OSI Approved :: MIT License",
28-
"Programming Language :: Python :: 3.6",
28+
"Programming Language :: Python :: 3.8",
2929
],
3030
packages=["xocto", "xocto.events"],
3131
package_data={"xocto": ["py.typed"]},
3232
zip_safe=False,
3333
install_requires=[
34-
"pytz==2022.1",
35-
"django==3.2.13",
36-
"structlog==20.2.0",
37-
"python-dateutil==2.8.2",
34+
"pytz",
35+
"django>=3.2,<4.0",
36+
"structlog>=20.2.0",
37+
"python-dateutil>=2.8.2",
3838
],
3939
extras_require={
40-
"dev": ["wheel==0.29.0", "twine==1.8.1", "black==22.3.0", "isort==5.10.1"],
40+
"dev": ["wheel==0.37.1", "twine==4.0.0", "black==22.3.0", "isort==5.10.1"],
4141
"test": [
4242
"flake8==4.0.1",
43-
"pytest==7.0.1",
43+
"pytest==7.1.2",
4444
"pytest-django==4.5.2",
45-
"hypothesis==5.49.0",
45+
"hypothesis==6.45.1",
4646
"time-machine==2.6.0",
4747
],
4848
},

0 commit comments

Comments
 (0)