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

improved retrievals and adaptions to next pyslk release #48

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

Conversation

neumannd
Copy link
Collaborator

@neumannd neumannd commented Dec 5, 2024

@neumannd neumannd added the enhancement New feature or request label Dec 5, 2024
@neumannd
Copy link
Collaborator Author

neumannd commented Dec 5, 2024

@observingClouds Can I prevent somehow that tests are generated automatically for all pyslk functions? Setting up all SlkMock functions properly will take a lot of time.

@observingClouds
Copy link
Owner

@neumannd can you point me to some tests? I think I cannot completely follow you. You just need to mock those functions that are actually used within slkspec.

@neumannd
Copy link
Collaborator Author

@observingClouds

You just need to mock those functions that are actually used within slkspec.

That's the main issue I have. It is quite time consuming to set up proper mock functions for this purpose. I am aware that this would be the proper proceedure. But, I am lacking time to finished this task in December. Would you merge anyway?

@observingClouds
Copy link
Owner

I have to say no here as I believe it's crucial for all code additions to pass the tests to maintain the integrity of the project.

@neumannd
Copy link
Collaborator Author

neumannd commented Feb 6, 2025

@observingClouds : The tests succeed now. @doguskbilir Updated the mock functions. Do you have any comments on the current code version?

Additionally, @doguskbilir is working on setting up a pyproject.toml file for the installation of the package. Thus, the old installation method via setup.py could be replaced by it. However, we do this in an extra PR?

@observingClouds
Copy link
Owner

Amazing! Great work! Yes, please do the pyproject.toml update in a separate PR.

@observingClouds observingClouds self-requested a review February 8, 2025 11:46
Copy link
Owner

@observingClouds observingClouds left a comment

Choose a reason for hiding this comment

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

Thanks @neumannd and @doguskbilir for this hard work! I really appreciate it. My main comment is about the complexity of _retrieve_item(). Please restructure it so that flake8 does no longer complain about C901. I think with a few extra functions and classes it will become much more readable and help us in the long run to maintain this package better.

@@ -135,23 +155,686 @@ def name(self) -> str:
return self._file
return self._url

# flake8: noqa: C901
Copy link
Owner

Choose a reason for hiding this comment

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

I am sorry to delay this further, but flake8 has correctly identified this >500 line long function to be too complicated. Could you please break this up into several function and use e.g. dataclasses to group some of the variables so that flake8 is happy again, e.g.

@dataclass
class TapeRecallStatus:
    success: Set[str] = field(default_factory=set)
    active: Set[str] = field(default_factory=set)
    failed: Dict[str, str] = field(default_factory=dict)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'll split it up 👍

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The reason why I did no split this up as completely independent functions -- but used a sub-function (or how they are called) -- is that there are many arguments required and these arguments need to be modified. I think the most reasonable approach here would be to set up a specific class for this ... . Need to think about it.

slkspec/core.py Outdated Show resolved Hide resolved
slkspec/core.py Show resolved Hide resolved
Comment on lines +700 to +713
"""
{'SKIPPED': {'SKIPPED_TARGET_EXISTS': ['/arch/bm0146/k204221/iow/INDEX.txt']},
'FILES': {'/arch/bm0146/k204221/iow/INDEX.txt': '/home/k204221/tmp/INDEX.txt'}}

# dry run
{'ENVISAGED': {'ENVISAGED': ['/arch/bm0146/k204221/iow/INDEX.txt']},
'FILES': {'/arch/bm0146/k204221/iow/INDEX.txt': '/home/k204221/tmp/abcdef2/INDEX.txt'}}

# after successful retrieval
{'ENVISAGED': {'ENVISAGED': []}, 'FILES': {'/arch/bm0146/k204221/iow/INDEX.txt':
'/home/k204221/tmp/INDEX.txt'}, 'SUCCESS': {'SUCCESS': ['/arch/bm0146/k204221/iow/INDEX.txt']}}

{'FAILED': {'FAILED_NOT_CACHED': ['/arch/bm0146/k204221/iow/iow_data5_001.tar']},
'FILES': {'/arch/bm0146/k204221/iow/iow_data5_001.tar': '/home/k204221/tmp/iow_data5_001.tar'}}
Copy link
Owner

Choose a reason for hiding this comment

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

This could go into the docstring of a new function?!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'll check.

Comment on lines +315 to +318
# +----------------------------------------------------------
# | CHECK STATUS OF RUNNING JOBS
# +----------------------------------------------------------
# check if there are jobs running for whole tapes:
Copy link
Owner

Choose a reason for hiding this comment

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

I am not a fan of these comment, ideally this would become obvious from the function names.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'll check it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants