Skip to content

Commit eb381a3

Browse files
authored
[fead-cicd]: add-linting, formatting and check video tags (#55)
* [fead-cicd]: add-linting, formatting and check video tags * fix comments
1 parent c7aae7f commit eb381a3

73 files changed

Lines changed: 799 additions & 401 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.flake8

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[flake8]
2+
enable-extensions = G
3+
select = B,C,E,F,G,P,SIM1,T4,W,B9
4+
max-line-length = 120
5+
# C408 ignored because we like the dict keyword argument syntax
6+
# E501 is not flexible enough, we're using B950 instead
7+
ignore =
8+
E203,E305,E402,E501,E721,E741,F405,F821,F841,F999,W503,W504,C408,E302,W291,E303,E226,E265
9+
exclude =
10+
third_party

.github/workflows/lint.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
# lint.yml : A workflow to trigger lint tests on GitHub
17+
name: 'Lint'
18+
on:
19+
pull_request:
20+
workflow_dispatch:
21+
jobs:
22+
lint:
23+
name: 'Linting'
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: 'Checkout'
27+
uses: actions/checkout@v4
28+
- name: 'Setup Python'
29+
uses: actions/setup-python@v5
30+
with:
31+
python-version: 'pypy3.10'
32+
- name: 'Lint'
33+
run: |
34+
sudo apt-get update
35+
bash ./scripts/format.sh

.github/workflows/test.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
name: Test
17+
18+
on:
19+
workflow_run:
20+
workflows: ["Lint"]
21+
types:
22+
- completed
23+
24+
jobs:
25+
check-video-links:
26+
runs-on: ubuntu-latest
27+
steps:
28+
- name: 'Checkout'
29+
uses: actions/checkout@v4
30+
31+
- name: 'Setup Python'
32+
uses: actions/setup-python@v5
33+
with:
34+
python-version: 'pypy3.10'
35+
36+
- name: Install dependencies
37+
run: pip install requests
38+
39+
- name: Run Video Link Checker
40+
run: python scripts/check_video_links.py

.pre-commit-config.yaml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
default_language_version:
17+
python: python3.10
18+
repos:
19+
- repo: https://github.com/pycqa/flake8
20+
rev: 6.0.0
21+
hooks:
22+
- id: flake8
23+
args:
24+
- --max-line-length=120
25+
- --ignore=E501,F401,E203,E402,E265,E741,F841,F821,F811,W503,E231,E225,E702
26+
exclude: ^dist/|^third_party/
27+
28+
- repo: https://github.com/psf/black
29+
rev: 23.12.1
30+
hooks:
31+
- id: black
32+
args: [--line-length=120]
33+
exclude: ^dist/|^third_party/
34+
35+
- repo: https://github.com/timothycrosley/isort
36+
rev: 5.12.0
37+
hooks:
38+
- id: isort
39+
args: [--line-length=120]
40+
41+
- repo: https://github.com/MarcoGorelli/absolufy-imports
42+
rev: v0.3.1
43+
hooks:
44+
- id: absolufy-imports
45+
46+
- repo: https://github.com/pre-commit/pre-commit-hooks
47+
rev: v4.0.1
48+
hooks:
49+
- id: trailing-whitespace
50+
exclude: ^tests/.*/fixtures/.*
51+
args: [--markdown-linebreak-ext=md]
52+
- id: end-of-file-fixer
53+
exclude: ^tests/.*/fixtures/.*
54+
- id: check-added-large-files
55+
args: ['--maxkb=2000']

cosmos_transfer1/auxiliary/guardrail/aegis/aegis.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
# limitations under the License.
1515

1616
import argparse
17-
1817
import os
18+
1919
import torch
2020
from peft import PeftModel
2121
from transformers import AutoModelForCausalLM, AutoTokenizer
@@ -28,6 +28,7 @@
2828
SAFE = misc.Color.green("SAFE")
2929
UNSAFE = misc.Color.red("UNSAFE")
3030

31+
3132
class Aegis(ContentSafetyGuardrail):
3233
def __init__(
3334
self,
@@ -46,7 +47,7 @@ def __init__(
4647
base_model = AutoModelForCausalLM.from_pretrained(base_model_id, cache_dir=base_model_dir)
4748
self.tokenizer = AutoTokenizer.from_pretrained(base_model_id, cache_dir=base_model_dir)
4849
self.model = PeftModel.from_pretrained(base_model, aegis_adapter, cache_dir=aegis_adapter_dir)
49-
50+
5051
self.model.to(self.device, dtype=self.dtype).eval()
5152

5253
def get_moderation_prompt(self, user_prompt: str) -> str:

cosmos_transfer1/auxiliary/guardrail/blocklist/blocklist.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ def __init__(
3636
guardrail_partial_match_min_chars: int = 6,
3737
guardrail_partial_match_letter_count: float = 0.4,
3838
) -> None:
39-
4039
self.checkpoint_dir = os.path.join(checkpoint_dir, "nvidia/Cosmos-Guardrail1/blocklist")
4140
nltk.data.path.append(os.path.join(self.checkpoint_dir, "nltk_data"))
4241
self.lemmatizer = nltk.WordNetLemmatizer()

cosmos_transfer1/auxiliary/guardrail/face_blur_filter/face_blur_filter.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
)
3535
from cosmos_transfer1.utils import log, misc
3636

37-
3837
# RetinaFace model constants from https://github.com/biubug6/Pytorch_Retinaface/blob/master/detect.py
3938
TOP_K = 5_000
4039
KEEP_TOP_K = 750

cosmos_transfer1/auxiliary/guardrail/video_content_safety_filter/vision_encoder.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
# limitations under the License.
1515

1616
import os
17+
1718
import torch
1819
from PIL import Image
1920
from transformers import SiglipModel, SiglipProcessor

cosmos_transfer1/auxiliary/human_keypoint/human_keypoint.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,17 @@
1414
# limitations under the License.
1515

1616
import os
17+
1718
import cv2
1819
import numpy as np
1920
from rtmlib import Wholebody
2021

21-
from cosmos_transfer1.utils import log
2222
from cosmos_transfer1.diffusion.datasets.augmentors.human_keypoint_utils import (
2323
coco_wholebody_133_skeleton,
2424
openpose134_skeleton,
2525
)
26+
from cosmos_transfer1.utils import log
27+
2628

2729
class HumanKeypointModel:
2830
def __init__(self, to_openpose=True, conf_thres=0.6):
@@ -37,9 +39,9 @@ def __init__(self, to_openpose=True, conf_thres=0.6):
3739

3840
def __call__(self, input_video: str, output_video: str = "keypoint.mp4") -> str:
3941
"""
40-
Generate the human body keypoint plot for the keypointControlNet video2world model.
41-
Input: mp4 video
42-
Output: mp4 keypoint video, of the same spatial and temporal dimensions as the input video.
42+
Generate the human body keypoint plot for the keypointControlNet video2world model.
43+
Input: mp4 video
44+
Output: mp4 keypoint video, of the same spatial and temporal dimensions as the input video.
4345
"""
4446

4547
log.info(f"Processing video: {input_video} to generate keypoint video: {output_video}")

cosmos_transfer1/checkpointer/ema_fsdp_checkpointer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717

1818
import attrs
1919

20+
from cosmos_transfer1.checkpointer.fsdp_checkpointer import FSDPCheckpointer as BaseFSDPCheckpointer
2021
from cosmos_transfer1.utils import log
2122
from cosmos_transfer1.utils.config import CheckpointConfig as BaseCheckpointConfig
2223
from cosmos_transfer1.utils.ddp_config import make_freezable
23-
from cosmos_transfer1.checkpointer.fsdp_checkpointer import FSDPCheckpointer as BaseFSDPCheckpointer
2424

2525

2626
@make_freezable

0 commit comments

Comments
 (0)