1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
|
%global _empty_manifest_terminate_build 0
Name: python-canopy
Version: 8.38
Release: 1
Summary: Python Client for the Canopy Simulation API
License: MIT
URL: https://github.com/canopysimulations/canopy-python/
Source0: https://mirrors.nju.edu.cn/pypi/web/packages/5e/41/830fbf1d5a3198754084183c667fa0ccc17fcf248553eec18ecff8ec0c84/canopy-8.38.tar.gz
BuildArch: noarch
%description
# Installation
### Versioning
This library uses [SimVer](http://simver.org/) versioning, where a change in the major version number indicates a
breaking change and a change in the minor version number indicates a non-breaking change (such as an additional
feature or bug fix).
### Changelog
The changelog is available [here](CHANGELOG.md).
### Requirements.
This library has been tested on Python 3.6 and higher.
### pip install
```sh
pip install canopy
```
You may need to run `pip` with root permission: `sudo pip install canopy`.
From a Jupyter Notebook you can run `!pip install canopy`.
### Setuptools
Install via [Setuptools](http://pypi.python.org/pypi/setuptools).
```sh
python setup.py install --user
```
(or `sudo python setup.py install` to install the package for all users)
### Running Tests
Unit tests can be run with:
```
pytest canopy
```
Integration tests can be run with:
```
pytest integration_tests
```
To run the integration tests you'll need to ensure you have an environment variable called `CANOPY_PYTHON_INTEGRATION_TEST_CREDENTIALS`
containing the string `<client_id>|<client_secret>|<username>|<tenant_name>|<password>`.
# Getting Started
## Example Usage
See the [Canopy Python Examples](https://github.com/CanopySimulations/canopy-python-examples) repository for example usage.
## Introduction
This package is designed for customers of [Canopy Simulations](https://www.canopysimulations.com/) who would like
to access the Canopy API from Python, for example using Jupyter Notebooks.
Currently the library is split into two parts:
- The client generated using the OpenAPI toolset is located in the "canopy/openapi" folder.
We don't have a great deal of control over how this code looks, but it should give a fairly complete interface to the main API.
- One folder up from that in the "canopy" folder we are adding helper functions which wrap common use cases in simple functions.
You can also use these functions as a reference to using the OpenAPI generated code.
When using the library you generally start by creating a `canopy.Session` object.
The session object manages authentication, and the caching of user settings.
Calling `session.authentication.authenticate()` before calling OpenAPI generated client functions ensures that you are
authenticated and that any expired access tokens are refreshed.
Our helper functions will handle calling `authenticate` before making any calls, so if you are only using our
helper functions you won't need to call it yourself.
The `session` should generally be created once per application. It will automatically dispose itself when the application
shuts down. Alternatively you can enclose it in an `async with` or a `with` block if you need to create multiple sessions,
as shown in the examples below.
If you are using the OpenAPI generated code then you can pass the `session.async_client` or `session.sync_client` into the OpenAPI
generated API client instance as the `api_client` parameter as shown below. Passing in `async_client` will cause it to use
`asyncio`, and you will need to `await` the calls. Passing in `sync_client` will cause the calls to complete synchronously.
Our helper functions all use `asyncio` for efficient parallelisation of downloads, and must therefore be awaited.
The following example shows how to create a session and request some output channels from a study using our helper function:
```python
import canopy
import asyncio
async with canopy.Session(client_id='<your_client_id>', username='<your_username>') as session:
study_data = await canopy.load_study(session, '<study_id>', 'DynamicLap', ['sRun', 'vCar'])
# Using the OpenAPI generated client directly:
study_api = canopy.openapi.StudyApi(session.async_client)
job_result = await study_api.study_get_study_job_metadata(
session.authentication.tenant_id,
'<study_id>',
0)
# Using asyncio.ensure_future() to enable us to perform multiple calls in parallel
job_result_task = asyncio.ensure_future(study_api.study_get_study_job_metadata(
session.authentication.tenant_id,
'<study_id>',
0))
job_result_2 = await job_result_task
```
When running this code you will be prompted for your client secret and your password if
it is the first time `session.authentication.authenticate()` has been called for this session instance. Alternatively
you can pass the client secret and password into the Session class (after fetching them from a secure location) to
avoid being prompted.
If you can't use `asyncio` and `async/await` you can instead instantiate the session object synchronously
and use the `canopy.run` method when calling our async helper methods.
You can pass `session.sync_client` into the OpenAPI client classes instead of `session.async_client` to make them
return results synchronously.
```python
import canopy
with canopy.Session(client_id='<your_client_id>', username='<your_username>') as session:
# Note we are using canopy.run(..) to force the async method to run synchronously.
# This is a wrapper for asyncio.get_event_loop().run_until_complete(..).
study_data = canopy.run(canopy.load_study(session, '<study_id>', 'DynamicLap', ['sRun', 'vCar']))
# Using the OpenAPI generated client synchronously by passing in sync_client:
study_api = canopy.openapi.StudyApi(session.sync_client)
job_result = study_api.study_get_study_job_metadata(
session.authentication.tenant_id,
'<study_id>',
0)
# You can still run synchronous OpenAPI client methods asynchronously using threads if you need to:
job_result_thread = study_api.study_get_study_job_metadata(
session.authentication.tenant_id,
'<study_id>',
0,
async_req=True)
job_result_2 = job_result_thread.get()
```
## Proxy Servers
You can configure your proxy server by passing in a `proxy` argument to the `canopy.Session` object:
```python
async with canopy.Session(authentication_data, proxy=canopy.ProxyConfiguration('http://some.proxy.com', 'user', 'pass')) as session:
```
# Updating the OpenAPI Client
This needs to be tidied up, improved, and automated.
Additional options can be found here: https://openapi-generator.tech/docs/generators/openapi/
- e.g. enumUnknownDefaultCase could be useful if the remaining exposed enums change in future.
You can use the Dockerfile in this repository to create a docker image to generate the new API stubs:
```sh
docker image build -t canopy-python-gen:1 .
docker container run -i -t --mount type=bind,src='<path>/<to>/canopy/canopy-python',dst=/canopy/repo canopy-python-gen:1 /bin/bash
```
```sh
java -jar openapi-generator-cli.jar generate -g python-legacy -i https://api.canopysimulations.com/swagger/v1/swagger.json -o ./gen --package-name "canopy.openapi"
rm -r repo/canopy/openapi
rm -r repo/docs
cp -r gen/canopy/openapi repo/canopy
cp -r gen/docs repo
cp -r gen/README.md repo/OPENAPI_README.md
```
To regenerate the `asyncio` files execute:
```sh
rm -r gen
java -jar openapi-generator-cli.jar generate -g python-legacy -i https://api.canopysimulations.com/swagger/v1/swagger.json -o ./gen --package-name "canopy.openapi" --library asyncio
mv gen/canopy/openapi gen/canopy/openapi_asyncio
rm -r gen/canopy/openapi_asyncio/api
rm -r gen/canopy/openapi_asyncio/models
rm gen/canopy/openapi_asyncio/configuration.py
rm gen/canopy/openapi_asyncio/exceptions.py
sed -i 's/from canopy\.openapi import rest/from canopy.openapi_asyncio import rest/g' gen/canopy/openapi_asyncio/api_client.py
sed -i '/from canopy.*/d' gen/canopy/openapi_asyncio/__init__.py
sed -i '/# import /d' gen/canopy/openapi_asyncio/__init__.py
echo 'from canopy.openapi_asyncio.api_client import ApiClient' >> gen/canopy/openapi_asyncio/__init__.py
cp -r gen/canopy/openapi_asyncio repo/canopy
```
Note: The `openapi/configuration.py` file will need to be manually modified to add the default API host URL.
Note: The `openapi_asyncio/rest.py` file will need to be manually modified to support proxy servers after generation.
Note: The `openapi_asyncio/client_api.py` and `openapi/client_api.py` files will need to be manually modified to
support numpy array serialization after generation.
## Documentation for OpenAPI Generated Client
OpenAPI generated documentation can be found [here](OPENAPI_README.md).
%package -n python3-canopy
Summary: Python Client for the Canopy Simulation API
Provides: python-canopy
BuildRequires: python3-devel
BuildRequires: python3-setuptools
BuildRequires: python3-pip
%description -n python3-canopy
# Installation
### Versioning
This library uses [SimVer](http://simver.org/) versioning, where a change in the major version number indicates a
breaking change and a change in the minor version number indicates a non-breaking change (such as an additional
feature or bug fix).
### Changelog
The changelog is available [here](CHANGELOG.md).
### Requirements.
This library has been tested on Python 3.6 and higher.
### pip install
```sh
pip install canopy
```
You may need to run `pip` with root permission: `sudo pip install canopy`.
From a Jupyter Notebook you can run `!pip install canopy`.
### Setuptools
Install via [Setuptools](http://pypi.python.org/pypi/setuptools).
```sh
python setup.py install --user
```
(or `sudo python setup.py install` to install the package for all users)
### Running Tests
Unit tests can be run with:
```
pytest canopy
```
Integration tests can be run with:
```
pytest integration_tests
```
To run the integration tests you'll need to ensure you have an environment variable called `CANOPY_PYTHON_INTEGRATION_TEST_CREDENTIALS`
containing the string `<client_id>|<client_secret>|<username>|<tenant_name>|<password>`.
# Getting Started
## Example Usage
See the [Canopy Python Examples](https://github.com/CanopySimulations/canopy-python-examples) repository for example usage.
## Introduction
This package is designed for customers of [Canopy Simulations](https://www.canopysimulations.com/) who would like
to access the Canopy API from Python, for example using Jupyter Notebooks.
Currently the library is split into two parts:
- The client generated using the OpenAPI toolset is located in the "canopy/openapi" folder.
We don't have a great deal of control over how this code looks, but it should give a fairly complete interface to the main API.
- One folder up from that in the "canopy" folder we are adding helper functions which wrap common use cases in simple functions.
You can also use these functions as a reference to using the OpenAPI generated code.
When using the library you generally start by creating a `canopy.Session` object.
The session object manages authentication, and the caching of user settings.
Calling `session.authentication.authenticate()` before calling OpenAPI generated client functions ensures that you are
authenticated and that any expired access tokens are refreshed.
Our helper functions will handle calling `authenticate` before making any calls, so if you are only using our
helper functions you won't need to call it yourself.
The `session` should generally be created once per application. It will automatically dispose itself when the application
shuts down. Alternatively you can enclose it in an `async with` or a `with` block if you need to create multiple sessions,
as shown in the examples below.
If you are using the OpenAPI generated code then you can pass the `session.async_client` or `session.sync_client` into the OpenAPI
generated API client instance as the `api_client` parameter as shown below. Passing in `async_client` will cause it to use
`asyncio`, and you will need to `await` the calls. Passing in `sync_client` will cause the calls to complete synchronously.
Our helper functions all use `asyncio` for efficient parallelisation of downloads, and must therefore be awaited.
The following example shows how to create a session and request some output channels from a study using our helper function:
```python
import canopy
import asyncio
async with canopy.Session(client_id='<your_client_id>', username='<your_username>') as session:
study_data = await canopy.load_study(session, '<study_id>', 'DynamicLap', ['sRun', 'vCar'])
# Using the OpenAPI generated client directly:
study_api = canopy.openapi.StudyApi(session.async_client)
job_result = await study_api.study_get_study_job_metadata(
session.authentication.tenant_id,
'<study_id>',
0)
# Using asyncio.ensure_future() to enable us to perform multiple calls in parallel
job_result_task = asyncio.ensure_future(study_api.study_get_study_job_metadata(
session.authentication.tenant_id,
'<study_id>',
0))
job_result_2 = await job_result_task
```
When running this code you will be prompted for your client secret and your password if
it is the first time `session.authentication.authenticate()` has been called for this session instance. Alternatively
you can pass the client secret and password into the Session class (after fetching them from a secure location) to
avoid being prompted.
If you can't use `asyncio` and `async/await` you can instead instantiate the session object synchronously
and use the `canopy.run` method when calling our async helper methods.
You can pass `session.sync_client` into the OpenAPI client classes instead of `session.async_client` to make them
return results synchronously.
```python
import canopy
with canopy.Session(client_id='<your_client_id>', username='<your_username>') as session:
# Note we are using canopy.run(..) to force the async method to run synchronously.
# This is a wrapper for asyncio.get_event_loop().run_until_complete(..).
study_data = canopy.run(canopy.load_study(session, '<study_id>', 'DynamicLap', ['sRun', 'vCar']))
# Using the OpenAPI generated client synchronously by passing in sync_client:
study_api = canopy.openapi.StudyApi(session.sync_client)
job_result = study_api.study_get_study_job_metadata(
session.authentication.tenant_id,
'<study_id>',
0)
# You can still run synchronous OpenAPI client methods asynchronously using threads if you need to:
job_result_thread = study_api.study_get_study_job_metadata(
session.authentication.tenant_id,
'<study_id>',
0,
async_req=True)
job_result_2 = job_result_thread.get()
```
## Proxy Servers
You can configure your proxy server by passing in a `proxy` argument to the `canopy.Session` object:
```python
async with canopy.Session(authentication_data, proxy=canopy.ProxyConfiguration('http://some.proxy.com', 'user', 'pass')) as session:
```
# Updating the OpenAPI Client
This needs to be tidied up, improved, and automated.
Additional options can be found here: https://openapi-generator.tech/docs/generators/openapi/
- e.g. enumUnknownDefaultCase could be useful if the remaining exposed enums change in future.
You can use the Dockerfile in this repository to create a docker image to generate the new API stubs:
```sh
docker image build -t canopy-python-gen:1 .
docker container run -i -t --mount type=bind,src='<path>/<to>/canopy/canopy-python',dst=/canopy/repo canopy-python-gen:1 /bin/bash
```
```sh
java -jar openapi-generator-cli.jar generate -g python-legacy -i https://api.canopysimulations.com/swagger/v1/swagger.json -o ./gen --package-name "canopy.openapi"
rm -r repo/canopy/openapi
rm -r repo/docs
cp -r gen/canopy/openapi repo/canopy
cp -r gen/docs repo
cp -r gen/README.md repo/OPENAPI_README.md
```
To regenerate the `asyncio` files execute:
```sh
rm -r gen
java -jar openapi-generator-cli.jar generate -g python-legacy -i https://api.canopysimulations.com/swagger/v1/swagger.json -o ./gen --package-name "canopy.openapi" --library asyncio
mv gen/canopy/openapi gen/canopy/openapi_asyncio
rm -r gen/canopy/openapi_asyncio/api
rm -r gen/canopy/openapi_asyncio/models
rm gen/canopy/openapi_asyncio/configuration.py
rm gen/canopy/openapi_asyncio/exceptions.py
sed -i 's/from canopy\.openapi import rest/from canopy.openapi_asyncio import rest/g' gen/canopy/openapi_asyncio/api_client.py
sed -i '/from canopy.*/d' gen/canopy/openapi_asyncio/__init__.py
sed -i '/# import /d' gen/canopy/openapi_asyncio/__init__.py
echo 'from canopy.openapi_asyncio.api_client import ApiClient' >> gen/canopy/openapi_asyncio/__init__.py
cp -r gen/canopy/openapi_asyncio repo/canopy
```
Note: The `openapi/configuration.py` file will need to be manually modified to add the default API host URL.
Note: The `openapi_asyncio/rest.py` file will need to be manually modified to support proxy servers after generation.
Note: The `openapi_asyncio/client_api.py` and `openapi/client_api.py` files will need to be manually modified to
support numpy array serialization after generation.
## Documentation for OpenAPI Generated Client
OpenAPI generated documentation can be found [here](OPENAPI_README.md).
%package help
Summary: Development documents and examples for canopy
Provides: python3-canopy-doc
%description help
# Installation
### Versioning
This library uses [SimVer](http://simver.org/) versioning, where a change in the major version number indicates a
breaking change and a change in the minor version number indicates a non-breaking change (such as an additional
feature or bug fix).
### Changelog
The changelog is available [here](CHANGELOG.md).
### Requirements.
This library has been tested on Python 3.6 and higher.
### pip install
```sh
pip install canopy
```
You may need to run `pip` with root permission: `sudo pip install canopy`.
From a Jupyter Notebook you can run `!pip install canopy`.
### Setuptools
Install via [Setuptools](http://pypi.python.org/pypi/setuptools).
```sh
python setup.py install --user
```
(or `sudo python setup.py install` to install the package for all users)
### Running Tests
Unit tests can be run with:
```
pytest canopy
```
Integration tests can be run with:
```
pytest integration_tests
```
To run the integration tests you'll need to ensure you have an environment variable called `CANOPY_PYTHON_INTEGRATION_TEST_CREDENTIALS`
containing the string `<client_id>|<client_secret>|<username>|<tenant_name>|<password>`.
# Getting Started
## Example Usage
See the [Canopy Python Examples](https://github.com/CanopySimulations/canopy-python-examples) repository for example usage.
## Introduction
This package is designed for customers of [Canopy Simulations](https://www.canopysimulations.com/) who would like
to access the Canopy API from Python, for example using Jupyter Notebooks.
Currently the library is split into two parts:
- The client generated using the OpenAPI toolset is located in the "canopy/openapi" folder.
We don't have a great deal of control over how this code looks, but it should give a fairly complete interface to the main API.
- One folder up from that in the "canopy" folder we are adding helper functions which wrap common use cases in simple functions.
You can also use these functions as a reference to using the OpenAPI generated code.
When using the library you generally start by creating a `canopy.Session` object.
The session object manages authentication, and the caching of user settings.
Calling `session.authentication.authenticate()` before calling OpenAPI generated client functions ensures that you are
authenticated and that any expired access tokens are refreshed.
Our helper functions will handle calling `authenticate` before making any calls, so if you are only using our
helper functions you won't need to call it yourself.
The `session` should generally be created once per application. It will automatically dispose itself when the application
shuts down. Alternatively you can enclose it in an `async with` or a `with` block if you need to create multiple sessions,
as shown in the examples below.
If you are using the OpenAPI generated code then you can pass the `session.async_client` or `session.sync_client` into the OpenAPI
generated API client instance as the `api_client` parameter as shown below. Passing in `async_client` will cause it to use
`asyncio`, and you will need to `await` the calls. Passing in `sync_client` will cause the calls to complete synchronously.
Our helper functions all use `asyncio` for efficient parallelisation of downloads, and must therefore be awaited.
The following example shows how to create a session and request some output channels from a study using our helper function:
```python
import canopy
import asyncio
async with canopy.Session(client_id='<your_client_id>', username='<your_username>') as session:
study_data = await canopy.load_study(session, '<study_id>', 'DynamicLap', ['sRun', 'vCar'])
# Using the OpenAPI generated client directly:
study_api = canopy.openapi.StudyApi(session.async_client)
job_result = await study_api.study_get_study_job_metadata(
session.authentication.tenant_id,
'<study_id>',
0)
# Using asyncio.ensure_future() to enable us to perform multiple calls in parallel
job_result_task = asyncio.ensure_future(study_api.study_get_study_job_metadata(
session.authentication.tenant_id,
'<study_id>',
0))
job_result_2 = await job_result_task
```
When running this code you will be prompted for your client secret and your password if
it is the first time `session.authentication.authenticate()` has been called for this session instance. Alternatively
you can pass the client secret and password into the Session class (after fetching them from a secure location) to
avoid being prompted.
If you can't use `asyncio` and `async/await` you can instead instantiate the session object synchronously
and use the `canopy.run` method when calling our async helper methods.
You can pass `session.sync_client` into the OpenAPI client classes instead of `session.async_client` to make them
return results synchronously.
```python
import canopy
with canopy.Session(client_id='<your_client_id>', username='<your_username>') as session:
# Note we are using canopy.run(..) to force the async method to run synchronously.
# This is a wrapper for asyncio.get_event_loop().run_until_complete(..).
study_data = canopy.run(canopy.load_study(session, '<study_id>', 'DynamicLap', ['sRun', 'vCar']))
# Using the OpenAPI generated client synchronously by passing in sync_client:
study_api = canopy.openapi.StudyApi(session.sync_client)
job_result = study_api.study_get_study_job_metadata(
session.authentication.tenant_id,
'<study_id>',
0)
# You can still run synchronous OpenAPI client methods asynchronously using threads if you need to:
job_result_thread = study_api.study_get_study_job_metadata(
session.authentication.tenant_id,
'<study_id>',
0,
async_req=True)
job_result_2 = job_result_thread.get()
```
## Proxy Servers
You can configure your proxy server by passing in a `proxy` argument to the `canopy.Session` object:
```python
async with canopy.Session(authentication_data, proxy=canopy.ProxyConfiguration('http://some.proxy.com', 'user', 'pass')) as session:
```
# Updating the OpenAPI Client
This needs to be tidied up, improved, and automated.
Additional options can be found here: https://openapi-generator.tech/docs/generators/openapi/
- e.g. enumUnknownDefaultCase could be useful if the remaining exposed enums change in future.
You can use the Dockerfile in this repository to create a docker image to generate the new API stubs:
```sh
docker image build -t canopy-python-gen:1 .
docker container run -i -t --mount type=bind,src='<path>/<to>/canopy/canopy-python',dst=/canopy/repo canopy-python-gen:1 /bin/bash
```
```sh
java -jar openapi-generator-cli.jar generate -g python-legacy -i https://api.canopysimulations.com/swagger/v1/swagger.json -o ./gen --package-name "canopy.openapi"
rm -r repo/canopy/openapi
rm -r repo/docs
cp -r gen/canopy/openapi repo/canopy
cp -r gen/docs repo
cp -r gen/README.md repo/OPENAPI_README.md
```
To regenerate the `asyncio` files execute:
```sh
rm -r gen
java -jar openapi-generator-cli.jar generate -g python-legacy -i https://api.canopysimulations.com/swagger/v1/swagger.json -o ./gen --package-name "canopy.openapi" --library asyncio
mv gen/canopy/openapi gen/canopy/openapi_asyncio
rm -r gen/canopy/openapi_asyncio/api
rm -r gen/canopy/openapi_asyncio/models
rm gen/canopy/openapi_asyncio/configuration.py
rm gen/canopy/openapi_asyncio/exceptions.py
sed -i 's/from canopy\.openapi import rest/from canopy.openapi_asyncio import rest/g' gen/canopy/openapi_asyncio/api_client.py
sed -i '/from canopy.*/d' gen/canopy/openapi_asyncio/__init__.py
sed -i '/# import /d' gen/canopy/openapi_asyncio/__init__.py
echo 'from canopy.openapi_asyncio.api_client import ApiClient' >> gen/canopy/openapi_asyncio/__init__.py
cp -r gen/canopy/openapi_asyncio repo/canopy
```
Note: The `openapi/configuration.py` file will need to be manually modified to add the default API host URL.
Note: The `openapi_asyncio/rest.py` file will need to be manually modified to support proxy servers after generation.
Note: The `openapi_asyncio/client_api.py` and `openapi/client_api.py` files will need to be manually modified to
support numpy array serialization after generation.
## Documentation for OpenAPI Generated Client
OpenAPI generated documentation can be found [here](OPENAPI_README.md).
%prep
%autosetup -n canopy-8.38
%build
%py3_build
%install
%py3_install
install -d -m755 %{buildroot}/%{_pkgdocdir}
if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
pushd %{buildroot}
if [ -d usr/lib ]; then
find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/lib64 ]; then
find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/bin ]; then
find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/sbin ]; then
find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst
fi
touch doclist.lst
if [ -d usr/share/man ]; then
find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst
fi
popd
mv %{buildroot}/filelist.lst .
mv %{buildroot}/doclist.lst .
%files -n python3-canopy -f filelist.lst
%dir %{python3_sitelib}/*
%files help -f doclist.lst
%{_docdir}/*
%changelog
* Fri May 05 2023 Python_Bot <Python_Bot@openeuler.org> - 8.38-1
- Package Spec generated
|