Skip to content

Commit

Permalink
refactor!: make deeplink_ext a conventional python package (#36)
Browse files Browse the repository at this point in the history
* refactor!: make deeplink_ext a conventional python package

plus offering a patching mechanism to patch InternLM and lightllm

* add format CI

* use a more complete .gitignore

* handle patch failure -> fallback & add Copyright

* fix cpp format action

* make print thread-safe

* feat: add diopi error code and message to exception

* fix(internlm): raise NotImplementedError for rotary_emb, instead of
using wrong patch

* fix(lightllm): patch_lightllm did nothing due to indentation error
  • Loading branch information
lljbash authored Jan 25, 2024
1 parent 7ef9c24 commit 1a9fc6d
Show file tree
Hide file tree
Showing 41 changed files with 1,063 additions and 946 deletions.
308 changes: 37 additions & 271 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,275 +1,41 @@
---
Language: Cpp
BasedOnStyle: Google
# AccessModifierOffset: -1
# AlignAfterOpenBracket: Align
# AlignArrayOfStructures: None
# AlignConsecutiveAssignments:
# Enabled: false
# AcrossEmptyLines: false
# AcrossComments: false
# AlignCompound: false
# PadOperators: true
# AlignConsecutiveBitFields:
# Enabled: false
# AcrossEmptyLines: false
# AcrossComments: false
# AlignCompound: false
# PadOperators: false
# AlignConsecutiveDeclarations:
# Enabled: false
# AcrossEmptyLines: false
# AcrossComments: false
# AlignCompound: false
# PadOperators: false
# AlignConsecutiveMacros:
# Enabled: false
# AcrossEmptyLines: false
# AcrossComments: false
# AlignCompound: false
# PadOperators: false
# AlignEscapedNewlines: Left
# AlignOperands: Align
# AlignTrailingComments:
# Kind: Always
# OverEmptyLines: 0
# AllowAllArgumentsOnNextLine: true
# AllowAllParametersOfDeclarationOnNextLine: true
# AllowShortBlocksOnASingleLine: Never
# AllowShortCaseLabelsOnASingleLine: false
# AllowShortEnumsOnASingleLine: true
# AllowShortFunctionsOnASingleLine: All
# AllowShortIfStatementsOnASingleLine: WithoutElse
# AllowShortLambdasOnASingleLine: All
# AllowShortLoopsOnASingleLine: true
# AlwaysBreakAfterDefinitionReturnType: None
# AlwaysBreakAfterReturnType: None
# AlwaysBreakBeforeMultilineStrings: true
# AlwaysBreakTemplateDeclarations: Yes
# AttributeMacros:
# - __capability
# BinPackArguments: true
# BinPackParameters: true
# BitFieldColonSpacing: Both
# BraceWrapping:
# AfterCaseLabel: false
# AfterClass: false
# AfterControlStatement: Never
# AfterEnum: false
# AfterExternBlock: false
# AfterFunction: false
# AfterNamespace: false
# AfterObjCDeclaration: false
# AfterStruct: false
# AfterUnion: false
# BeforeCatch: false
# BeforeElse: false
# BeforeLambdaBody: false
# BeforeWhile: false
# IndentBraces: false
# SplitEmptyFunction: true
# SplitEmptyRecord: true
# SplitEmptyNamespace: true
# BreakAfterAttributes: Never
# BreakAfterJavaFieldAnnotations: false
# BreakArrays: true
# BreakBeforeBinaryOperators: None
# BreakBeforeConceptDeclarations: Always
# BreakBeforeBraces: Attach
# BreakBeforeInlineASMColon: OnlyMultiline
# BreakBeforeTernaryOperators: true
# BreakConstructorInitializers: BeforeColon
# BreakInheritanceList: BeforeColon
# BreakStringLiterals: true
# ColumnLimit: 80
# CommentPragmas: '^ IWYU pragma:'
# CompactNamespaces: false
# ConstructorInitializerIndentWidth: 4
# ContinuationIndentWidth: 4
# Cpp11BracedListStyle: true
# DerivePointerAlignment: true
# DisableFormat: false
# EmptyLineAfterAccessModifier: Never
# EmptyLineBeforeAccessModifier: LogicalBlock
# ExperimentalAutoDetectBinPacking: false
# FixNamespaceComments: true
# ForEachMacros:
# - foreach
# - Q_FOREACH
# - BOOST_FOREACH
# IfMacros:
# - KJ_IF_MAYBE
# IncludeBlocks: Regroup
BreakAfterAttributes: Leave
CommentPragmas: '^ (IWYU pragma:|NOLINT(BEGIN|END|NEXTLINE)?(\(.+\))?:? )'
DerivePointerAlignment: false
InsertNewlineAtEOF: true
IncludeCategories:
- Regex: '^("|<)csrc_dipu/.*'
Priority: 9
SortPriority: 0
CaseSensitive: false
- Regex: '^("|<)diopi/.*'
Priority: 8
SortPriority: 0
CaseSensitive: false
- Regex: '^("|<)(c10|aten|torch).*'
Priority: 4
SortPriority: 0
CaseSensitive: false
- Regex: '^("|<)(pybind11|Python\.h).*'
Priority: 5
SortPriority: 0
CaseSensitive: false
- Regex: '^<((ext/.*)|pthread)\.h.*'
Priority: 2
SortPriority: 1
CaseSensitive: false
- Regex: '^("|<)(cuda|su|cn|(..?ccl)|(.*_runtime)).*\.h.*'
Priority: 3
SortPriority: 0
CaseSensitive: false
- Regex: '^<.*'
Priority: 2
SortPriority: 0
CaseSensitive: false
- Regex: '.*'
Priority: 10
SortPriority: 0
CaseSensitive: false
# IncludeIsMainRegex: '([-_](test|unittest))?$'
# IncludeIsMainSourceRegex: ''
# IndentAccessModifiers: false
# IndentCaseBlocks: false
# IndentCaseLabels: true
# IndentExternBlock: AfterExternBlock
# IndentGotoLabels: true
# IndentPPDirectives: None
# IndentRequiresClause: true
# IndentWidth: 2
# IndentWrappedFunctionNames: false
# InsertBraces: false
# InsertNewlineAtEOF: false
# InsertTrailingCommas: None
# IntegerLiteralSeparator:
# Binary: 0
# BinaryMinDigits: 0
# Decimal: 0
# DecimalMinDigits: 0
# Hex: 0
# HexMinDigits: 0
# JavaScriptQuotes: Leave
# JavaScriptWrapImports: true
# KeepEmptyLinesAtTheStartOfBlocks: false
# LambdaBodyIndentation: Signature
# LineEnding: DeriveLF
# MacroBlockBegin: ''
# MacroBlockEnd: ''
# MaxEmptyLinesToKeep: 1
# NamespaceIndentation: None
# ObjCBinPackProtocolList: Never
# ObjCBlockIndentWidth: 2
# ObjCBreakBeforeNestedBlockParam: true
# ObjCSpaceAfterProperty: false
# ObjCSpaceBeforeProtocolList: true
# PackConstructorInitializers: NextLine
# PenaltyBreakAssignment: 2
# PenaltyBreakBeforeFirstCallParameter: 1
# PenaltyBreakComment: 300
# PenaltyBreakFirstLessLess: 120
# PenaltyBreakOpenParenthesis: 0
# PenaltyBreakString: 1000
# PenaltyBreakTemplateDeclaration: 10
# PenaltyExcessCharacter: 1000000
# PenaltyIndentedWhitespace: 0
# PenaltyReturnTypeOnItsOwnLine: 200
# PointerAlignment: Left
# PPIndentWidth: -1
# QualifierAlignment: Leave
# RawStringFormats:
# - Language: Cpp
# Delimiters:
# - cc
# - CC
# - cpp
# - Cpp
# - CPP
# - 'c++'
# - 'C++'
# CanonicalDelimiter: ''
# BasedOnStyle: google
# - Language: TextProto
# Delimiters:
# - pb
# - PB
# - proto
# - PROTO
# EnclosingFunctions:
# - EqualsProto
# - EquivToProto
# - PARSE_PARTIAL_TEXT_PROTO
# - PARSE_TEST_PROTO
# - PARSE_TEXT_PROTO
# - ParseTextOrDie
# - ParseTextProtoOrDie
# - ParseTestProto
# - ParsePartialTestProto
# CanonicalDelimiter: pb
# BasedOnStyle: google
# ReferenceAlignment: Pointer
# ReflowComments: true
# RemoveBracesLLVM: false
# RemoveSemicolon: false
# RequiresClausePosition: OwnLine
# RequiresExpressionIndentation: OuterScope
# SeparateDefinitionBlocks: Leave
# ShortNamespaceLines: 1
# SortIncludes: CaseSensitive
# SortJavaStaticImport: Before
# SortUsingDeclarations: LexicographicNumeric
# SpaceAfterCStyleCast: false
# SpaceAfterLogicalNot: false
# SpaceAfterTemplateKeyword: true
# SpaceAroundPointerQualifiers: Default
# SpaceBeforeAssignmentOperators: true
# SpaceBeforeCaseColon: false
# SpaceBeforeCpp11BracedList: false
# SpaceBeforeCtorInitializerColon: true
# SpaceBeforeInheritanceColon: true
# SpaceBeforeParens: ControlStatements
# SpaceBeforeParensOptions:
# AfterControlStatements: true
# AfterForeachMacros: true
# AfterFunctionDefinitionName: false
# AfterFunctionDeclarationName: false
# AfterIfMacros: true
# AfterOverloadedOperator: false
# AfterRequiresInClause: false
# AfterRequiresInExpression: false
# BeforeNonEmptyParentheses: false
# SpaceBeforeRangeBasedForLoopColon: true
# SpaceBeforeSquareBrackets: false
# SpaceInEmptyBlock: false
# SpaceInEmptyParentheses: false
# SpacesBeforeTrailingComments: 2
# SpacesInAngles: Never
# SpacesInConditionalStatement: false
# SpacesInContainerLiterals: true
# SpacesInCStyleCastParentheses: false
# SpacesInLineCommentPrefix:
# Minimum: 1
# Maximum: -1
# SpacesInParentheses: false
# SpacesInSquareBrackets: false
# Standard: Auto
# StatementAttributeLikeMacros:
# - Q_EMIT
# StatementMacros:
# - Q_UNUSED
# - QT_REQUIRE_VERSION
# TabWidth: 8
# UseTab: Never
# WhitespaceSensitiveMacros:
# - BOOST_PP_STRINGIZE
# - CF_SWIFT_NAME
# - NS_SWIFT_NAME
# - PP_STRINGIZE
# - STRINGIZE
...

- Regex: '^("|<)csrc_dipu/'
Priority: 90
CaseSensitive: false
- Regex: '^("|<)diopi/'
Priority: 80
CaseSensitive: false
- Regex: '^("|<)(c10|aten|torch)/'
Priority: 40
CaseSensitive: false
- Regex: '^("|<)Python\.h'
Priority: 50
CaseSensitive: false
- Regex: '^("|<)(frameobject|structmember)\.h'
Priority: 50
SortPriority: 51
CaseSensitive: false
- Regex: '^("|<)(pybind11)'
Priority: 50
SortPriority: 52
CaseSensitive: false
- Regex: '^<((ext/.*)|pthread)\.h'
Priority: 20
SortPriority: 21
CaseSensitive: false
- Regex: '^("|<)(cuda|su|cn|(..?ccl)|(.*_runtime)).*\.h'
Priority: 30
CaseSensitive: false
- Regex: '^<.*'
Priority: 20
CaseSensitive: false
- Regex: '.*'
Priority: 100
CaseSensitive: false
32 changes: 32 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: format

on:
workflow_dispatch:
pull_request:
push:
branches:
- main

jobs:
clang-format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: cpp-linter/cpp-linter-action@v2
id: cpp-lint
with:
style: file
tidy-checks: '-*' # disable clang tidy at this stage
version: 17
files-changed-only: false
- name: Fail test
if: steps.cpp-lint.outputs.checks-failed > 0
run: echo "Some files failed the linting checks!" && exit 1

python-black:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: psf/black@stable
with: # see: https://black.readthedocs.io/en/stable/getting_started.html
version: "~= 23.11.0"
Loading

0 comments on commit 1a9fc6d

Please sign in to comment.