You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- We use [Github Glow](https://guides.github.com/introduction/flow/)
7
-
8
-
9
-
## Commit Message Guidelines
10
-
11
-
- The messages of the commits use [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/)
12
-
- See [Angular guideline](https://github.com/angular/angular/blob/22b96b9/CONTRIBUTING.md#-commit-message-guidelines)
13
-
14
-
15
-
## Installation
16
-
17
-
After cloning this repo, create a [virtualenv](https://virtualenv.pypa.io/en/stable/) and ensure dependencies are installed by running:
18
-
19
-
```sh
20
-
virtualenv venv
21
-
source venv/bin/activate
22
-
pip install -e ".[test]"
23
-
```
24
-
25
-
Well-written tests and maintaining good test coverage is important to this project. While developing, run new and existing tests with:
26
-
27
-
```sh
28
-
pytest --cov=pyms --cov=tests tests/
29
-
```
30
-
31
-
Add the `-s` flag if you have introduced breakpoints into the code for debugging.
32
-
Add the `-v` ("verbose") flag to get more detailed test output. For even more detailed output, use `-vv`.
33
-
Check out the [pytest documentation](https://docs.pytest.org/en/latest/) for more options and test running controls.
34
-
35
-
PyMS supports several versions of Python3. To make sure that changes do not break compatibility with any of those versions, we use `tox` to create virtualenvs for each Python version and run tests with that version. To run against all Python versions defined in the `tox.ini` config file, just run:
36
-
37
-
```sh
38
-
tox
39
-
```
40
-
41
-
If you wish to run against a specific version defined in the `tox.ini` file:
42
-
43
-
```sh
44
-
tox -e py36
45
-
```
46
-
47
-
Tox can only use whatever versions of Python are installed on your system. When you create a pull request, Travis will also be running the same tests and report the results, so there is no need for potential contributors to try to install every single version of Python on their own system ahead of time.
48
-
49
-
## Pipenv
50
-
51
-
### Advantages over plain pip and requirements.txt
52
-
[Pipenv](https://pipenv.readthedocs.io/en/latest/) generates two files: a `Pipfile`and a `Pipfile.lock`.
53
-
*`Pipfile`: Is a high level declaration of the dependencies of your project. It can contain "dev" dependencies (usually test related stuff) and "standard" dependencies which are the ones you'll need for your project to function
54
-
*`Pipfile.lock`: Is the "list" of all the dependencies your Pipfile has installed, along with their version and their hashes. This prevents two things: Conflicts between dependencies and installing a malicious module.
55
-
56
-
### How to...
57
-
58
-
Here the most 'common' `pipenv` commands, for a more in-depth explanation please refer to the [official documentation](https://pipenv.readthedocs.io/en/latest/).
59
-
60
-
#### Install pipenv
61
-
```bash
62
-
pip install pipenv
63
-
```
64
-
65
-
#### Install dependencies defined in a Pipfile
66
-
```bash
67
-
pipenv install
68
-
```
69
-
70
-
#### Install both dev and "standard" dependencies defined in a Pipfile
71
-
```bash
72
-
pipenv install --dev
73
-
```
74
-
75
-
#### Install a new module
76
-
```bash
77
-
pipenv install django
78
-
```
79
-
80
-
#### Install a new dev module (usually test related stuff)
81
-
```bash
82
-
pipenv install nose --dev
83
-
```
84
-
85
-
#### Install dependencies in production
86
-
```bash
87
-
pipenv install --deploy
88
-
```
89
-
90
-
#### Start a shell
91
-
```bash
92
-
pipenv shell
93
-
```
3
+
See this [webpage](https://python-microservices.github.io/contributing/)
94
4
95
5
## Documentation
96
6
@@ -106,60 +16,4 @@ This project use MkDocs
106
16
mkdocs.yml # The configuration file.
107
17
docs/
108
18
index.md # The documentation homepage.
109
-
... # Other markdown pages, images and other files.
110
-
111
-
## Tutorial: Create your own service
112
-
113
-
* First, you must create a file with the name of your service inside of `pyms.flask.service`, for example,
114
-
"myawesomesrv":
115
-
116
-
pyms/flask/services/myawesomesrv.py
117
-
```python
118
-
from pyms.flask.services.driver import DriverService
119
-
120
-
121
-
classService(DriverService):
122
-
service ="myawesomesrv"
123
-
default_values = {
124
-
"myvalue": 0,
125
-
"myvalue2": 1
126
-
}
127
-
```
128
-
129
-
* Now, you can configure your service from `config.yml`
130
-
```yaml
131
-
pyms:
132
-
config:
133
-
myawesomesrv:
134
-
myvalue: 5
135
-
```
136
-
137
-
* Your service will be instanced inside the `ms` object in `flask.current_app` object. For example, with the last config,
138
-
you could print the folowing code:
139
-
140
-
```python
141
-
from flask import jsonify, current_app
142
-
143
-
from pyms.flask.app import Microservice
144
-
145
-
ms = Microservice(service="my-minimal-microservice", path=__file__)
146
-
app = ms.create_app()
147
-
148
-
149
-
@app.route("/")
150
-
def example():
151
-
return jsonify({
152
-
"myvalue": current_app.ms.myawesomesrv.myvalue,
153
-
"myvalue2": current_app.ms.myawesomesrv.myvalue2
154
-
})
155
-
156
-
157
-
if __name__ == '__main__':
158
-
app.run()
159
-
```
160
-
161
-
This would be the output in `http://localhost:5000/`:
162
-
163
-
```json
164
-
{"myvalue": 5, "myvalue2": 1}
165
-
```
19
+
... # Other markdown pages, images and other files.
Then, initialize the service defined in the 1.2 block. See [Services](./docs/services.md) for more details.
101
-
102
-
2. Initialize a [Flask](https://flask.palletsprojects.com/en/1.1.x/) instance, [Connexion](https://github.com/zalando/connexion)
103
-
if it was defined in the pyms configuration block, create a tracer, add health-check blueprint, initialize libs and set
104
-
the PyMS Microservice in `ms` attribute and you can access to it with `current_app.ms`.
105
-
This steps has their each functions and you can easy
106
-
override it.
107
-
108
-
3. `create_app` returns the flask instance which you can interact with as a typical flask app
109
-
110
-
See [Documentation](https://py-ms.readthedocs.io/en/latest/) to learn more.
39
+
See our [quickstart webpage](https://python-microservices.github.io/quickstart/)
111
40
112
41
## Create a project from scaffold
113
42
114
-
PyMS has a command line option to create a project template like [Microservices Scaffold](https://github.com/python-microservices/microservices-scaffold).
115
-
This command uses [cookiecutter](https://github.com/cookiecutter/cookiecutter) to download and install this [template](https://github.com/python-microservices/microservices-template)
116
-
117
-
**[Warning]** You must run first `pip install cookiecutter==1.7.0`
project_name [Python Microservices Boilerplate]: example project
128
-
project_folder [example_project]:
129
-
project_short_description [Python Boilerplate contains all the boilerplate you need to create a Python package.]:
130
-
create_model_class [y]:
131
-
microservice_with_swagger_and_connexion [y]:
132
-
microservice_with_traces [y]:
133
-
microservice_with_metrics [y]:
134
-
application_root [/example_project]:
135
-
Select open_source_license:
136
-
1 - MIT license
137
-
2 - BSD license
138
-
3 - ISC license
139
-
4 - Apache Software License 2.0
140
-
5 - GNU General Public License v3
141
-
6 - Not open source
142
-
Choose from 1, 2, 3, 4, 5, 6 [1]:
143
-
```
144
-
145
-
When you finish introducing the options, a project will be created in `[project_folder]` folder
43
+
See our [Create a project from scaffold webpage](https://python-microservices.github.io/quickstart/#create-a-project-from-scaffold)
146
44
147
45
## How To contribute
148
46
149
-
We appreciate opening issues and pull requests to make PyMS even more stable & useful! See [This doc](CONTRIBUTING.md)
150
-
for more details.
47
+
We appreciate opening issues and pull requests to make PyMS even more stable & useful! See [This doc](https://python-microservices.github.io/contributing/)
0 commit comments