Skip to content

Commit

Permalink
Merge branch 'main' into 142-remove-return_gufe
Browse files Browse the repository at this point in the history
  • Loading branch information
ianmkenney authored Dec 4, 2023
2 parents e801045 + 76c439c commit a32f1ba
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions alchemiscale/interface/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ def create_network(
network: AlchemicalNetwork,
scope: Scope,
compress: Union[bool, int] = True,
visualize: bool = True,
) -> ScopedKey:
"""Submit an AlchemicalNetwork to a specific Scope.
Expand All @@ -105,6 +106,8 @@ def create_network(
Use an integer between 0 and 9 for finer control over
the degree of compression; 0 means no compression, 9 means max
compression. ``True`` is synonymous with level 5 compression.
visualize
If ``True``, show submission progress indicator.
Returns
-------
Expand All @@ -119,16 +122,25 @@ def create_network(

validate_network_nonself(network)

from rich.progress import Progress

sk = self.get_scoped_key(network, scope)
with Progress(*self._rich_waiting_columns(), transient=False) as progress:
task = progress.add_task(f"Submitting [bold]'{sk}'[/bold]...", total=None)

def post():
data = dict(network=network.to_dict(), scope=scope.dict())
scoped_key = self._post_resource("/networks", data, compress=compress)
progress.start_task(task)
progress.update(task, total=1, completed=1)
return self._post_resource("/networks", data, compress=compress)

if visualize:
from rich.progress import Progress

with Progress(*self._rich_waiting_columns(), transient=False) as progress:
task = progress.add_task(
f"Submitting [bold]'{sk}'[/bold]...", total=None
)

scoped_key = post()
progress.start_task(task)
progress.update(task, total=1, completed=1)
else:
scoped_key = post()

return ScopedKey.from_dict(scoped_key)

Expand Down

0 comments on commit a32f1ba

Please sign in to comment.