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

[#525] Add support for touch API operation #531

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

korydraughn
Copy link
Contributor

The implementation appears to work.

Just need to implement tests.

@trel
Copy link
Member

trel commented Apr 6, 2024

Why all caps error code? Is there precedent for that in PRC?

@korydraughn
Copy link
Contributor Author

Just not familiar with all the conventions yet. Also, I think I saw exceptions like that used in other places in the PRC.

Copy link
Collaborator

@d-w-moore d-w-moore left a comment

Choose a reason for hiding this comment

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

This is well done. I like the use of an irods.manager.common for commonly /multiply used code. Wonder now if we should scan for instances where irods.common would be similarly useful.

Approve the changes so far. Guess we'll have one more round once tests are implemented

irods/manager/collection_manager.py Show resolved Hide resolved
irods/manager/common.py Outdated Show resolved Hide resolved
@d-w-moore
Copy link
Collaborator

Why all caps error code? Is there precedent for that in PRC?

I don't know the valid uses of INVALID_OBJECT_TYPE , either. Not currently used otherwise, so may be a relic of something in PRC's past that got deleted. It appears also that it subclasses RuleEngineException, which may be misleading. I would suggest another error (possibly more targeted? Invalid_Path_For_Object_Type?)

@korydraughn
Copy link
Contributor Author

I added a new exception type, InvalidInputArgument, to replace the use of INVALID_OBJECT_TYPE.

All new tests pass. The only way I could run my tests was by skipping the iRODS version check code in helpers.make_session(). Is there another way to handle that?

@korydraughn korydraughn marked this pull request as ready for review April 7, 2024 15:28
@korydraughn
Copy link
Contributor Author

Forgot to mention this PR also adds modify_time and create_time to the replica object. See aad7740.

@korydraughn
Copy link
Contributor Author

Looks like I need to address a few more codacy issues.

irods/test/collection_test.py Outdated Show resolved Hide resolved
Copy link
Contributor

@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.

The meat of the change is good. Just a few suggestions/questions

irods/manager/collection_manager.py Outdated Show resolved Hide resolved
irods/manager/collection_manager.py Outdated Show resolved Hide resolved
irods/manager/common.py Outdated Show resolved Hide resolved
irods/manager/common.py Outdated Show resolved Hide resolved
irods/manager/data_object_manager.py Outdated Show resolved Hide resolved
irods/manager/collection_manager.py Show resolved Hide resolved
irods/test/collection_test.py Outdated Show resolved Hide resolved
irods/test/collection_test.py Outdated Show resolved Hide resolved
irods/test/data_obj_test.py Outdated Show resolved Hide resolved
irods/test/data_obj_test.py Show resolved Hide resolved
irods/test/collection_test.py Show resolved Hide resolved
irods/test/collection_test.py Outdated Show resolved Hide resolved
irods/test/collection_test.py Outdated Show resolved Hide resolved
irods/test/collection_test.py Outdated Show resolved Hide resolved
@korydraughn
Copy link
Contributor Author

korydraughn commented May 16, 2024

All review comments addressed.

All that's left is to run the full test suite.

Copy link
Contributor

@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.

Just had one more suggestion. Looks good otherwise

from irods.api_number import api_number
from irods.message import iRODSMessage, JSON_Message

def touch_impl(session, path, **options):
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be _touch_impl so that it discourages use? Feels like people should be calling the methods in data_object_manager or collection_manager. Thoughts?

Sounds like @d-w-moore is in favor of a module like this, so maybe I'm in the minority here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea. Keep them conventions coming.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thinking about this more, user code shouldn't import the util module at all. Are there conventions for expressing that?

Copy link
Collaborator

@d-w-moore d-w-moore May 24, 2024

Choose a reason for hiding this comment

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

@korydraughn @alanking - prefixing with underscore, ie renaming to _touch_impl as you said., is probably what you want. That's a clear enough indication to users this isn't for them to call. Also (and in support of that conclusion), a statement from <module> import * won't import symbols starting with underscores

Copy link
Collaborator

@d-w-moore d-w-moore May 24, 2024

Choose a reason for hiding this comment

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

(One can still do from X.Y.Z import _my_prefixed_thing or simply import X.Y.Z then then do something with X.Y.Z._my_prefixed_thing)

Copy link
Collaborator

@d-w-moore d-w-moore May 24, 2024

Choose a reason for hiding this comment

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

@alanking in other words doing __all__ = [ ] does not prevent individual import of symbols by name, nor does it prevent access to the module namespace. It simply does the best of Python symbol-hiding, which is to prevent mass clobbering (or just accidental importation) via from blah import *

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm just now seeing there were additional comments. My comment about moving forward with a source file level docstring didn't take the rest of the conversation into account.

I'm going to add leading underscores.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can also rename the module to use a leading underscore (e.g. _internal).

That seems to be a known convention. Thoughts?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I can also rename the module to use a leading underscore (e.g. _internal).

That seems to be a known convention. Thoughts?

That is true. Generally modules are considered not user domain if their names have a leading underscore.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good. I'll tweak the code to use leading underscores in the module name and functions. Then it becomes crystal clear that they are for internal use only.

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.

None yet

4 participants