rowan-python 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- rowan-python-0.0.1/PKG-INFO +78 -0
- rowan-python-0.0.1/README.md +64 -0
- rowan-python-0.0.1/pyproject.toml +30 -0
- rowan-python-0.0.1/rowan/__init__.py +4 -0
- rowan-python-0.0.1/rowan/client.py +107 -0
- rowan-python-0.0.1/rowan/utils.py +15 -0
- rowan-python-0.0.1/rowan_python.egg-info/PKG-INFO +78 -0
- rowan-python-0.0.1/rowan_python.egg-info/SOURCES.txt +10 -0
- rowan-python-0.0.1/rowan_python.egg-info/dependency_links.txt +1 -0
- rowan-python-0.0.1/rowan_python.egg-info/requires.txt +4 -0
- rowan-python-0.0.1/rowan_python.egg-info/top_level.txt +1 -0
- rowan-python-0.0.1/setup.cfg +4 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: rowan-python
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Rowan Python Library
|
|
5
|
+
Author-email: Corin Wagen <corin@rowansci.com>
|
|
6
|
+
Project-URL: Homepage, https://github.com/rowansci/rowan-client
|
|
7
|
+
Project-URL: Bug Tracker, https://github.com/rowansci/rowan-client/issues
|
|
8
|
+
Requires-Python: >=3.8
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
Requires-Dist: cctk>=0.2.18
|
|
11
|
+
Requires-Dist: httpx>=0.25
|
|
12
|
+
Requires-Dist: numpy>=1.24
|
|
13
|
+
Requires-Dist: stjames>=0.0.5
|
|
14
|
+
|
|
15
|
+
# Rowan Python Library
|
|
16
|
+
|
|
17
|
+
The Rowan Python library provides convenient access to the Rowan API from applications written in the Python language.
|
|
18
|
+
|
|
19
|
+
## Documentation
|
|
20
|
+
|
|
21
|
+
The documentation is available [here](https://docs.rowansci.com).
|
|
22
|
+
|
|
23
|
+
## Installation
|
|
24
|
+
|
|
25
|
+
To install, run `pip install rowan-python`.
|
|
26
|
+
|
|
27
|
+
## Usage
|
|
28
|
+
|
|
29
|
+
Rowan can be run in either blocking (wait until job is complete) or non-blocking (don't wait) modes.
|
|
30
|
+
Both modes require generation of an API key at [labs.rowansci.com](https://labs.rowansci.com/account/api-keys).
|
|
31
|
+
|
|
32
|
+
For now, molecules are specified through [*cctk*](https://cctk.rtfd.io). Additional ways to specify molecules will be added in the future.
|
|
33
|
+
|
|
34
|
+
Results are returned as dictionaries in the [*stjames*](https://github.com/rowansci/stjames) format.
|
|
35
|
+
|
|
36
|
+
### Blocking
|
|
37
|
+
```
|
|
38
|
+
import cctk
|
|
39
|
+
import rowan
|
|
40
|
+
|
|
41
|
+
rowan.api_key = "rowan-sk..."
|
|
42
|
+
client = rowan.Client()
|
|
43
|
+
|
|
44
|
+
# load molecule by name (cctk can also load in a variety of file formats)
|
|
45
|
+
molecule = cctk.Molecule.new_from_name("cyclobutane")
|
|
46
|
+
|
|
47
|
+
# run calculation remotely and return result
|
|
48
|
+
result = client.compute(molecule, name="opt cyclobutane", method="b97-3c", tasks=["optimize", "charge"])
|
|
49
|
+
print(result)
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Non-Blocking
|
|
53
|
+
```
|
|
54
|
+
import cctk
|
|
55
|
+
import rowan
|
|
56
|
+
|
|
57
|
+
rowan.api_key = "rowan-sk..."
|
|
58
|
+
client = rowan.Client(blocking=False)
|
|
59
|
+
|
|
60
|
+
# load molecule by name (cctk can also load in a variety of file formats)
|
|
61
|
+
molecule = cctk.Molecule.new_from_name("cyclobutane")
|
|
62
|
+
|
|
63
|
+
# start calculation and return id
|
|
64
|
+
calc_id = client.compute(molecule, name="opt cyclobutane", method="b97-3c", tasks=["optimize", "charge"])
|
|
65
|
+
|
|
66
|
+
# retrieve result (and status)
|
|
67
|
+
result = client.get(calc_id)
|
|
68
|
+
print(result)
|
|
69
|
+
|
|
70
|
+
# alternately, cancel queued or running calculation
|
|
71
|
+
client.stop(calc_id)
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Issues
|
|
75
|
+
|
|
76
|
+
To report issues, please use the "Issues" tab above.
|
|
77
|
+
|
|
78
|
+
*Corin Wagen, 2023*
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# Rowan Python Library
|
|
2
|
+
|
|
3
|
+
The Rowan Python library provides convenient access to the Rowan API from applications written in the Python language.
|
|
4
|
+
|
|
5
|
+
## Documentation
|
|
6
|
+
|
|
7
|
+
The documentation is available [here](https://docs.rowansci.com).
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
To install, run `pip install rowan-python`.
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
Rowan can be run in either blocking (wait until job is complete) or non-blocking (don't wait) modes.
|
|
16
|
+
Both modes require generation of an API key at [labs.rowansci.com](https://labs.rowansci.com/account/api-keys).
|
|
17
|
+
|
|
18
|
+
For now, molecules are specified through [*cctk*](https://cctk.rtfd.io). Additional ways to specify molecules will be added in the future.
|
|
19
|
+
|
|
20
|
+
Results are returned as dictionaries in the [*stjames*](https://github.com/rowansci/stjames) format.
|
|
21
|
+
|
|
22
|
+
### Blocking
|
|
23
|
+
```
|
|
24
|
+
import cctk
|
|
25
|
+
import rowan
|
|
26
|
+
|
|
27
|
+
rowan.api_key = "rowan-sk..."
|
|
28
|
+
client = rowan.Client()
|
|
29
|
+
|
|
30
|
+
# load molecule by name (cctk can also load in a variety of file formats)
|
|
31
|
+
molecule = cctk.Molecule.new_from_name("cyclobutane")
|
|
32
|
+
|
|
33
|
+
# run calculation remotely and return result
|
|
34
|
+
result = client.compute(molecule, name="opt cyclobutane", method="b97-3c", tasks=["optimize", "charge"])
|
|
35
|
+
print(result)
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Non-Blocking
|
|
39
|
+
```
|
|
40
|
+
import cctk
|
|
41
|
+
import rowan
|
|
42
|
+
|
|
43
|
+
rowan.api_key = "rowan-sk..."
|
|
44
|
+
client = rowan.Client(blocking=False)
|
|
45
|
+
|
|
46
|
+
# load molecule by name (cctk can also load in a variety of file formats)
|
|
47
|
+
molecule = cctk.Molecule.new_from_name("cyclobutane")
|
|
48
|
+
|
|
49
|
+
# start calculation and return id
|
|
50
|
+
calc_id = client.compute(molecule, name="opt cyclobutane", method="b97-3c", tasks=["optimize", "charge"])
|
|
51
|
+
|
|
52
|
+
# retrieve result (and status)
|
|
53
|
+
result = client.get(calc_id)
|
|
54
|
+
print(result)
|
|
55
|
+
|
|
56
|
+
# alternately, cancel queued or running calculation
|
|
57
|
+
client.stop(calc_id)
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Issues
|
|
61
|
+
|
|
62
|
+
To report issues, please use the "Issues" tab above.
|
|
63
|
+
|
|
64
|
+
*Corin Wagen, 2023*
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "rowan-python"
|
|
3
|
+
version = "0.0.1"
|
|
4
|
+
description = "Rowan Python Library"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.8"
|
|
7
|
+
authors = [
|
|
8
|
+
{ name = "Corin Wagen", email = "corin@rowansci.com" },
|
|
9
|
+
]
|
|
10
|
+
|
|
11
|
+
dependencies = [
|
|
12
|
+
"cctk>=0.2.18",
|
|
13
|
+
"httpx>=0.25",
|
|
14
|
+
"numpy>=1.24",
|
|
15
|
+
"stjames>=0.0.5",
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
[build-system]
|
|
19
|
+
# maybe will want to move away from setuptools eventually
|
|
20
|
+
requires = ["setuptools>=61.0"]
|
|
21
|
+
build-backend = "setuptools.build_meta"
|
|
22
|
+
|
|
23
|
+
[project.urls]
|
|
24
|
+
"Homepage" = "https://github.com/rowansci/rowan-client"
|
|
25
|
+
"Bug Tracker" = "https://github.com/rowansci/rowan-client/issues"
|
|
26
|
+
|
|
27
|
+
[tool.ruff]
|
|
28
|
+
line-length = 160
|
|
29
|
+
select = ["E", "F"]
|
|
30
|
+
ignore = ["E741"]
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import cctk
|
|
4
|
+
import httpx
|
|
5
|
+
from typing import Optional
|
|
6
|
+
import numpy as np
|
|
7
|
+
import stjames
|
|
8
|
+
from dataclasses import dataclass, field
|
|
9
|
+
import time
|
|
10
|
+
|
|
11
|
+
import rowan
|
|
12
|
+
|
|
13
|
+
API_URL = "https://api.rowansci.com/calculation"
|
|
14
|
+
|
|
15
|
+
# cf. /opt/miniconda3/envs/openai/lib/python3.9/site-packages/openai/__init__.py
|
|
16
|
+
|
|
17
|
+
@dataclass
|
|
18
|
+
class Client:
|
|
19
|
+
blocking: bool = True
|
|
20
|
+
print: bool = True
|
|
21
|
+
ping_interval: int = 5
|
|
22
|
+
|
|
23
|
+
headers: dict = field(init=False)
|
|
24
|
+
|
|
25
|
+
def __post_init__(self):
|
|
26
|
+
self.headers = {"X-API-Key": rowan.utils.get_api_key()}
|
|
27
|
+
|
|
28
|
+
def compute(
|
|
29
|
+
self,
|
|
30
|
+
input_molecule: cctk.Molecule,
|
|
31
|
+
name: Optional[str] = None,
|
|
32
|
+
folder_id: Optional[str] = None,
|
|
33
|
+
**options,
|
|
34
|
+
) -> stjames.Calculation | int:
|
|
35
|
+
atomic_numbers = input_molecule.atomic_numbers.view(np.ndarray)
|
|
36
|
+
geometry = input_molecule.geometry.view(np.ndarray)
|
|
37
|
+
|
|
38
|
+
atoms = list()
|
|
39
|
+
for i in range(input_molecule.num_atoms()):
|
|
40
|
+
atoms.append(
|
|
41
|
+
stjames.Atom(atomic_number=atomic_numbers[i], position=geometry[i])
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
molecule = stjames.Molecule(
|
|
45
|
+
atoms=atoms,
|
|
46
|
+
charge=input_molecule.charge,
|
|
47
|
+
multiplicity=input_molecule.multiplicity,
|
|
48
|
+
)
|
|
49
|
+
settings = stjames.Settings(**options)
|
|
50
|
+
calc = stjames.Calculation(molecules=[molecule], name=name, settings=settings)
|
|
51
|
+
|
|
52
|
+
with httpx.Client() as client:
|
|
53
|
+
response = client.post(
|
|
54
|
+
f"{API_URL}",
|
|
55
|
+
headers=self.headers,
|
|
56
|
+
json={
|
|
57
|
+
"json_data": calc.model_dump(mode="json"),
|
|
58
|
+
"folder_id": folder_id,
|
|
59
|
+
},
|
|
60
|
+
)
|
|
61
|
+
response.raise_for_status()
|
|
62
|
+
response_dict = response.json()
|
|
63
|
+
calc_id = response_dict["id"]
|
|
64
|
+
|
|
65
|
+
if self.print:
|
|
66
|
+
print(f"Calculation {calc_id} submitted")
|
|
67
|
+
|
|
68
|
+
if self.blocking:
|
|
69
|
+
while not response_dict["is_finished"]:
|
|
70
|
+
time.sleep(self.ping_interval)
|
|
71
|
+
response = client.get(f"{API_URL}/{calc_id}", headers=self.headers)
|
|
72
|
+
response_dict = response.json()
|
|
73
|
+
if not response.status_code == 200:
|
|
74
|
+
raise ValueError(
|
|
75
|
+
f"Error {response.status_code}: {response.reason}"
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
# we finished! get proper schema
|
|
79
|
+
response = client.get(
|
|
80
|
+
f"{API_URL}/{calc_id}/stjames", headers=self.headers
|
|
81
|
+
)
|
|
82
|
+
response_dict = response.json()
|
|
83
|
+
|
|
84
|
+
if self.print:
|
|
85
|
+
print(
|
|
86
|
+
f"Calculation {calc_id} completed after {response_dict['elapsed']:.1f} s of CPU time"
|
|
87
|
+
)
|
|
88
|
+
print(
|
|
89
|
+
f"(View the results at labs.rowansci.com/calculations/{calc_id})"
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
return stjames.Calculation.model_validate(response_dict)
|
|
93
|
+
|
|
94
|
+
else:
|
|
95
|
+
return calc_id
|
|
96
|
+
|
|
97
|
+
def get(self, calc_id: int) -> stjames.Calculation:
|
|
98
|
+
with httpx.Client() as client:
|
|
99
|
+
response = client.get(f"{API_URL}/{calc_id}/stjames", headers=self.headers)
|
|
100
|
+
response.raise_for_status()
|
|
101
|
+
response_dict = response.json()
|
|
102
|
+
return stjames.Calculation.model_validate(response_dict)
|
|
103
|
+
|
|
104
|
+
def stop(self, calc_id: int) -> None:
|
|
105
|
+
with httpx.Client() as client:
|
|
106
|
+
response = client.post(f"{API_URL}/{calc_id}/stop", headers=self.headers)
|
|
107
|
+
response.raise_for_status()
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import os
|
|
2
|
+
|
|
3
|
+
import rowan
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def get_api_key() -> str:
|
|
7
|
+
api_key = os.environ.get("ROWAN_API_KEY")
|
|
8
|
+
if api_key is not None:
|
|
9
|
+
return api_key
|
|
10
|
+
elif hasattr(rowan, "api_key"):
|
|
11
|
+
return rowan.api_key
|
|
12
|
+
else:
|
|
13
|
+
raise ValueError(
|
|
14
|
+
"No API key provided. You can set your API key using 'rowan.api_key = <API-KEY>', or you can set the environment variable ROWAN_API_KEY=<API-KEY>)."
|
|
15
|
+
)
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: rowan-python
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Rowan Python Library
|
|
5
|
+
Author-email: Corin Wagen <corin@rowansci.com>
|
|
6
|
+
Project-URL: Homepage, https://github.com/rowansci/rowan-client
|
|
7
|
+
Project-URL: Bug Tracker, https://github.com/rowansci/rowan-client/issues
|
|
8
|
+
Requires-Python: >=3.8
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
Requires-Dist: cctk>=0.2.18
|
|
11
|
+
Requires-Dist: httpx>=0.25
|
|
12
|
+
Requires-Dist: numpy>=1.24
|
|
13
|
+
Requires-Dist: stjames>=0.0.5
|
|
14
|
+
|
|
15
|
+
# Rowan Python Library
|
|
16
|
+
|
|
17
|
+
The Rowan Python library provides convenient access to the Rowan API from applications written in the Python language.
|
|
18
|
+
|
|
19
|
+
## Documentation
|
|
20
|
+
|
|
21
|
+
The documentation is available [here](https://docs.rowansci.com).
|
|
22
|
+
|
|
23
|
+
## Installation
|
|
24
|
+
|
|
25
|
+
To install, run `pip install rowan-python`.
|
|
26
|
+
|
|
27
|
+
## Usage
|
|
28
|
+
|
|
29
|
+
Rowan can be run in either blocking (wait until job is complete) or non-blocking (don't wait) modes.
|
|
30
|
+
Both modes require generation of an API key at [labs.rowansci.com](https://labs.rowansci.com/account/api-keys).
|
|
31
|
+
|
|
32
|
+
For now, molecules are specified through [*cctk*](https://cctk.rtfd.io). Additional ways to specify molecules will be added in the future.
|
|
33
|
+
|
|
34
|
+
Results are returned as dictionaries in the [*stjames*](https://github.com/rowansci/stjames) format.
|
|
35
|
+
|
|
36
|
+
### Blocking
|
|
37
|
+
```
|
|
38
|
+
import cctk
|
|
39
|
+
import rowan
|
|
40
|
+
|
|
41
|
+
rowan.api_key = "rowan-sk..."
|
|
42
|
+
client = rowan.Client()
|
|
43
|
+
|
|
44
|
+
# load molecule by name (cctk can also load in a variety of file formats)
|
|
45
|
+
molecule = cctk.Molecule.new_from_name("cyclobutane")
|
|
46
|
+
|
|
47
|
+
# run calculation remotely and return result
|
|
48
|
+
result = client.compute(molecule, name="opt cyclobutane", method="b97-3c", tasks=["optimize", "charge"])
|
|
49
|
+
print(result)
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Non-Blocking
|
|
53
|
+
```
|
|
54
|
+
import cctk
|
|
55
|
+
import rowan
|
|
56
|
+
|
|
57
|
+
rowan.api_key = "rowan-sk..."
|
|
58
|
+
client = rowan.Client(blocking=False)
|
|
59
|
+
|
|
60
|
+
# load molecule by name (cctk can also load in a variety of file formats)
|
|
61
|
+
molecule = cctk.Molecule.new_from_name("cyclobutane")
|
|
62
|
+
|
|
63
|
+
# start calculation and return id
|
|
64
|
+
calc_id = client.compute(molecule, name="opt cyclobutane", method="b97-3c", tasks=["optimize", "charge"])
|
|
65
|
+
|
|
66
|
+
# retrieve result (and status)
|
|
67
|
+
result = client.get(calc_id)
|
|
68
|
+
print(result)
|
|
69
|
+
|
|
70
|
+
# alternately, cancel queued or running calculation
|
|
71
|
+
client.stop(calc_id)
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Issues
|
|
75
|
+
|
|
76
|
+
To report issues, please use the "Issues" tab above.
|
|
77
|
+
|
|
78
|
+
*Corin Wagen, 2023*
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
pyproject.toml
|
|
3
|
+
rowan/__init__.py
|
|
4
|
+
rowan/client.py
|
|
5
|
+
rowan/utils.py
|
|
6
|
+
rowan_python.egg-info/PKG-INFO
|
|
7
|
+
rowan_python.egg-info/SOURCES.txt
|
|
8
|
+
rowan_python.egg-info/dependency_links.txt
|
|
9
|
+
rowan_python.egg-info/requires.txt
|
|
10
|
+
rowan_python.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
rowan
|