Skip to content

Commit

Permalink
update dninja
Browse files Browse the repository at this point in the history
  • Loading branch information
grokhi committed Jan 17, 2024
1 parent e58bc26 commit cbe10b0
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/main.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import json
import os
from distutils import util

Expand Down Expand Up @@ -139,6 +140,20 @@ def download_json_plus_images(api, project, dataset_ids):
save_image_meta=True,
)
sly.logger.info("Project {!r} has been successfully downloaded.".format(project.name))
sly.logger.info("Start building files...")

tf_urls_path = "/cache/released_datasets.json"
local_save_path = sly.app.get_data_dir() + "/tmp/released_datasets.json"
if api.file.exists(TEAM_ID, tf_urls_path):
api.file.download(TEAM_ID, tf_urls_path, local_save_path)
with open(local_save_path, "r") as f:
urls = json.load(f)
else:
raise FileNotFoundError(f"File not found: '{tf_urls_path}'")

build_license(urls[project.name]["markdown"]["LICENSE"], download_dir)
build_readme(urls[project.name]["markdown"]["README"], download_dir)
sly.logger.info("'LICENSE.md' and 'README.md' were successfully built.")


def download_only_json(api, project, dataset_ids):
Expand Down Expand Up @@ -182,6 +197,19 @@ def download_only_json(api, project, dataset_ids):
sly.logger.info("Total number of images: {!r}".format(total_images))


def build_license(license_content: str, download_dir: str):
license_path = os.path.join(download_dir, "LICENSE.md")
print(license_content)
with open(license_path, "w") as license_file:
license_file.write(license_content)


def build_readme(readme_content: str, download_dir: str):
readme_path = os.path.join(download_dir, "README.md")
with open(readme_path, "w") as license_file:
license_file.write(readme_content)


def main():
sly.logger.info(
"Script arguments",
Expand Down

0 comments on commit cbe10b0

Please sign in to comment.