Skip to content

Commit

Permalink
added spack_config and spack_package data
Browse files Browse the repository at this point in the history
  • Loading branch information
utkarshgupta95 committed Jul 2, 2024
1 parent d7c5742 commit 0416a97
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 3 deletions.
20 changes: 18 additions & 2 deletions tools/release_provenance/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ class ModelBuild(Base):
spack_hash = Column(String, primary_key=True, index=True)
spec = Column(String, nullable=False)
spack_version = Column(String, ForeignKey("spack_version.commit"))
spack_package = Column(String, ForeignKey("spack_package.commit"))
spack_config = Column(String, ForeignKey("spack_config.commit"))
created_at = Column(DateTime, nullable=False)
release_url = Column(Text, nullable=False, unique=True)
component_build = relationship('ComponentBuild', secondary="model_component", back_populates='model_build')
Expand All @@ -44,12 +46,26 @@ class SpackVersion(Base):
version = Column(String, nullable=False)
model_build = relationship('ModelBuild')

class SpackConfig(Base):
__tablename__ = "spack_config"

commit = Column(String, primary_key=True, index=True)
version = Column(String, nullable=False)
model_build = relationship('ModelBuild')

class SpackPackage(Base):
__tablename__ = "spack_package"

commit = Column(String, primary_key=True, index=True)
version = Column(String, nullable=False)
model_build = relationship('ModelBuild')


model_component_association = Table(
"model_component",
Base.metadata,
Column("id", Integer, primary_key=True, autoincrement=True),
Column("model_build", ForeignKey(ModelBuild.spack_hash)),
Column("component_build", ForeignKey(ComponentBuild.spack_hash)),
Column("model_build", ForeignKey(ModelBuild.spack_hash, ondelete='CASCADE')),
Column("component_build", ForeignKey(ComponentBuild.spack_hash, ondelete='CASCADE')),
UniqueConstraint('model_build', 'component_build', name='uix_1')
)
24 changes: 24 additions & 0 deletions tools/release_provenance/save_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ def get_model_build(model_build_data):
if model_build == None:
model_build = ModelBuild()
model_build.spack_version = get_spack_version(model_build_data["spack_version"])
model_build.spack_config = get_spack_config(model_build_data["spack_config"])
model_build.spack_package = get_spack_package(model_build_data["spack_package"])
model_build.spack_hash = model_build_data["spack_hash"]
model_build.spec = model_build_data["spec"]
model_build.release_url = model_build_data["release_url"]
Expand All @@ -51,6 +53,28 @@ def get_spack_version(spack_version_data):

return spack_version.commit

def get_spack_package(spack_package_data):
spack_package = session.query(SpackPackage).get(spack_package_data["commit"])

if spack_package is None:
spack_package = SpackPackage()
spack_package.commit = spack_package_data["commit"]
spack_package.version = spack_package_data["version"]
session.add(spack_package)

return spack_package.commit

def get_spack_config(spack_config_data):
spack_config = session.query(SpackConfig).get(spack_config_data["commit"])

if spack_config is None:
spack_config = SpackConfig()
spack_config.commit = spack_config_data["commit"]
spack_config.version = spack_config_data["version"]
session.add(spack_config)

return spack_config.commit

def main():
release_data_filename = sys.argv[1]
release_data = read_release_data(release_data_filename)
Expand Down
10 changes: 9 additions & 1 deletion tools/release_provenance/test_release_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,21 @@
}
],
"model_build": {
"spack_hash": "f4f2qe5b3c22q4dtzzqs5o2iygy435rh",
"spack_hash": "f4f2qe5b3c22q4dtzzqs5o2iygy435r",
"spec": "[email protected]=2023.11.23",
"created_at": "2024/02/13 11:49:00",
"release_url": "https://github.com/ACCESS-NRI/ACCESS-OM3/releases",
"spack_version": {
"commit": "6812713cf470b473a607f0de0e8e1cf53f804fb8",
"version": "0.20.3"
},
"spack_package": {
"commit": "6812713cf470b473a607f0de0e8e1cf53f804fb8",
"version": "0.20.3"
},
"spack_config": {
"commit": "6812713cf470b473a607f0de0e8e1cf53f804fb8",
"version": "0.20.3"
}
}
}

0 comments on commit 0416a97

Please sign in to comment.