rowan-python 2.0.3__py3-none-any.whl → 2.1.0__py3-none-any.whl

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/__init__.py CHANGED
@@ -3,6 +3,7 @@ from . import constants
3
3
 
4
4
  from .folder import *
5
5
  from .workflow import *
6
+ from .project import *
6
7
  from .protein import *
7
8
  from .user import *
8
9
  from .utils import *
rowan/project.py ADDED
@@ -0,0 +1,136 @@
1
+ from datetime import datetime
2
+ from typing import Any, Self
3
+
4
+ from pydantic import BaseModel
5
+
6
+ from .utils import api_client
7
+
8
+
9
+ class Project(BaseModel):
10
+ """
11
+ A class representing a project in the Rowan API.
12
+
13
+ :ivar uuid: The UUID of the project.
14
+ :ivar name: The name of the project.
15
+ :ivar created_at: The date and time the project was created.
16
+ """
17
+
18
+ uuid: str
19
+ name: str | None = None
20
+ created_at: datetime | None = None
21
+
22
+ def __repr__(self) -> str:
23
+ return f"<Project name='{self.name}' created_at='{self.created_at}' uuid='{self.uuid}'>"
24
+
25
+ def update(
26
+ self,
27
+ name: str | None = None,
28
+ ) -> Self:
29
+ """
30
+ Update a project.
31
+
32
+ :param name: The new name of the project.
33
+
34
+ :return: The updated project object.
35
+ """
36
+ payload = {
37
+ "name": name if name is not None else self.name,
38
+ }
39
+
40
+ with api_client() as client:
41
+ response = client.post(f"/project/{self.uuid}", json=payload)
42
+ response.raise_for_status()
43
+ updated_data = response.json()
44
+
45
+ self.name = updated_data.get("name")
46
+ return self
47
+
48
+ def delete(self) -> None:
49
+ """
50
+ Delete the project.
51
+
52
+ This is a destructive action, it will delete all the folders and
53
+ workflows that are inside this project.
54
+
55
+ :raises requests.HTTPError: if the request to the API fails.
56
+ """
57
+ with api_client() as client:
58
+ response = client.delete(f"/project/{self.uuid}")
59
+ response.raise_for_status()
60
+
61
+
62
+ def retrieve_project(uuid: str) -> Project:
63
+ """
64
+ Retrieves a project from the API by UUID. Project UUID can be found in the project's URL.
65
+
66
+ :param uuid: The UUID of the project to retrieve.
67
+ :return: A Project object representing the retrieved project.
68
+ :raises HTTPError: If the API request fails.
69
+ """
70
+ with api_client() as client:
71
+ response = client.get(f"/project/{uuid}")
72
+ response.raise_for_status()
73
+ return Project(**response.json())
74
+
75
+
76
+ def list_projects(
77
+ name_contains: str | None = None,
78
+ page: int = 0,
79
+ size: int = 10,
80
+ ) -> list[Project]:
81
+ """
82
+ Retrieve a list of projects based on the specified criteria.
83
+
84
+ :param name_contains: Substring to search for in project names.
85
+ :param page: Pagination parameter to specify the page number.
86
+ :param size: Pagination parameter to specify the number of items per page.
87
+ :return: A list of Folder objects that match the search criteria.
88
+ :raises requests.HTTPError: if the request to the API fails.
89
+ """
90
+
91
+ params: dict[str, Any] = {
92
+ "page": page,
93
+ "size": size,
94
+ }
95
+
96
+ if name_contains is not None:
97
+ params["name_contains"] = name_contains
98
+
99
+ with api_client() as client:
100
+ response = client.get("/project", params=params)
101
+ response.raise_for_status()
102
+ items = response.json()
103
+
104
+ return [Project(**item) for item in items]
105
+
106
+
107
+ def create_project(
108
+ name: str,
109
+ ) -> Project:
110
+ """
111
+ Create a new project.
112
+
113
+ :param name: The name of the project.
114
+ :return: The newly created project.
115
+ """
116
+ data = {
117
+ "name": name,
118
+ }
119
+ with api_client() as client:
120
+ response = client.post("/project", json=data)
121
+ response.raise_for_status()
122
+ project_data = response.json()
123
+ return Project(**project_data)
124
+
125
+
126
+ def default_project() -> Project:
127
+ """
128
+ Retrieves the default project from the API.
129
+
130
+ :return: A Project object representing the default project.
131
+ :raises HTTPError: If the API request fails.
132
+ """
133
+ with api_client() as client:
134
+ response = client.get("/user/me/default_project")
135
+ response.raise_for_status()
136
+ return Project(**response.json())
rowan/protein.py CHANGED
@@ -189,12 +189,13 @@ def upload_protein(name: str, file_path: Path) -> Protein:
189
189
  return Protein(**final_response.json())
190
190
 
191
191
 
192
- def create_protein_from_pdb_id(name: str, code: str) -> Protein:
192
+ def create_protein_from_pdb_id(name: str, code: str, project_uuid: str) -> Protein:
193
193
  """
194
194
  Creates a protein from a PDB ID.
195
195
 
196
196
  :param name: The name of the protein to create
197
197
  :param code: The PDB ID of the protein to create
198
+ :param project_uuid: The UUID of the project to create the protein in
198
199
  :return: A Protein object representing the created protein
199
200
  :raises requests.HTTPError: if the request to the API fails
200
201
  """
@@ -207,7 +208,11 @@ def create_protein_from_pdb_id(name: str, code: str) -> Protein:
207
208
  protein_data = conversion_response.json()
208
209
 
209
210
  # Step 2: Use the converted data to create the final protein object.
210
- creation_payload = {"name": name, "protein_data": protein_data, "ancestor_uuid": None}
211
+ creation_payload = {
212
+ "name": name,
213
+ "protein_data": protein_data,
214
+ "project_uuid": project_uuid,
215
+ }
211
216
  final_response = client.post("/protein", json=creation_payload)
212
217
  final_response.raise_for_status()
213
218
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rowan-python
3
- Version: 2.0.3
3
+ Version: 2.1.0
4
4
  Summary: Rowan Python Library
5
5
  Project-URL: Homepage, https://github.com/rowansci/rowan-client
6
6
  Project-URL: Bug Tracker, https://github.com/rowansci/rowan-client/issues
@@ -1,14 +1,15 @@
1
- rowan/__init__.py,sha256=KWt0ConmoDkmFZUk1lKO7eXFwRbaVU0oLLnYvOafLVc,148
1
+ rowan/__init__.py,sha256=2rz6dW0l9DzawiFi6S0WSv8XlZq1CoTBKJrsJ1uesvk,171
2
2
  rowan/constants.py,sha256=ZZvv3L0b2y3dMGlWGeaRmx40J5tBrpxNxvJgjP1TNjg,37
3
3
  rowan/folder.py,sha256=n9WkjHMweQLtVcWUvCttOrmezvUdbFxam_eDEMzLF_A,6791
4
- rowan/protein.py,sha256=TOCsN50RaYh3Ja4GBxzH6R7qUk-Y9Xv7y1WU3buPFis,7778
4
+ rowan/project.py,sha256=ALPPkMa_cg7w5OkXno1cs6acCofw8AOUYRSeWgr3L0o,3774
5
+ rowan/protein.py,sha256=8hVNfnrULxE0Pz8cv5AnbTr7sMWNvStfM03vZh4k7uw,7925
5
6
  rowan/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
7
  rowan/user.py,sha256=Dl--NPUPATKCs2VmILsW8HnLiunG0Lxr0n6mKuHm21U,3891
7
8
  rowan/utils.py,sha256=907lV0fEP6BnjOWyisd3Uh8Mk5JuQMOX9QEjGi_mdew,3314
8
9
  rowan/workflow.py,sha256=LwU1iaweXseQENOHYAOQqvjNkwITZn82JHeSr4xZiTc,39505
9
10
  rowan/rowan_rdkit/__init__.py,sha256=EATX2VRzywzKxqkpCUMTf7RNQLkWsfi5VcCNDW6EIiw,503
10
11
  rowan/rowan_rdkit/chem_utils.py,sha256=i7-EmAcmvHYtc9NiZblLY_k2DoQKofAZo5KT2qtkUCI,34775
11
- rowan_python-2.0.3.dist-info/METADATA,sha256=-RDgaRghr3pWuUCJp7GTdGzoo1PnggTEsb8uIVrz8mU,1598
12
- rowan_python-2.0.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
13
- rowan_python-2.0.3.dist-info/licenses/LICENSE,sha256=i7ehYBS-6gGmbTcgU4mgk28pyOx2kScJ0kcx8n7bWLM,1084
14
- rowan_python-2.0.3.dist-info/RECORD,,
12
+ rowan_python-2.1.0.dist-info/METADATA,sha256=uma5PV9zajHWyVBlZcOn59kRmg2jwKvyDvnVczK4drc,1598
13
+ rowan_python-2.1.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
14
+ rowan_python-2.1.0.dist-info/licenses/LICENSE,sha256=i05z7xEhyrg6f8j0lR3XYjShnF-MJGFQ-DnpsZ8yiVI,1084
15
+ rowan_python-2.1.0.dist-info/RECORD,,
@@ -1,6 +1,6 @@
1
1
  The MIT License
2
2
 
3
- Copyright (c) Rowan (https://rowansci.com)
3
+ Copyright (c) Rowan Scientific Corporation
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal