- 
                Notifications
    You must be signed in to change notification settings 
- Fork 0
          Added a method to collect the run metadata
          #7
        
          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
      
      
            frankcorneliusmartin
  wants to merge
  5
  commits into
  main
  
    
      
        
          
  
    
      Choose a base branch
      
     
    
      
        
      
      
        
          
          
        
        
          
            
              
              
              
  
           
        
        
          
            
              
              
           
        
       
     
  
        
          
            
          
            
          
        
       
    
      
from
feature/add-metadata-decorator-retrieval-function
  
      
      
   
  
    
  
  
  
 
  
      
    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.
          
          
  
     Open
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            5 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      9efc70e
              
                Added a method to collect the run `metadata`
              
              
                frankcorneliusmartin ddc9102
              
                Added unittests for the `@metadata` decorator
              
              
                frankcorneliusmartin 4fb7cd6
              
                Added pytest to the dependencies
              
              
                frankcorneliusmartin eaeb65c
              
                Added tests for the `read_csv` and `sleep` functions
              
              
                frankcorneliusmartin e67e4d0
              
                Updated `algorithm_store.json` definition for the `metadata` function.
              
              
                frankcorneliusmartin 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
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| from importlib.resources import files | ||
|  | ||
| from vantage6.mock.mock_network import MockNetwork, MockUserClient | ||
| import pytest | ||
|  | ||
|  | ||
| @pytest.fixture | ||
| def mock_client() -> MockUserClient: | ||
| test_data = files("v6-session-basics").joinpath("data/test_data.csv") | ||
| mock_network = MockNetwork( | ||
| module_name="v6-session-basics", | ||
| datasets=[ | ||
| { | ||
| "test_data_1": { | ||
| "database": test_data, | ||
| "db_type": "csv", | ||
| }, | ||
| }, | ||
| { | ||
| "test_data_1": { | ||
| "database": test_data, | ||
| "db_type": "csv", | ||
| }, | ||
| } | ||
| ] | ||
| ) | ||
| return MockUserClient(mock_network) | ||
|  | ||
| def test_metadata_function(mock_client: MockUserClient): | ||
| """Test the metadata function""" | ||
| # Get organizations | ||
| orgs = mock_client.organization.list() | ||
| org_ids = [org["id"] for org in orgs] | ||
|  | ||
| # Create task | ||
| task = mock_client.task.create( | ||
| method="metadata", organizations=org_ids, arguments={} | ||
| ) | ||
|  | ||
| # Wait for results | ||
| results = mock_client.wait_for_results(task.get("id")) | ||
|  | ||
| # Assertions | ||
| assert results is not None | ||
| assert len(results) == 2 # Two organizations | ||
| for result in results: | ||
| assert "task_id" in result | ||
| assert "node_id" in result | ||
| assert "collaboration_id" in result | ||
| assert "organization_id" in result | ||
| assert "temporary_directory" in result | ||
| assert "output_file" in result | ||
| assert "input_file" in result | ||
| assert "token" in result | ||
| assert "action" in result | ||
|  | ||
| print(results) | 
  
    
      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,54 @@ | ||
| from importlib.resources import files | ||
| import pandas as pd | ||
| import pytest | ||
|  | ||
| from vantage6.mock.mock_network import MockNetwork, MockUserClient | ||
|  | ||
|  | ||
| @pytest.fixture | ||
| def mock_client() -> MockUserClient: | ||
| test_data = files("v6-session-basics").joinpath("data/test_data.csv") | ||
| mock_network = MockNetwork( | ||
| module_name="v6-session-basics", | ||
| datasets=[ | ||
| { | ||
| "test_data_1": { | ||
| "database": test_data, | ||
| "db_type": "csv", | ||
| }, | ||
| }, | ||
| { | ||
| "test_data_1": { | ||
| "database": test_data, | ||
| "db_type": "csv", | ||
| }, | ||
| } | ||
| ] | ||
| ) | ||
| return MockUserClient(mock_network) | ||
|  | ||
|  | ||
| def test_read_csv_function(mock_client: MockUserClient): | ||
| """Test the read_csv function""" | ||
| # Get organizations | ||
| orgs = mock_client.organization.list() | ||
| org_ids = [org["id"] for org in orgs] | ||
|  | ||
| # Create task | ||
| mock_client.dataframe.create( | ||
| method="read_csv", | ||
| organizations=org_ids, | ||
| arguments={}, | ||
| action="data_extraction", | ||
| label="test_data_1", | ||
| name="my_dataframe_by_frank" | ||
| ) | ||
|  | ||
| # A data extraction job should create a dataframe on each node, lets check if this | ||
| # is the case. Note that in the mock network we store the dataframes in the Python | ||
| # session as pandas dataframes while in the real network we store them at disk as | ||
| # parquet files. | ||
| for node in mock_client.network.nodes: | ||
| assert len(node.dataframes) == 1 | ||
| assert "my_dataframe_by_frank" in node.dataframes | ||
| assert isinstance(node.dataframes["my_dataframe_by_frank"], pd.DataFrame) | 
  
    
      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,49 @@ | ||
| from importlib.resources import files | ||
|  | ||
| from vantage6.mock.mock_network import MockNetwork, MockUserClient | ||
| import pytest | ||
|  | ||
|  | ||
| @pytest.fixture | ||
| def mock_client() -> MockUserClient: | ||
| test_data = files("v6-session-basics").joinpath("data/test_data.csv") | ||
| mock_network = MockNetwork( | ||
| module_name="v6-session-basics", | ||
| datasets=[ | ||
| { | ||
| "test_data_1": { | ||
| "database": test_data, | ||
| "db_type": "csv", | ||
| }, | ||
| }, | ||
| { | ||
| "test_data_1": { | ||
| "database": test_data, | ||
| "db_type": "csv", | ||
| }, | ||
| } | ||
| ] | ||
| ) | ||
| return mock_network.user_client | ||
|  | ||
| def test_sleep_function(mock_client: MockUserClient): | ||
| """Test the metadata function""" | ||
| # Get organizations | ||
| orgs = mock_client.organization.list() | ||
| org_ids = [org["id"] for org in orgs] | ||
|  | ||
| # Note that the tasks here are run in sequence, thus sleeping for 1 seconds will | ||
| # be multiplied by the number of organizations. | ||
| task = mock_client.task.create( | ||
| method="sleep", organizations=org_ids, arguments={"seconds": 1} | ||
| ) | ||
|  | ||
| # Wait for results | ||
| results = mock_client.wait_for_results(task.get("id")) | ||
|  | ||
| # Assertions | ||
| assert results is not None | ||
| assert len(results) == 2 # Two organizations | ||
| for result in results: | ||
| assert "sleep" in result | ||
| assert result["sleep"] == "done" | 
            File renamed without changes.
          
    
  
    
      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
    
  
  
    
              
  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.
When adding dependencies on the main level, it would be good to do
uv syncso that theuv.lockis also updated to reflect this added dependency.Actually, I think we hardly ever need to manually modify the pyproject.toml anymore - dependencies should be added/modified by uv commands such as, in this case,
uv add pytest