Skip to content

Main Methods

Top-level methods for running calculations with chemcloud. Most users should never need to use anything except these methods for running calculations on chemcloud.

chemcloud

ChemCloud python client. Scalable compute, easy to learn, fast to code.

compute

compute(
    *args, **kwargs
) -> Union[
    ProgramOutput, list[ProgramOutput], FutureOutput
]

Submit a compute job using the default client.

See CCClient.compute for more information.

Usage
from qcio import ProgramInput, Structure
from chemcloud import compute

struct = Structure.open("structure.xyz")
prog_input = ProgramInput(
    calctype="energy",
    structure=struct,
    model={"method": "b3lyp", "basis": "6-31g"},
    keywords={},  # Optional keywords for the program
    )

# Submit a single job
output = compute("psi4", prog_input)

# Submit multiple jobs
prog_inputs = [prog_input] * 100  # List of ProgramInput objects
outputs = compute("psi4", prog_inputs)

Results may be collected asynchronously if desired:

future = compute("psi4", prog_inputs, return_future=True)
future.is_ready  # Checks if all tasks are complete (not required)
outputs = future.get()  # Collects results

Or stream results from the server as they complete:

future = compute("psi4", prog_inputs, return_future=True)
for output in future.as_completed():  # Will return results as the complete
    # Process outputs
Source code in chemcloud/__init__.py
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
def compute(*args, **kwargs) -> Union[ProgramOutput, list[ProgramOutput], FutureOutput]:
    """Submit a compute job using the default client.

    See [CCClient.compute][chemcloud.client.CCClient.compute] for more information.

    Usage:
        ```python
        from qcio import ProgramInput, Structure
        from chemcloud import compute

        struct = Structure.open("structure.xyz")
        prog_input = ProgramInput(
            calctype="energy",
            structure=struct,
            model={"method": "b3lyp", "basis": "6-31g"},
            keywords={},  # Optional keywords for the program
            )

        # Submit a single job
        output = compute("psi4", prog_input)

        # Submit multiple jobs
        prog_inputs = [prog_input] * 100  # List of ProgramInput objects
        outputs = compute("psi4", prog_inputs)
        ```

        Results may be collected asynchronously if desired:

        ```python
        future = compute("psi4", prog_inputs, return_future=True)
        future.is_ready  # Checks if all tasks are complete (not required)
        outputs = future.get()  # Collects results
        ```

        Or stream results from the server as they complete:

        ```python
        future = compute("psi4", prog_inputs, return_future=True)
        for output in future.as_completed():  # Will return results as the complete
            # Process outputs
        ```
    """
    global _default_client
    if _default_client is None:
        _default_client = CCClient()
    return _default_client.compute(*args, **kwargs)

configure_client

configure_client(**kwargs) -> None

Configure the default ChemCloud client.

Passes keyword arguments to CCClient constructor. See CCClient for more information.

Usage

Pass any of the following keyword arguments before calling compute to configure the client.

from chemcloud import configure_client

configure_client(
    chemcloud_username="testuser",  # Not recommended
    chemcloud_password="testpassword",  # Not recommended  # pragma: allowlist secret
    chemcloud_domain="https://example.com",
    profile="testprofile",
    queue="myqueue",
    )
Source code in chemcloud/__init__.py
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
def configure_client(**kwargs) -> None:
    """Configure the default ChemCloud client.

    Passes keyword arguments to CCClient constructor.
    See [CCClient][chemcloud.client.CCClient] for more information.

    Usage:
        Pass any of the following keyword arguments before calling
        [compute][chemcloud.compute] to configure the client.

        ```python
        from chemcloud import configure_client

        configure_client(
            chemcloud_username="testuser",  # Not recommended
            chemcloud_password="testpassword",  # Not recommended  # pragma: allowlist secret
            chemcloud_domain="https://example.com",
            profile="testprofile",
            queue="myqueue",
            )
        ```
    """
    global _default_client
    _default_client = CCClient(**kwargs)

setup_profile

setup_profile(profile: Optional[str] = None) -> None

Setup a profile for the ChemCloud client.

See CCClient.setup_profile for more information.

Source code in chemcloud/__init__.py
100
101
102
103
104
105
106
def setup_profile(profile: Optional[str] = None) -> None:
    """Setup a profile for the ChemCloud client.

    See [CCClient.setup_profile][chemcloud.client.CCClient.setup_profile] for more information.
    """
    client = CCClient()
    client.setup_profile(profile)

fetch_output

fetch_output(*args, **kwargs)

Fetch the status and output of a compute job using the default client.

Only needed if you want on manually check the status of a compute job. This function is usually not used by end users.

See CCClient.fetch_output for more information.

Source code in chemcloud/__init__.py
109
110
111
112
113
114
115
116
117
118
119
120
def fetch_output(*args, **kwargs):
    """Fetch the status and output of a compute job using the default client.

    Only needed if you want on manually check the status of a compute job. This function
    is usually not used by end users.

    See [CCClient.fetch_output][chemcloud.client.CCClient.fetch_output] for more information.
    """
    global _default_client
    if _default_client is None:
        _default_client = CCClient()
    return _default_client.fetch_output(*args, **kwargs)

hello_world

hello_world(name: Optional[str] = None) -> str

Return a greeting message from the ChemCloud server.

See CCClient.hello_world for more information.

Source code in chemcloud/__init__.py
123
124
125
126
127
128
129
130
131
def hello_world(name: Optional[str] = None) -> str:
    """Return a greeting message from the ChemCloud server.

    See [CCClient.hello_world][chemcloud.client.CCClient.hello_world] for more information.
    """
    global _default_client
    if _default_client is None:
        _default_client = CCClient()
    return _default_client.hello_world(name)