- 
                Notifications
    You must be signed in to change notification settings 
- Fork 2
fix: Don't fail on required rclone options that have default values #1077
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
          
     Open
      
      
            eikek
  wants to merge
  5
  commits into
  main
  
    
      
        
          
  
    
      Choose a base branch
      
     
    
      
        
      
      
        
          
          
        
        
          
            
              
              
              
  
           
        
        
          
            
              
              
           
        
       
     
  
        
          
            
          
            
          
        
       
    
      
from
eikek/s3-endpoint-fix
  
      
      
   
  
    
  
  
  
 
  
      
    base: main
Could not load branches
            
              
  
    Branch not found: {{ refName }}
  
            
                
      Loading
              
            Could not load tags
            
            
              Nothing to show
            
              
  
            
                
      Loading
              
            Are you sure you want to change the base?
            Some commits from the old base branch may be removed from the timeline,
            and old review comments may become outdated.
          
          
      
        
          +45
        
        
          −6
        
        
          
        
      
    
  
  
     Open
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            5 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      4f6920b
              
                Don't check required rclone options with default values
              
              
                eikek 8306631
              
                Inject defaults for required rclone options for "test connection"
              
              
                eikek 035388e
              
                Inject rclone default values when mounting
              
              
                eikek b4ab011
              
                temporarily deactivate failing test
              
              
                eikek c79f4a8
              
                Inject only default values matching the provider in the config
              
              
                eikek File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
        
          
  
    
      
          
            10 changes: 10 additions & 0 deletions
          
          10 
        
  test/components/renku_data_services/storage/test_rclone.py
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| """Tests for the rclone module.""" | ||
|  | ||
| from renku_data_services.storage.rclone import RCloneValidator | ||
|  | ||
|  | ||
| def test_validate_switch_s3_no_endpoint() -> None: | ||
| """Endpoint has a default value and is not required to specify.""" | ||
| validator = RCloneValidator() | ||
| cfg = {"provider": "Switch", "type": "s3"} | ||
| validator.validate(cfg, keep_sensitive=True) | 
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While the expression does it job, I wonder if it wouldn't be nicer to rewrite it to be a bit clearer.
I thing the main initial check is whether
configcontains the value. It's also the only positive check in the chain so I would put it first and then all the others.Another possibility could be:
I think it makes the intent a bit clearer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, to my taste, this is not cleaner or easier to read 😅. We could then do more and pull out the
notand saynot all([…])to save a fewnots … But it doesn't look better to me, either.I think the expression easy enough to understand. In general, I like to place the condition first that most likely triggers the short circuit. The downside of the
any|all(…)is that it allocates a new list for no real reason, imo. There are many options in the schema, only a few are required. The config object holds very few from what I could see. I chosenot opt.requiredbecause I think it matches in most cases.Now, I don't have a strong opinion - to me any equivalent variant is fine. If there is a strong opinion, I happily change it to match any taste, just let me know the preferred way.