Skip to content

[#827] Add README text on usage of iRODSSession instances - #832

Open
d-w-moore wants to merge 1 commit into
irods:mainfrom
d-w-moore:827.m
Open

[#827] Add README text on usage of iRODSSession instances#832
d-w-moore wants to merge 1 commit into
irods:mainfrom
d-w-moore:827.m

Conversation

@d-w-moore

Copy link
Copy Markdown
Collaborator

No description provided.

@korydraughn korydraughn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Wording seems good.

Are we encouraging the use of irods.helpers and make_session()?
Are they meant for general usage?

Comment thread README.md
Comment on lines +49 to +70
```python
from irods.helpers import make_session
sess1 = make_session()

# Possible patterns include:
# 1. keeping a ready reference to the session.

sess1.collections.get(f'/tempZone/home/{session.username}')
# (... Further instances of calls to the server through sess1 may follow.)

# or:
# 2. using the session object with a context manager.

with make_session() as sess2:
my_user = sess2.users.get(ses.username)
# Here, we can have other statements using sess2, and at end
# of code block, sess2.cleanup() is implicitly called.

# sess1 retains an idle but reusable connection whereas sess2 does not; i.e.
# sess1.pool.idle has length 1, and sess2.pool.idle is an empty set.
# However, both sessions are equally open for further server interactions.
```

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Consider splitting this into two independent code blocks. That should help the reader see the edges of each approach.

Comment thread README.md
Comment on lines +49 to +70
```python
from irods.helpers import make_session
sess1 = make_session()

# Possible patterns include:
# 1. keeping a ready reference to the session.

sess1.collections.get(f'/tempZone/home/{session.username}')
# (... Further instances of calls to the server through sess1 may follow.)

# or:
# 2. using the session object with a context manager.

with make_session() as sess2:
my_user = sess2.users.get(ses.username)
# Here, we can have other statements using sess2, and at end
# of code block, sess2.cleanup() is implicitly called.

# sess1 retains an idle but reusable connection whereas sess2 does not; i.e.
# sess1.pool.idle has length 1, and sess2.pool.idle is an empty set.
# However, both sessions are equally open for further server interactions.
```

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think the comments in the code example should be moved outside of it. They capture the main thing we want to emphasize.

@d-w-moore d-w-moore changed the title Add README text on usage of iRODSSession instances [#827] Add README text on usage of iRODSSession instances Sep 4, 2026
@d-w-moore

Copy link
Copy Markdown
Collaborator Author

Wording seems good.

Are we encouraging the use of irods.helpers and make_session()? Are they meant for general usage?

I don't feel we have to encourage it ... if the mention of it as the first option seems like encouraging, perhaps a reorganization is needed. The upshot is: a client environment set up, make_session is the quickest way to create and authenticate.

There is this: make_session is used widely in the tests, with only the tiny difference that the version called from the tests will vet the connected server version internally before continuing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants