atomict 1.2.24__py3-none-any.whl → 1.2.27__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.
atomict/__version__.py CHANGED
@@ -1 +1 @@
1
- __version__ = "1.2.24"
1
+ __version__ = "1.2.27"
atomict/api.py CHANGED
@@ -8,7 +8,7 @@ from requests.exceptions import (
8
8
  ConnectionError,
9
9
  Timeout,
10
10
  )
11
- from tenacity import retry, stop_after_attempt, wait_exponential, after_log, retry_if_exception_type, retry_if_exception, before_sleep_log
11
+ from tenacity import retry, stop_after_attempt, stop_after_delay, wait_exponential, after_log, retry_if_exception_type, retry_if_exception, before_sleep_log
12
12
 
13
13
  from atomict.exceptions import APIValidationError, PermissionDenied
14
14
  from atomict.utils.tenacity import before_log
@@ -23,21 +23,22 @@ def is_http_5xx_error(exception):
23
23
 
24
24
 
25
25
  @retry(
26
- stop=stop_after_attempt(5),
26
+ stop=(stop_after_attempt(5) | stop_after_delay(300)),
27
27
  wait=wait_exponential(multiplier=2, min=1, max=30),
28
28
  retry=(retry_if_exception_type((ConnectionError, Timeout)) | retry_if_exception(is_http_5xx_error)),
29
29
  before=before_log(logger, logging.INFO),
30
30
  after=after_log(logger, logging.INFO),
31
31
  before_sleep=before_sleep_log(logger, logging.WARNING),
32
32
  )
33
- def get(path: str):
34
- api_root = os.environ.get("AT_SERVER", "https://api.atomictessellator.com")
33
+ def get(path: str, api_root: str = None, token: str = None):
34
+ api_root = api_root or os.environ.get("AT_SERVER", "https://api.atomictessellator.com")
35
+ token = token or os.environ.get("AT_TOKEN")
35
36
  headers = {"Accept": "application/json", "Content-Type": "application/json"}
36
37
 
37
- if os.environ.get("AT_TOKEN"):
38
- headers["Authorization"] = f"Token {os.environ.get('AT_TOKEN')}"
38
+ if token:
39
+ headers["Authorization"] = f"Token {token}"
39
40
 
40
- response = requests.get(f"{api_root}/{path}", headers=headers)
41
+ response = requests.get(f"{api_root}/{path}", headers=headers, timeout=120)
41
42
 
42
43
  content_type = response.headers.get("Content-Type")
43
44
 
@@ -66,14 +67,14 @@ def get(path: str):
66
67
 
67
68
 
68
69
  @retry(
69
- stop=stop_after_attempt(5),
70
+ stop=(stop_after_attempt(5) | stop_after_delay(300)),
70
71
  wait=wait_exponential(multiplier=2, min=1, max=30),
71
72
  retry=(retry_if_exception_type((ConnectionError, Timeout)) | retry_if_exception(is_http_5xx_error)),
72
73
  before=before_log(logger, logging.INFO),
73
74
  after=after_log(logger, logging.INFO),
74
75
  before_sleep=before_sleep_log(logger, logging.WARNING),
75
76
  )
76
- def post(path: str, payload: dict, files=None, extra_headers={}):
77
+ def post(path: str, payload: dict, files=None, extra_headers={}, api_root: str = None, token: str = None):
77
78
  # Jesus christ this logic needs cleaning up
78
79
  if not files and "Content-Type" not in extra_headers:
79
80
  headers = {"Content-Type": "application/x-www-form-urlencoded"}
@@ -87,17 +88,18 @@ def post(path: str, payload: dict, files=None, extra_headers={}):
87
88
  else:
88
89
  headers.update(extra_headers)
89
90
 
90
- if os.environ.get("AT_TOKEN"):
91
- headers["Authorization"] = f"Token {os.environ.get('AT_TOKEN')}"
91
+ api_root = api_root or os.environ.get("AT_SERVER", "https://api.atomictessellator.com")
92
+ token = token or os.environ.get("AT_TOKEN")
92
93
 
93
- api_root = os.environ.get("AT_SERVER", "https://api.atomictessellator.com")
94
+ if token:
95
+ headers["Authorization"] = f"Token {token}"
94
96
 
95
97
  if files is not None:
96
98
  response = requests.post(
97
- f"{api_root}/{path}", data=payload, headers=headers, files=files
99
+ f"{api_root}/{path}", data=payload, headers=headers, files=files, timeout=120
98
100
  )
99
101
  else:
100
- response = requests.post(f"{api_root}/{path}", data=payload, headers=headers)
102
+ response = requests.post(f"{api_root}/{path}", data=payload, headers=headers, timeout=120)
101
103
 
102
104
  if response.status_code in [requests.codes.ok, requests.codes.created]:
103
105
  resp = response.json()
@@ -116,22 +118,23 @@ def post(path: str, payload: dict, files=None, extra_headers={}):
116
118
 
117
119
 
118
120
  @retry(
119
- stop=stop_after_attempt(5),
121
+ stop=(stop_after_attempt(5) | stop_after_delay(300)),
120
122
  wait=wait_exponential(multiplier=2, min=1, max=30),
121
123
  retry=(retry_if_exception_type((ConnectionError, Timeout)) | retry_if_exception(is_http_5xx_error)),
122
124
  before=before_log(logger, logging.INFO),
123
125
  after=after_log(logger, logging.INFO),
124
126
  before_sleep=before_sleep_log(logger, logging.WARNING),
125
127
  )
126
- def patch(path: str, payload: dict):
128
+ def patch(path: str, payload: dict, api_root: str = None, token: str = None):
127
129
  payload_enc = json.dumps(payload)
128
130
  headers = {"Content-Type": "application/json"}
129
131
 
130
- if os.environ.get("AT_TOKEN"):
131
- headers["Authorization"] = f"Token {os.environ.get('AT_TOKEN')}"
132
+ api_root = api_root or os.environ.get("AT_SERVER", "https://api.atomictessellator.com")
133
+ token = token or os.environ.get("AT_TOKEN")
132
134
 
133
- api_root = os.environ.get("AT_SERVER", "https://api.atomictessellator.com")
134
- response = requests.patch(f"{api_root}/{path}", data=payload_enc, headers=headers)
135
+ if token:
136
+ headers["Authorization"] = f"Token {token}"
137
+ response = requests.patch(f"{api_root}/{path}", data=payload_enc, headers=headers, timeout=120)
135
138
 
136
139
  if response.status_code == requests.codes.ok:
137
140
  resp = response.json()
@@ -150,21 +153,22 @@ def patch(path: str, payload: dict):
150
153
 
151
154
 
152
155
  @retry(
153
- stop=stop_after_attempt(5),
156
+ stop=(stop_after_attempt(5) | stop_after_delay(300)),
154
157
  wait=wait_exponential(multiplier=2, min=1, max=30),
155
158
  retry=(retry_if_exception_type((ConnectionError, Timeout)) | retry_if_exception(is_http_5xx_error)),
156
159
  before=before_log(logger, logging.INFO),
157
160
  after=after_log(logger, logging.INFO),
158
161
  before_sleep=before_sleep_log(logger, logging.WARNING),
159
162
  )
160
- def delete(path: str):
163
+ def delete(path: str, api_root: str = None, token: str = None):
161
164
  headers = {}
162
165
 
163
- if os.environ.get("AT_TOKEN"):
164
- headers["Authorization"] = f"Token {os.environ.get('AT_TOKEN')}"
166
+ api_root = api_root or os.environ.get("AT_SERVER", "https://api.atomictessellator.com")
167
+ token = token or os.environ.get("AT_TOKEN")
165
168
 
166
- api_root = os.environ.get("AT_SERVER", "https://api.atomictessellator.com")
167
- response = requests.delete(f"{api_root}/{path}", headers=headers)
169
+ if token:
170
+ headers["Authorization"] = f"Token {token}"
171
+ response = requests.delete(f"{api_root}/{path}", headers=headers, timeout=120)
168
172
 
169
173
  if response.status_code == requests.codes.ok:
170
174
  resp = response.json()
@@ -44,9 +44,14 @@ def get(
44
44
  console.print(Panel.fit(f"[bold]EA Exploration Details[/bold]"))
45
45
  console.print(f"ID: {result['id']}")
46
46
  console.print(f"Name: {result.get('name', 'N/A')}")
47
- console.print(f"Status: {get_status_string(result.get('status'))}")
47
+ if result.get("task"):
48
+ console.print(
49
+ f"Status: {get_status_string(result['task'].get('status'))}"
50
+ )
51
+ console.print(f"Calculator: {result.get('calculator', 'N/A')}")
52
+ console.print(f"Strains: {result.get('strains_list', [])}")
48
53
  console.print(f"Created: {format_datetime(result.get('created_at'))}")
49
- console.print(f"Updated: {format_datetime(result.get('updated_at'))}")
54
+ console.print(f"Updated: {format_datetime(result.get('edited_at'))}")
50
55
 
51
56
  if result.get("parameters"):
52
57
  console.print("\n[bold]Parameters[/bold]")
@@ -80,13 +85,20 @@ def get(
80
85
  columns = [
81
86
  ("ID", "id", None),
82
87
  ("Name", "name", None),
88
+ ("Calculator", "calculator", None),
83
89
  ("Strains list", "strains_list", None),
84
90
  ("Stress algorithm", "stress_algorithm", None),
85
91
  ("Stress method", "stress_method", None),
86
92
  ("Num last samples", "num_last_samples", None),
87
- ("Status", "status", get_status_string),
93
+ (
94
+ "Status",
95
+ "task",
96
+ lambda x: (
97
+ get_status_string(x.get("status")) if isinstance(x, dict) else None
98
+ ),
99
+ ),
88
100
  ("Created", "created_at", format_datetime),
89
- ("Updated", "updated_at", format_datetime),
101
+ ("Updated", "edited_at", format_datetime),
90
102
  ]
91
103
 
92
104
  items, footer_string = get_pagination_info(results)
@@ -104,73 +116,82 @@ def get(
104
116
  console.print(table)
105
117
 
106
118
 
119
+ CALCULATOR_MAP = {
120
+ "fhi-aims": 1,
121
+ "uma-s-1p1": 4,
122
+ "uma-m-1p1": 5,
123
+ }
124
+
125
+
107
126
  @soecexploration_group.command()
108
- @click.option("--name", required=True, help="Exploration name")
109
- @click.option("--project", required=True, help="Project ID")
127
+ @click.option("--name", help="Exploration name")
128
+ @click.option(
129
+ "--calculator",
130
+ required=True,
131
+ type=click.Choice(list(CALCULATOR_MAP.keys()), case_sensitive=False),
132
+ help="Calculator to use (fhi-aims, uma-s-1p1, uma-m-1p1)",
133
+ )
134
+ @click.option(
135
+ "--strain",
136
+ "strains",
137
+ multiple=True,
138
+ type=float,
139
+ help="Strain value (repeatable to override the default strains_list)",
140
+ )
141
+ @click.option(
142
+ "--starting-structure-mlrelax",
143
+ help="ID of the starting MLRelaxation",
144
+ )
145
+ @click.option(
146
+ "--source-geometry",
147
+ help="ID of the source geometry UserUpload",
148
+ )
149
+ @click.option(
150
+ "--description", help="Exploration description"
151
+ )
110
152
  @click.option(
111
- "--relaxed-structure-simulation", help="ID of the relaxed structure simulation"
153
+ "--launch", is_flag=True, help="Launch the exploration immediately"
112
154
  )
113
- @click.option("--relaxed-structure", help="ID of the relaxed structure upload")
114
- @click.option("--k8s-cluster", help="K8S cluster ID (required for launch)")
115
- @click.option("--launch", is_flag=True, help="Launch the exploration immediately")
116
155
  @click.option("--json-output", is_flag=True, help="Output in JSON format")
117
156
  def create(
118
- name: str,
119
- project: str,
120
- relaxed_structure_simulation: Optional[str] = None,
121
- relaxed_structure: Optional[str] = None,
122
- k8s_cluster: Optional[str] = None,
157
+ name: Optional[str],
158
+ calculator: str,
159
+ strains: tuple,
160
+ starting_structure_mlrelax: Optional[str] = None,
161
+ source_geometry: Optional[str] = None,
162
+ description: Optional[str] = None,
123
163
  launch: bool = False,
124
164
  json_output: bool = False,
125
165
  ):
126
- """Create a new SOEC exploration
127
-
128
- Either --relaxed-structure-simulation or --relaxed-structure must be provided.
129
- If --launch is specified, --k8s-cluster must also be provided.
130
- """
166
+ """Create a new SOEC exploration"""
131
167
  client = get_client()
132
168
  console = Console()
133
169
 
134
- # Validate required fields for launch
135
- if launch and not k8s_cluster:
136
- console.print("[red]K8S cluster ID is required when launching[/red]")
137
- return
138
-
139
- # Validate relaxed structure source
140
- if not (relaxed_structure_simulation or relaxed_structure):
141
- console.print(
142
- "[red]Either relaxed-structure-simulation or relaxed-structure must be provided[/red]"
143
- )
144
- return
145
-
146
- if relaxed_structure_simulation and relaxed_structure:
147
- console.print(
148
- "[red]Cannot specify both relaxed-structure-simulation and relaxed-structure[/red]"
149
- )
150
- return
151
-
152
- # Prepare request data
153
170
  data = {
154
- "name": name,
155
- "project": project,
171
+ "calculator": CALCULATOR_MAP[calculator.lower()],
156
172
  }
157
-
158
- if relaxed_structure_simulation:
159
- data["relaxed_structure_simulation"] = relaxed_structure_simulation
160
- if relaxed_structure:
161
- data["relaxed_structure"] = relaxed_structure
162
- if k8s_cluster:
163
- data["k8s_cluster"] = k8s_cluster
164
- if launch:
165
- data["action"] = "LAUNCH"
173
+ if strains:
174
+ data["strains_list"] = list(strains)
175
+ if name:
176
+ data["name"] = name
177
+ if description:
178
+ data["description"] = description
179
+ if starting_structure_mlrelax:
180
+ data["starting_structure_mlrelax_id"] = starting_structure_mlrelax
181
+ if source_geometry:
182
+ data["source_geometry_id"] = source_geometry
166
183
 
167
184
  result = client.post("/api/ea-exploration/", data=data)
168
185
 
186
+ if launch:
187
+ client.post(f"/api/ea-exploration/{result['id']}/launch_stage1/", data={})
188
+
169
189
  if json_output:
170
190
  console.print_json(data=result)
171
191
  else:
192
+ label = name or result["id"]
172
193
  console.print(
173
- f"[green]Created SOEC exploration '{name}' with ID: {result['id']}[/green]"
194
+ f"[green]Created SOEC exploration '{label}' with ID: {result['id']}[/green]"
174
195
  )
175
196
  if launch:
176
197
  console.print("[green]Exploration has been queued for launch[/green]")
@@ -285,17 +306,32 @@ def get_sample(
285
306
 
286
307
  @soecexploration_group.command()
287
308
  @click.option("--exploration", required=True, help="SOEC Exploration ID")
288
- @click.option("--simulation", required=True, help="Simulation ID")
309
+ @click.option("--simulation", help="FHI-aims simulation ID")
310
+ @click.option("--mlrelax", help="MLRelaxation ID")
311
+ @click.option("--strain", type=float, help="Strain value applied to the sample")
312
+ @click.option("--matrix", type=int, help="Strain matrix index")
289
313
  @click.option("--json-output", is_flag=True, help="Output in JSON format")
290
- def create_sample(exploration: str, simulation: str, json_output: bool = False):
314
+ def create_sample(
315
+ exploration: str,
316
+ simulation: Optional[str] = None,
317
+ mlrelax: Optional[str] = None,
318
+ strain: Optional[float] = None,
319
+ matrix: Optional[int] = None,
320
+ json_output: bool = False,
321
+ ):
291
322
  """Create a new SOEC exploration sample"""
292
323
  client = get_client()
293
324
  console = Console()
294
325
 
295
- data = {
296
- "exploration": exploration,
297
- "simulation": simulation,
298
- }
326
+ data = {"exploration_id": exploration}
327
+ if simulation:
328
+ data["simulation_id"] = simulation
329
+ if mlrelax:
330
+ data["mlrelax_id"] = mlrelax
331
+ if strain is not None:
332
+ data["strain"] = strain
333
+ if matrix is not None:
334
+ data["matrix"] = matrix
299
335
 
300
336
  result = client.post("/api/ea-exploration-sample/", data=data)
301
337
 
@@ -452,8 +488,8 @@ def create_analysis_file(analysis: str, file_id: str, json_output: bool = False)
452
488
  console = Console()
453
489
 
454
490
  data = {
455
- "analysis": analysis,
456
- "user_upload": file_id,
491
+ "analysis_id": analysis,
492
+ "user_upload_id": file_id,
457
493
  }
458
494
 
459
495
  result = client.post("/api/ea-exploration-analysis-file/", data=data)
@@ -530,10 +566,10 @@ def get_analysis_file(
530
566
 
531
567
  if fetch_all:
532
568
  results = client.get_all(
533
- "/api/soec-exploration-analysis-file/", params=params
569
+ "/api/ea-exploration-analysis-file/", params=params
534
570
  )
535
571
  else:
536
- results = client.get("/api/soec-exploration-analysis-file/", params=params)
572
+ results = client.get("/api/ea-exploration-analysis-file/", params=params)
537
573
 
538
574
  if json_output:
539
575
  console.print_json(data=results)
@@ -126,41 +126,56 @@ def get(
126
126
  @sqs_group.command()
127
127
  @click.option("--name", help="Exploration name")
128
128
  @click.option("--description", help="Exploration description")
129
- @click.option("--project", required=True, help="Project ID")
130
- @click.option("--auto-max-size", is_flag=True, help="Automatically determine max size")
131
129
  @click.option("--max-size", type=int, help="Maximum structure size")
132
- @click.option("--atom-count-limit", type=int, help="Upper limit for atom count")
133
130
  @click.option("--cutoffs", type=float, multiple=True, help="Cluster cutoff values")
134
- @click.option("--starting-structure", required=True, help="FHIAims simulation ID")
131
+ @click.option(
132
+ "--source-geometry",
133
+ required=True,
134
+ help="UserUpload ID for the source geometry",
135
+ )
136
+ @click.option(
137
+ "--target-concentration",
138
+ "target_concentrations",
139
+ multiple=True,
140
+ help="Target concentration in ELEMENT=WEIGHT format (weights must sum to 1.0)",
141
+ )
135
142
  @click.option("--json-output", is_flag=True, help="Output in JSON format")
136
143
  def create(
137
144
  name: Optional[str],
138
145
  description: Optional[str],
139
- project: str,
140
- auto_max_size: bool = False,
141
146
  max_size: Optional[int] = None,
142
- atom_count_limit: Optional[int] = None,
143
147
  cutoffs: Optional[List[float]] = None,
144
- starting_structure: str = None,
148
+ source_geometry: str = None,
149
+ target_concentrations: tuple = (),
145
150
  json_output: bool = False,
146
151
  ):
147
152
  """Create a new SQS exploration"""
148
153
  client = get_client()
149
154
  console = Console()
150
155
 
151
- data = {"project": project, "auto_max_size": auto_max_size}
156
+ parsed_targets = []
157
+ for tc in target_concentrations:
158
+ try:
159
+ element, weight = tc.split("=", 1)
160
+ parsed_targets.append({"element": element, "weight": float(weight)})
161
+ except ValueError:
162
+ console.print(
163
+ f"[red]Invalid --target-concentration format: {tc}. Use ELEMENT=WEIGHT[/red]"
164
+ )
165
+ return
166
+
167
+ data = {
168
+ "source_geometry": source_geometry,
169
+ "target_concentrations": parsed_targets,
170
+ }
152
171
  if name:
153
172
  data["name"] = name
154
173
  if description:
155
174
  data["description"] = description
156
175
  if max_size is not None:
157
176
  data["max_size"] = max_size
158
- if atom_count_limit is not None:
159
- data["atom_count_upper_limit"] = atom_count_limit
160
177
  if cutoffs:
161
178
  data["cluster_cutoffs"] = list(cutoffs)
162
- if starting_structure:
163
- data["starting_structure"] = starting_structure
164
179
 
165
180
  result = client.post("/api/sqs-exploration/", data=data)
166
181
 
@@ -210,7 +225,6 @@ def get_target_concentration(
210
225
  console.print(f"ID: {result['id']}")
211
226
  console.print(f"Exploration: {result['exploration']}")
212
227
  console.print(f"Element: {result.get('element', 'N/A')}")
213
- console.print(f"Concentration: {result.get('concentration', 'N/A')}")
214
228
  console.print(f"Weight: {result.get('weight', 'N/A')}")
215
229
  else:
216
230
  if not exploration:
@@ -235,7 +249,7 @@ def get_target_concentration(
235
249
  columns = [
236
250
  ("ID", "id", None),
237
251
  ("Element", "element", None),
238
- ("Concentration", "concentration", None),
252
+ ("Weight", "weight", None),
239
253
  ("Created", "created_at", format_datetime),
240
254
  ]
241
255
 
@@ -261,14 +275,15 @@ def get_target_concentration(
261
275
  @click.option("--exploration", required=True, help="SQS Exploration ID")
262
276
  @click.option("--element", required=True, help="Element symbol")
263
277
  @click.option(
264
- "--concentration", required=True, type=float, help="Target concentration (0-1)"
278
+ "--weight",
279
+ required=True,
280
+ type=float,
281
+ help="Target concentration weight (0-1)",
265
282
  )
266
- @click.option("--weight", type=float, help="Weight for this target concentration")
267
283
  @click.option("--json-output", is_flag=True, help="Output in JSON format")
268
284
  def create_target_concentration(
269
285
  exploration: str,
270
286
  element: str,
271
- concentration: float,
272
287
  weight: float,
273
288
  json_output: bool = False,
274
289
  ):
@@ -276,14 +291,13 @@ def create_target_concentration(
276
291
  client = get_client()
277
292
  console = Console()
278
293
 
279
- if not 0 <= concentration <= 1:
280
- console.print("[red]Concentration must be between 0 and 1[/red]")
294
+ if not 0 <= weight <= 1:
295
+ console.print("[red]Weight must be between 0 and 1[/red]")
281
296
  return
282
297
 
283
298
  data = {
284
299
  "exploration": exploration,
285
300
  "element": element,
286
- "concentration": concentration,
287
301
  "weight": weight,
288
302
  }
289
303
 
@@ -319,8 +333,8 @@ def create_simulation_file(
319
333
  console = Console()
320
334
 
321
335
  data = {
322
- "exploration": exploration,
323
- "user_upload": user_upload,
336
+ "exploration_id": exploration,
337
+ "user_upload_id": user_upload,
324
338
  }
325
339
 
326
340
  result = client.post("/api/sqs-simulation-file/", data=data)
@@ -129,7 +129,7 @@ def get_job(
129
129
  console = Console()
130
130
 
131
131
  if id:
132
- job = client.get(f"/api/k8s-job/{id}/")
132
+ job = client.get(f"/api/launchable-job/{id}/")
133
133
  if json_output:
134
134
  console.print_json(data=job)
135
135
  return
@@ -163,9 +163,9 @@ def get_job(
163
163
  return
164
164
 
165
165
  if fetch_all:
166
- results = client.get_all("/api/k8s-job/", params=params)
166
+ results = client.get_all("/api/launchable-job/", params=params)
167
167
  else:
168
- results = client.get("/api/k8s-job/", params=params)
168
+ results = client.get("/api/launchable-job/", params=params)
169
169
 
170
170
  if json_output:
171
171
  console.print_json(data=results)
@@ -49,7 +49,6 @@ def get(
49
49
  console.print(Panel(f"[bold]Project Details[/bold]"))
50
50
  console.print(f"ID: {result['id']}")
51
51
  console.print(f"Name: {result.get('name', 'N/A')}")
52
- console.print(f"Smiles: {result.get('thumbnail_smiles', 'N/A')}")
53
52
  console.print(f"Created: {format_datetime(result.get('created_at', 'N/A'))}")
54
53
  console.print(f"Updated: {format_datetime(result.get('updated_at', 'N/A'))}")
55
54
  if result.get("description_html"):
@@ -123,7 +122,6 @@ def get(
123
122
  columns = [
124
123
  ("ID", "id", None),
125
124
  ("Name", "name", None),
126
- ("Smiles", "thumbnail_smiles", None),
127
125
  ("Created", "created_at", format_datetime),
128
126
  ("Updated", "updated_at", format_datetime),
129
127
  ]
@@ -144,19 +142,23 @@ def get(
144
142
 
145
143
 
146
144
  @project_group.command()
147
- @click.option("--name", required=True, help="Project name")
145
+ @click.option("--name", help="Project name")
148
146
  @click.option("--description", help="Project description")
149
147
  @click.option("--json-output", is_flag=True, help="Output in JSON format")
150
- def create(name: str, description: Optional[str] = None, json_output: bool = False):
148
+ def create(
149
+ name: Optional[str] = None,
150
+ description: Optional[str] = None,
151
+ json_output: bool = False,
152
+ ):
151
153
  """Create a new project"""
152
154
  client = get_client()
153
155
  console = Console()
154
156
 
155
- data = {
156
- "name": name,
157
- }
157
+ data = {}
158
+ if name:
159
+ data["name"] = name
158
160
  if description:
159
- data["description"] = description
161
+ data["description_html"] = description
160
162
 
161
163
  result = client.post("/api/project/", data=data)
162
164
 
@@ -207,9 +209,9 @@ def get_note(
207
209
  console.print(f"Project: {result.get('project', 'N/A')}")
208
210
  console.print(f"Created: {format_datetime(result.get('created_at'))}")
209
211
  console.print(f"Updated: {format_datetime(result.get('updated_at'))}")
210
- if result.get("content"):
212
+ if result.get("content_html"):
211
213
  console.print("\n[bold]Content[/bold]")
212
- console.print(result["content"])
214
+ console.print(result["content_html"])
213
215
  else:
214
216
  params = {}
215
217
  if search is not None:
@@ -261,22 +263,24 @@ def get_note(
261
263
 
262
264
  @project_group.command()
263
265
  @click.option("--project", required=True, help="Project ID")
264
- @click.option("--title", required=True, help="Note title")
266
+ @click.option("--title", help="Note title")
265
267
  @click.option("--content", help="Note content")
266
268
  @click.option("--json-output", is_flag=True, help="Output in JSON format")
267
269
  def create_note(
268
- project: str, title: str, content: Optional[str] = None, json_output: bool = False
270
+ project: str,
271
+ title: Optional[str] = None,
272
+ content: Optional[str] = None,
273
+ json_output: bool = False,
269
274
  ):
270
275
  """Create a new project note"""
271
276
  client = get_client()
272
277
  console = Console()
273
278
 
274
- data = {
275
- "project": project,
276
- "title": title,
277
- }
279
+ data = {"project": project}
280
+ if title:
281
+ data["title"] = title
278
282
  if content:
279
- data["content"] = content
283
+ data["content_html"] = content
280
284
 
281
285
  result = client.post("/api/project-note/", data=data)
282
286