Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for initializing Connections from Settings instances #22

Merged
merged 9 commits into from
Apr 8, 2022

Conversation

Mandrenkov
Copy link
Collaborator

Context:
One of the most common operations performed by XCC users after configuring their Xanadu Cloud API key is creating a new Connection instance. The easiest way to do this without invoking the (private) xcc.commands.load_connection() function is to initialize a Settings instance and manually specify each keyword argument to Connection.__init__(); however, this is quite tedious and leads to a suboptimal user experience.

Description of the Change:

  • Added the Connection.load() function which creates a Connection object from an implicit or explicit Settings instance.
import xcc

# Initialize a Connection using an implicit Settings instance.
connection = xcc.Connection.load()

# Initialize a Connection using an explicit Settings instance.
connection = xcc.Connection.load(settings=xcc.Settings())

Benefits:

  • It is easier to instantiate a Connection instance using environment variables or the Xanadu Cloud .env file.

Possible Drawbacks:
None.

Related GitHub Issues:
None.

Copy link
Contributor

@doctorperceptron doctorperceptron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great feature!

@Mandrenkov Mandrenkov merged commit e6f68d0 into main Apr 8, 2022
@Mandrenkov Mandrenkov deleted the sc-17419-accessible-connection-loader branch April 8, 2022 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants