Skip to content

Comments

[48] refactor to use free functions#49

Open
trel wants to merge 29 commits intoirods:mainfrom
trel:36-freefunctions.m
Open

[48] refactor to use free functions#49
trel wants to merge 29 commits intoirods:mainfrom
trel:36-freefunctions.m

Conversation

@trel
Copy link
Member

@trel trel commented Feb 19, 2026

currently a single commit beyond branch 36.m, will rebase once that is merged.

all tests pass

@alanking
Copy link

alanking commented Feb 19, 2026

What is the relationship between this PR and #44? Oh, I guess that's what 36.m is referring to. Nevermind.

@trel
Copy link
Member Author

trel commented Feb 19, 2026

yes, sorry - this builds on #44

@trel trel force-pushed the 36-freefunctions.m branch from 6caa135 to af5bee8 Compare February 20, 2026 00:57
@trel
Copy link
Member Author

trel commented Feb 20, 2026

coverage at 91%

- created HTTPSession class in common.py to encapsulate base URL and token
- updated modules and methods to accept HTTPSession instead of separate parameters
- updated test suite to use HTTPSession objects
@trel trel force-pushed the 36-freefunctions.m branch from e34111b to a729cd4 Compare February 21, 2026 04:22
@trel
Copy link
Member Author

trel commented Feb 21, 2026

rebased, single commit.

ready for review.

@trel
Copy link
Member Author

trel commented Feb 21, 2026

$ coverage report
Name                                     Stmts   Miss  Cover
------------------------------------------------------------
irods_http_client/__init__.py                4      0   100%
irods_http_client/collections.py            99      0   100%
irods_http_client/common.py                 25      0   100%
irods_http_client/data_objects.py          295      2    99%
irods_http_client/irods_http_client.py      21      2    90%
irods_http_client/queries.py                52      0   100%
irods_http_client/resources.py              75      0   100%
irods_http_client/rules.py                  22      0   100%
irods_http_client/tickets.py                38      0   100%
irods_http_client/users_groups.py          101      0   100%
irods_http_client/zones.py                  39      0   100%
------------------------------------------------------------
TOTAL                                      771      4    99%

the two lines in data_objects.py are reading and writing with a ticket. not sure how to do that.

Copy link

@korydraughn korydraughn left a comment

Choose a reason for hiding this comment

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

Looks good overall.

The main thing is in how errors are checked (string comparisons) and checking of HTTP status codes.

Comment on lines 542 to 566
headers = {
"Authorization": "Bearer " + session.token,
"Content-Type": "application/x-www-form-urlencoded",
}

data = {
"op": "write",
"offset": offset,
"truncate": truncate,
"append": append,
"bytes": bytes_,
}

if parallel_write_handle != "":
data["parallel-write-handle"] = parallel_write_handle
else:
data["lpath"] = lpath

if resource != "":
data["resource"] = resource

if stream_index != -1:
data["stream-index"] = stream_index

r = requests.post(session.url_base + "/data-objects", headers=headers, data=data) # noqa: S113

Choose a reason for hiding this comment

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

Probably want to encode this as multipart/form-data. See the tests which deal with parallel_write_init/shutdown.

@trel trel force-pushed the 36-freefunctions.m branch from 08aa01d to 40a54e2 Compare February 24, 2026 03:35
@trel
Copy link
Member Author

trel commented Feb 24, 2026

only one line untested - not sure how to generate that error text at the moment.

$ coverage report
Name                         Stmts   Miss  Cover
------------------------------------------------
irods_http/__init__.py           3      0   100%
irods_http/collections.py       90      0   100%
irods_http/common.py            21      0   100%
irods_http/data_objects.py     281      0   100%
irods_http/irods_http.py        27      1    96%
irods_http/queries.py           49      0   100%
irods_http/resources.py         68      0   100%
irods_http/rules.py             20      0   100%
irods_http/tickets.py           37      0   100%
irods_http/users_groups.py      89      0   100%
irods_http/zones.py             35      0   100%
------------------------------------------------
TOTAL                          720      1    99%

@trel trel force-pushed the 36-freefunctions.m branch from 65ec4a0 to a2be019 Compare February 24, 2026 04:36
Copy link

@alanking alanking left a comment

Choose a reason for hiding this comment

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

Given the size of this change and the fact that this hasn't been released yet, are there any areas in particular that you feel need special attention for review?

@trel
Copy link
Member Author

trel commented Feb 24, 2026

At this point, after the refactor to free functions, module naming, and lots of coverage work and test cleanup... I think there is only the one discussion about multipart/form-data that remains - #49 (comment)

Everything else feels pretty clean, and any fixups could happen after an initial release.

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.

3 participants