working hepc docker test
This commit is contained in:
committed by
=Michael Hohn
parent
fadc669586
commit
96a4dcf34d
@@ -54,7 +54,7 @@ def process_db_file(zip_path, db_collection_dir):
|
||||
owner = source_location_prefix.parent.name
|
||||
cid = generate_cid(cli_version, creation_time, primary_language, sha)
|
||||
new_db_fname = f"{owner}-{repo}-ctsj-{cid}.zip"
|
||||
result_url = f"http://hepc/{db_collection_dir}/{new_db_fname}"
|
||||
result_url = f"http://hepc/db/{db_collection_dir}/{new_db_fname}"
|
||||
|
||||
metadata = {
|
||||
"git_branch" : "HEAD",
|
||||
@@ -83,19 +83,24 @@ def process_db_file(zip_path, db_collection_dir):
|
||||
rm("-rf", temp_dir)
|
||||
|
||||
# Main application class
|
||||
class DBProcessor(cli.Application):
|
||||
class HEPC(cli.Application):
|
||||
"""
|
||||
DBProcessor processes db.zip files found in a starting directory,
|
||||
HEPC processes db.zip files found in a starting directory,
|
||||
copies updated names in a collection directory,
|
||||
and adds a metadata information file "metadata.json" to the directory.
|
||||
"""
|
||||
|
||||
db_collection_dir = cli.SwitchAttr(
|
||||
"--db_collection_dir", str, mandatory=True, help="Specify the database collection directory"
|
||||
"--db_collection_dir", str, mandatory=True,
|
||||
help="Specify the database collection directory"
|
||||
)
|
||||
starting_path = cli.SwitchAttr(
|
||||
"--starting_path", str, mandatory=True, help="Specify the starting path"
|
||||
)
|
||||
max_dbs = cli.SwitchAttr(
|
||||
"--max_dbs", int, mandatory=False, default=100,
|
||||
help="Specify the maximum number of databases to ingest"
|
||||
)
|
||||
|
||||
def main(self):
|
||||
db_collection_dir = expand_path(self.db_collection_dir)
|
||||
@@ -111,10 +116,10 @@ class DBProcessor(cli.Application):
|
||||
log("WARN", "No db.zip files found in the specified starting path.")
|
||||
return
|
||||
|
||||
for zip_path in db_files:
|
||||
for zip_path in db_files[0:self.max_dbs]:
|
||||
process_db_file(zip_path, db_collection_dir)
|
||||
|
||||
log("INFO", "Processing completed.")
|
||||
|
||||
if __name__ == "__main__":
|
||||
DBProcessor.run()
|
||||
HEPC.run()
|
||||
|
||||
@@ -18,7 +18,7 @@ logger = logging.getLogger(__name__)
|
||||
app = FastAPI()
|
||||
db_dir = None # This will be set by the CLI application
|
||||
|
||||
@app.get("/{file_path:path}")
|
||||
@app.get("/db/{file_path:path}")
|
||||
def serve_file(file_path: str):
|
||||
"""
|
||||
Serve files from the database directory, such as .zip files or metadata.json.
|
||||
@@ -59,7 +59,7 @@ class MRVAHepc(cli.Application):
|
||||
2. Metadata for those zip files, contained in metadata.json in the same
|
||||
directory.
|
||||
The HTTP endpoints are:
|
||||
1. /{filename}
|
||||
1. /db/{filename}
|
||||
2. /index
|
||||
3. /api/v1/latest_results/codeql-all
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user