- 
                Notifications
    
You must be signed in to change notification settings  - Fork 32
 
          ♻️ Extract workbench from projects to projects_nodes table 🗃️
          #7010
        
          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
          
     Merged
      
      
            giancarloromeo
  merged 72 commits into
  ITISFoundation:master
from
giancarloromeo:is5646/extract-projects-workbench-column
  
      
      
   
  Jan 21, 2025 
      
    
  
     Merged
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            72 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      5807f81
              
                extract first columns
              
              
                giancarloromeo 4573217
              
                add migration script
              
              
                giancarloromeo 05f619b
              
                update thumbnail
              
              
                giancarloromeo 4c566ad
              
                update script
              
              
                giancarloromeo 9494ab0
              
                add more data
              
              
                giancarloromeo dbc6366
              
                Merge branch 'master' into is5646/extract-projects-workbench-column
              
              
                giancarloromeo bc54acc
              
                fix test
              
              
                giancarloromeo e97a1cf
              
                fix node create
              
              
                giancarloromeo bd9c666
              
                fix node creation mock
              
              
                giancarloromeo 11455b2
              
                fix fixture
              
              
                giancarloromeo 031d947
              
                fix fixture
              
              
                giancarloromeo d0f989e
              
                Merge branch 'master' into is5646/extract-projects-workbench-column
              
              
                giancarloromeo 49415a5
              
                add columns
              
              
                giancarloromeo 0b701a7
              
                fix sql
              
              
                giancarloromeo 4b91286
              
                fix column name
              
              
                giancarloromeo ebd80bb
              
                add fields
              
              
                giancarloromeo 99a9eab
              
                Merge branch 'master' into is5646/extract-projects-workbench-column
              
              
                giancarloromeo 3bbd502
              
                fix imports
              
              
                giancarloromeo a325b15
              
                Merge remote-tracking branch 'upstream/master' into is5646/extract-pr…
              
              
                giancarloromeo a0fbe08
              
                Merge remote-tracking branch 'upstream/master' into is5646/extract-pr…
              
              
                giancarloromeo c7845fc
              
                add new repo
              
              
                giancarloromeo 95bce7e
              
                Merge remote-tracking branch 'upstream/master' into is5646/extract-pr…
              
              
                giancarloromeo 7d00d5d
              
                fix import
              
              
                giancarloromeo 48145b4
              
                fix mapping
              
              
                giancarloromeo f71c1c6
              
                fix model
              
              
                giancarloromeo 56099a8
              
                fix model
              
              
                giancarloromeo 9136b34
              
                fix field name
              
              
                giancarloromeo 279e538
              
                add output update
              
              
                giancarloromeo d45aace
              
                rename service
              
              
                giancarloromeo 9572145
              
                add missing column
              
              
                giancarloromeo 851c5be
              
                fix tests
              
              
                giancarloromeo cee9f8a
              
                Merge branch 'master' into is5646/extract-projects-workbench-column
              
              
                giancarloromeo d2fd817
              
                store only set values
              
              
                giancarloromeo 0ac9501
              
                Merge branch 'is5646/extract-projects-workbench-column' of github.com…
              
              
                giancarloromeo 55b60bc
              
                fix update node state
              
              
                giancarloromeo d73fed1
              
                fix packages
              
              
                giancarloromeo 46cfc4b
              
                Merge branch 'master' into is5646/extract-projects-workbench-column
              
              
                giancarloromeo ac8c9a6
              
                update sql
              
              
                giancarloromeo 6a865f3
              
                fix name
              
              
                giancarloromeo 459d567
              
                fix pylint
              
              
                giancarloromeo 0db6bc5
              
                Merge remote-tracking branch 'upstream/master' into is5646/extract-pr…
              
              
                giancarloromeo be92b63
              
                revert _base.py
              
              
                giancarloromeo be56df7
              
                add migration SQL cmd
              
              
                giancarloromeo a79bc7e
              
                update script
              
              
                giancarloromeo c48529d
              
                fix pylint
              
              
                giancarloromeo 5d92523
              
                fix model
              
              
                giancarloromeo 733055a
              
                blank
              
              
                giancarloromeo e93491f
              
                add get
              
              
                giancarloromeo 31c4f50
              
                fix column
              
              
                giancarloromeo 8f44d30
              
                add more columns
              
              
                giancarloromeo 2d45d5c
              
                blank
              
              
                giancarloromeo 623f926
              
                add issue reference
              
              
                giancarloromeo 0e46459
              
                Merge remote-tracking branch 'upstream/master' into is5646/extract-pr…
              
              
                giancarloromeo 2abb1e2
              
                fixes
              
              
                giancarloromeo 61c13e9
              
                requild script
              
              
                giancarloromeo 9d80edd
              
                remove validation
              
              
                giancarloromeo 931bbec
              
                rename method
              
              
                giancarloromeo cdd0e95
              
                pylint
              
              
                giancarloromeo 904d6e9
              
                update comment
              
              
                giancarloromeo 1b232d8
              
                Merge branch 'master' into is5646/extract-projects-workbench-column
              
              
                giancarloromeo 3f7f275
              
                remove deprecated
              
              
                giancarloromeo 893e9ed
              
                remove unused model
              
              
                giancarloromeo d2536cf
              
                Merge branch 'master' into is5646/extract-projects-workbench-column
              
              
                giancarloromeo b227c16
              
                Merge branch 'master' into is5646/extract-projects-workbench-column
              
              
                giancarloromeo febe935
              
                update comment
              
              
                giancarloromeo 24f0155
              
                Merge branch 'is5646/extract-projects-workbench-column' of github.com…
              
              
                giancarloromeo cb26397
              
                Merge remote-tracking branch 'upstream/master' into is5646/extract-pr…
              
              
                giancarloromeo 3a168e9
              
                update script
              
              
                giancarloromeo 58c1aed
              
                fix sonar
              
              
                giancarloromeo 65b43a1
              
                fix names
              
              
                giancarloromeo fc408e1
              
                fix import
              
              
                giancarloromeo 5ece129
              
                Merge branch 'master' into is5646/extract-projects-workbench-column
              
              
                giancarloromeo 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
    
  
  
    
              
        
          
  
    
      
          
            227 changes: 227 additions & 0 deletions
          
          227 
        
  ...src/simcore_postgres_database/migration/versions/ecd4eadaa781_extract_workbench_column.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,227 @@ | ||
| """extract workbench column | ||
| 
     | 
||
| Revision ID: ecd4eadaa781 | ||
| Revises: a3a58471b0f1 | ||
| Create Date: 2025-01-21 13:13:18.256109+00:00 | ||
| 
     | 
||
| """ | ||
| import sqlalchemy as sa | ||
| from alembic import op | ||
| from sqlalchemy.dialects import postgresql | ||
| 
     | 
||
| # revision identifiers, used by Alembic. | ||
| revision = "ecd4eadaa781" | ||
| down_revision = "a3a58471b0f1" | ||
| branch_labels = None | ||
| depends_on = None | ||
| 
     | 
||
| 
     | 
||
| def upgrade(): | ||
| # ### commands auto generated by Alembic - please adjust! ### | ||
| op.add_column( | ||
| "projects_nodes", | ||
| sa.Column( | ||
| "key", | ||
| sa.String(), | ||
| nullable=False, | ||
| comment="Distinctive name (based on the Docker registry path)", | ||
| ), | ||
| ) | ||
| op.add_column( | ||
| "projects_nodes", | ||
| sa.Column( | ||
| "version", sa.String(), nullable=False, comment="Semantic version number" | ||
| ), | ||
| ) | ||
| op.add_column( | ||
| "projects_nodes", | ||
| sa.Column( | ||
| "label", sa.String(), nullable=False, comment="Short name used for display" | ||
| ), | ||
| ) | ||
| op.add_column( | ||
| "projects_nodes", | ||
| sa.Column( | ||
| "progress", sa.Numeric(), nullable=True, comment="Progress value (0-100)" | ||
| ), | ||
| ) | ||
| op.add_column( | ||
| "projects_nodes", | ||
| sa.Column( | ||
| "thumbnail", | ||
| sa.String(), | ||
| nullable=True, | ||
| comment="Url of the latest screenshot", | ||
| ), | ||
| ) | ||
| op.add_column( | ||
| "projects_nodes", | ||
| sa.Column( | ||
| "input_access", | ||
| postgresql.JSONB(astext_type=sa.Text()), | ||
| nullable=True, | ||
| comment="Map with key - access level pairs", | ||
| ), | ||
| ) | ||
| op.add_column( | ||
| "projects_nodes", | ||
| sa.Column( | ||
| "input_nodes", | ||
| postgresql.JSONB(astext_type=sa.Text()), | ||
| nullable=True, | ||
| comment="IDs of the nodes where is connected to", | ||
| ), | ||
| ) | ||
| op.add_column( | ||
| "projects_nodes", | ||
| sa.Column( | ||
| "inputs", | ||
| postgresql.JSONB(astext_type=sa.Text()), | ||
| nullable=True, | ||
| comment="Input properties values", | ||
| ), | ||
| ) | ||
| op.add_column( | ||
| "projects_nodes", | ||
| sa.Column( | ||
| "inputs_required", | ||
| postgresql.JSONB(astext_type=sa.Text()), | ||
| nullable=True, | ||
| comment="Required input IDs", | ||
| ), | ||
| ) | ||
| op.add_column( | ||
| "projects_nodes", | ||
| sa.Column( | ||
| "inputs_units", | ||
| postgresql.JSONB(astext_type=sa.Text()), | ||
| nullable=True, | ||
| comment="Input units", | ||
| ), | ||
| ) | ||
| op.add_column( | ||
| "projects_nodes", | ||
| sa.Column( | ||
| "output_nodes", | ||
| postgresql.JSONB(astext_type=sa.Text()), | ||
| nullable=True, | ||
| comment="Node IDs of those connected to the output", | ||
| ), | ||
| ) | ||
| op.add_column( | ||
| "projects_nodes", | ||
| sa.Column( | ||
| "outputs", | ||
| postgresql.JSONB(astext_type=sa.Text()), | ||
| nullable=True, | ||
| comment="Output properties values", | ||
| ), | ||
| ) | ||
| op.add_column( | ||
| "projects_nodes", | ||
| sa.Column( | ||
| "run_hash", | ||
| sa.String(), | ||
| nullable=True, | ||
| comment="HEX digest of the resolved inputs + outputs hash at the time when the last outputs were generated", | ||
| ), | ||
| ) | ||
| op.add_column( | ||
| "projects_nodes", | ||
| sa.Column( | ||
| "state", | ||
| postgresql.JSONB(astext_type=sa.Text()), | ||
| nullable=True, | ||
| comment="State", | ||
| ), | ||
| ) | ||
| op.add_column( | ||
| "projects_nodes", | ||
| sa.Column( | ||
| "parent", | ||
| sa.String(), | ||
| nullable=True, | ||
| comment="Parent's (group-nodes) node ID", | ||
| ), | ||
| ) | ||
| op.add_column( | ||
| "projects_nodes", | ||
| sa.Column( | ||
| "boot_options", | ||
| postgresql.JSONB(astext_type=sa.Text()), | ||
| nullable=True, | ||
| comment="Some services provide alternative parameters to be injected at boot time.The user selection should be stored here, and it will overwrite the services's defaults", | ||
| ), | ||
| ) | ||
| # ### end Alembic commands ### | ||
| 
     | 
||
| op.execute( | ||
| """ | ||
| UPDATE projects_nodes | ||
| SET key = subquery.key, | ||
| version = subquery.version, | ||
| label = subquery.label, | ||
| progress = subquery.progress::numeric, | ||
| thumbnail = subquery.thumbnail, | ||
| input_access = subquery.input_access::jsonb, | ||
| input_nodes = subquery.input_nodes::jsonb, | ||
| inputs = subquery.inputs::jsonb, | ||
| inputs_required = subquery.inputs_required::jsonb, | ||
| inputs_units = subquery.inputs_units::jsonb, | ||
| output_nodes = subquery.output_nodes::jsonb, | ||
| outputs = subquery.outputs::jsonb, | ||
| run_hash = subquery.run_hash, | ||
| state = subquery.state::jsonb, | ||
| parent = subquery.parent, | ||
| boot_options = subquery.boot_options::jsonb | ||
| FROM ( | ||
| SELECT | ||
| projects.uuid AS project_id, | ||
| js.key AS node_id, | ||
| js.value::jsonb ->> 'key' AS key, | ||
| js.value::jsonb ->> 'label' AS label, | ||
| js.value::jsonb ->> 'version' AS version, | ||
| (js.value::jsonb ->> 'progress')::numeric AS progress, | ||
| js.value::jsonb ->> 'thumbnail' AS thumbnail, | ||
| js.value::jsonb ->> 'inputAccess' AS input_access, | ||
| js.value::jsonb ->> 'inputNodes' AS input_nodes, | ||
| js.value::jsonb ->> 'inputs' AS inputs, | ||
| js.value::jsonb ->> 'inputsRequired' AS inputs_required, | ||
| js.value::jsonb ->> 'inputsUnits' AS inputs_units, | ||
| js.value::jsonb ->> 'outputNodes' AS output_nodes, | ||
| js.value::jsonb ->> 'outputs' AS outputs, | ||
| js.value::jsonb ->> 'runHash' AS run_hash, | ||
| js.value::jsonb ->> 'state' AS state, | ||
| js.value::jsonb ->> 'parent' AS parent, | ||
| js.value::jsonb ->> 'bootOptions' AS boot_options | ||
| FROM projects, | ||
| json_each(projects.workbench) AS js | ||
| ) AS subquery | ||
| WHERE projects_nodes.project_uuid = subquery.project_id | ||
| AND projects_nodes.node_id = subquery.node_id; | ||
| """ | ||
| ) | ||
| op.alter_column("projects_nodes", "key", nullable=False) | ||
| op.alter_column("projects_nodes", "version", nullable=False) | ||
| op.alter_column("projects_nodes", "label", nullable=False) | ||
| 
     | 
||
| 
     | 
||
| def downgrade(): | ||
| # ### commands auto generated by Alembic - please adjust! ### | ||
| op.drop_column("projects_nodes", "boot_options") | ||
| op.drop_column("projects_nodes", "parent") | ||
| op.drop_column("projects_nodes", "state") | ||
| op.drop_column("projects_nodes", "run_hash") | ||
| op.drop_column("projects_nodes", "outputs") | ||
| op.drop_column("projects_nodes", "output_nodes") | ||
| op.drop_column("projects_nodes", "inputs_units") | ||
| op.drop_column("projects_nodes", "inputs_required") | ||
| op.drop_column("projects_nodes", "inputs") | ||
| op.drop_column("projects_nodes", "input_nodes") | ||
| op.drop_column("projects_nodes", "input_access") | ||
| op.drop_column("projects_nodes", "thumbnail") | ||
| op.drop_column("projects_nodes", "progress") | ||
| op.drop_column("projects_nodes", "label") | ||
| op.drop_column("projects_nodes", "version") | ||
| op.drop_column("projects_nodes", "key") | ||
| # ### end Alembic commands ### | 
      
      Oops, something went wrong.
        
    
  
      
      Oops, something went wrong.
        
    
  
  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.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.