Skip to content

CCClient

chemcloud.client.CCClient

CCClient(*, chemcloud_username: Optional[str] = None, chemcloud_password: Optional[str] = None, profile: Optional[str] = None, chemcloud_domain: Optional[str] = None)

Main client object to perform computations using ChemCloud.

Parameters:

Name Type Description Default
chemcloud_username Optional[str]

ChemCloud username

None
chemcloud_password Optional[str]

ChemCloud password

None
profile Optional[str]

Authentication profile name

None
chemcloud_domain Optional[str]

Domain of ChemCloud instance to connect to

None

Danger

It is not recommended to pass your ChemCloud username and password directly to a CCClient. Instead instantiate a client with no credentials client = CCClient() and then run client.configure() to securely set up your authentication credentials for ChemCloud.

Source code in chemcloud/client.py
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
def __init__(
    self,
    *,
    chemcloud_username: Optional[str] = None,
    chemcloud_password: Optional[str] = None,
    profile: Optional[str] = None,
    chemcloud_domain: Optional[str] = None,
):
    """
    Initialize a CCClient object.

    Parameters:
        chemcloud_username: ChemCloud username
        chemcloud_password: ChemCloud password
        profile: Authentication profile name
        chemcloud_domain: Domain of ChemCloud instance to connect to

    !!! Danger
        It is not recommended to pass your ChemCloud username and
        password directly to a `CCClient`. Instead instantiate a client with no
        credentials `client = CCClient()` and then run `client.configure()` to
        securely set up your authentication credentials for ChemCloud.
    """
    self._client = _RequestsClient(
        chemcloud_username=chemcloud_username,
        chemcloud_password=chemcloud_password,
        profile=profile,
        chemcloud_domain=chemcloud_domain,
    )
    self._openapi_spec: Optional[Dict] = None

version property

version: str

Returns chemcloud client version

profile property

profile: str

Profile being used for authentication with ChemCloud.

Returns:

Type Description
str

The name of the credentials profile being used with the current client.

supported_programs property

supported_programs: List[str]

Compute programs currently supported by ChemCloud.

Returns:

Type Description
List[str]

List of programs currently supported by ChemCloud.

hello_world

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

A simple endpoint to check connectivity to ChemCloud.

Parameters:

Name Type Description Default
name Optional[str]

Your name

None

Returns:

Type Description
str

A message from ChemCloud if the client was able to successfully

str

connect.

Source code in chemcloud/client.py
87
88
89
90
91
92
93
94
95
96
97
def hello_world(self, name: Optional[str] = None) -> str:
    """A simple endpoint to check connectivity to ChemCloud.

    Parameters:
        name: Your name

    Returns:
        A message from ChemCloud if the client was able to successfully
        connect.
    """
    return self._client.hello_world(name)

compute

compute(program: str, inp_obj: QCIOInputsOrList, *, collect_stdout: bool = True, collect_files: bool = False, collect_wfn: bool = False, rm_scratch_dir: bool = True, propagate_wfn: bool = False, queue: Optional[str] = None) -> Union[FutureOutput, FutureOutputGroup]

Submit a computation to ChemCloud.

Parameters:

Name Type Description Default
program str

A program name matching one of the self.supported_programs

required
inp_obj QCIOInputsOrList

The input object to be used for the computation. This can be a single input object or a list of input objects.

required
collect_stdout bool

Whether to collect stdout/stderr from the program as output. Failed computations will always collect stdout/stderr.

True
collect_files bool

Collect all files generated by the QC program as output.

False
collect_wfn bool

Collect the wavefunction file(s) from the calculation. Not every program will support this. Use collect_files to collect all files including the wavefunction.

False
rm_scratch_dir bool

Delete the scratch directory after the program exits. Should only be set to False for debugging purposes.

True
propagate_wfn bool

For any adapter performing a sequential task, such as a geometry optimization, propagate the wavefunction from the previous step to the next step. This is useful for accelerating convergence by using a previously computed wavefunction as a starting guess. This will be ignored if the adapter for a given qc program does not support it.

False
queue Optional[str]

The name of a private compute queue. If None, default queue is used

None

Returns:

Type Description
Union[FutureOutput, FutureOutputGroup]

Object providing access to a computation's eventual result. You can check a

Union[FutureOutput, FutureOutputGroup]

computation's status by running .status on the FutureOutput object or

Union[FutureOutput, FutureOutputGroup]

.get() to block and retrieve the computation's final result.

Source code in chemcloud/client.py
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
def compute(
    self,
    program: str,
    inp_obj: QCIOInputsOrList,
    *,
    collect_stdout: bool = True,
    collect_files: bool = False,
    collect_wfn: bool = False,
    rm_scratch_dir: bool = True,
    propagate_wfn: bool = False,
    queue: Optional[str] = None,
) -> Union[FutureOutput, FutureOutputGroup]:
    """Submit a computation to ChemCloud.

    Parameters:
        program: A program name matching one of the `self.supported_programs`
        inp_obj: The input object to be used for the computation. This can be a
            single input object or a list of input objects.
        collect_stdout: Whether to collect stdout/stderr from the program as output.
            Failed computations will always collect stdout/stderr.
        collect_files: Collect all files generated by the QC program as output.
        collect_wfn: Collect the wavefunction file(s) from the calculation.
            Not every program will support this. Use collect_files to collect
            all files including the wavefunction.
        rm_scratch_dir: Delete the scratch directory after the program exits. Should
            only be set to False for debugging purposes.
        propagate_wfn: For any adapter performing a sequential task, such
            as a geometry optimization, propagate the wavefunction from the previous
            step to the next step. This is useful for accelerating convergence by
            using a previously computed wavefunction as a starting guess. This will
            be ignored if the adapter for a given qc program does not support it.
        queue: The name of a private compute queue. If None, default queue is used

    Returns:
        Object providing access to a computation's eventual result. You can check a
        computation's status by running `.status` on the `FutureOutput` object or
        `.get()` to block and retrieve the computation's final result.
    """
    if self.supported_programs is not None:
        assert (
            program in self.supported_programs
        ), f"Please use one of the following programs: {self.supported_programs}"

    compute_params = dict(
        program=program,
        collect_stdout=collect_stdout,
        collect_files=collect_files,
        collect_wfn=collect_wfn,
        rm_scratch_dir=rm_scratch_dir,
        propagate_wfn=propagate_wfn,
        queue=queue,
    )
    return self._client.compute(inp_obj, compute_params)

configure

configure(profile: str = settings.chemcloud_credentials_profile) -> None

Configure profiles for authentication with ChemCloud.

Parameters:

Name Type Description Default
profile str

Optional value to create a named profile for use with QC Cloud. No value needs to be passed and most users will only have one login with ChemCloud. CCClient will access the profile by default without a specific name being passed. Pass a value if you have multiple logins to ChemCloud.

chemcloud_credentials_profile

Note: Configures chemcloud to use the passed credentials automatically in the future. You will not need to run .configure() the next time you use the chemcloud.

Source code in chemcloud/client.py
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
def configure(self, profile: str = settings.chemcloud_credentials_profile) -> None:
    """Configure profiles for authentication with ChemCloud.

    Parameters:
        profile: Optional value to create a named profile for use with QC
            Cloud. No value needs to be passed and most users will only have one
            login with ChemCloud. CCClient will access the profile by
            default without a specific name being passed. Pass a value if you have
            multiple logins to ChemCloud.
    Note:
        Configures `chemcloud` to use the passed credentials automatically in the
        future. You will not need to run `.configure()` the next time you use the
        `chemcloud`.

    """
    print(
        "✅ If you don't get have an account please signup at: "
        f"{self._client._chemcloud_domain}/signup"
    )
    access_token, refresh_token = self._client._set_tokens_from_user_input()
    self._client.write_tokens_to_credentials_file(
        access_token, refresh_token, profile=profile
    )
    print(
        f"'{profile}' profile configured! Username/password not required for "
        "future use of CCClient"
    )