Merge pull request #72546 from ClickHouse/test-local-module

Improve praktika imports
This commit is contained in:
Mikhail f. Shiryaev 2024-11-27 17:45:07 +00:00 committed by GitHub
commit ed1f326d56
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
28 changed files with 116 additions and 109 deletions

View File

@ -3,3 +3,5 @@ from .docker import Docker
from .job import Job from .job import Job
from .secret import Secret from .secret import Secret
from .workflow import Workflow from .workflow import Workflow
__all__ = ["Artifact", "Docker", "Job", "Secret", "Workflow"]

View File

@ -1,10 +1,10 @@
import argparse import argparse
import sys import sys
from praktika.html_prepare import Html from .html_prepare import Html
from praktika.utils import Utils from .utils import Utils
from praktika.validator import Validator from .validator import Validator
from praktika.yaml_generator import YamlGenerator from .yaml_generator import YamlGenerator
def create_parser(): def create_parser():
@ -86,8 +86,8 @@ def main():
elif args.command == "html": elif args.command == "html":
Html.prepare() Html.prepare()
elif args.command == "run": elif args.command == "run":
from praktika.mangle import _get_workflows from .mangle import _get_workflows
from praktika.runner import Runner from .runner import Runner
workflows = _get_workflows(name=args.workflow or None) workflows = _get_workflows(name=args.workflow or None)
job_workflow_pairs = [] job_workflow_pairs = []

View File

@ -5,9 +5,9 @@ from pathlib import Path
from types import SimpleNamespace from types import SimpleNamespace
from typing import Any, Dict, List, Type from typing import Any, Dict, List, Type
from praktika import Workflow from . import Workflow
from praktika.settings import Settings from .settings import Settings
from praktika.utils import MetaClasses, T from .utils import MetaClasses, T
@dataclasses.dataclass @dataclasses.dataclass

View File

@ -2,12 +2,12 @@ import dataclasses
import json import json
from pathlib import Path from pathlib import Path
from praktika import Artifact, Job, Workflow from . import Artifact, Job, Workflow
from praktika._environment import _Environment from ._environment import _Environment
from praktika.digest import Digest from .digest import Digest
from praktika.s3 import S3 from .s3 import S3
from praktika.settings import Settings from .settings import Settings
from praktika.utils import Utils from .utils import Utils
class Cache: class Cache:

View File

@ -4,10 +4,11 @@ import json
from typing import Optional from typing import Optional
import requests import requests
from praktika._environment import _Environment
from praktika.result import Result from ._environment import _Environment
from praktika.settings import Settings from .result import Result
from praktika.utils import Utils from .settings import Settings
from .utils import Utils
class CIDB: class CIDB:

View File

@ -5,10 +5,10 @@ from hashlib import md5
from pathlib import Path from pathlib import Path
from typing import List from typing import List
from praktika import Job from . import Job
from praktika.docker import Docker from .docker import Docker
from praktika.settings import Settings from .settings import Settings
from praktika.utils import Utils from .utils import Utils
class Digest: class Digest:

View File

@ -1,7 +1,7 @@
import dataclasses import dataclasses
from typing import List from typing import List
from praktika.utils import Shell from .utils import Shell
class Docker: class Docker:

View File

@ -0,0 +1 @@
#!/usr/bin/env python

View File

@ -1,4 +1,4 @@
from praktika.execution.machine_init import run from .machine_init import run
if __name__ == "__main__": if __name__ == "__main__":
run() run()

View File

@ -1,6 +1,6 @@
import os import os
from praktika.utils import MetaClasses from ..utils import MetaClasses
class ScalingType(metaclass=MetaClasses.WithIter): class ScalingType(metaclass=MetaClasses.WithIter):

View File

@ -5,8 +5,9 @@ import time
import traceback import traceback
import requests import requests
from praktika.execution.execution_settings import ExecutionSettings, ScalingType
from praktika.utils import ContextManager, Shell from ..utils import ContextManager, Shell
from .execution_settings import ExecutionSettings, ScalingType
class StateMachine: class StateMachine:

View File

@ -1,10 +1,10 @@
import json import json
import time import time
from praktika._environment import _Environment from ._environment import _Environment
from praktika.result import Result from .result import Result
from praktika.settings import Settings from .settings import Settings
from praktika.utils import Shell from .utils import Shell
class GH: class GH:

View File

@ -4,12 +4,14 @@ from typing import List
import requests import requests
from jwt import JWT, jwk_from_pem from jwt import JWT, jwk_from_pem
from praktika import Workflow
from praktika.mangle import _get_workflows from . import Workflow
from praktika.settings import Settings from .mangle import _get_workflows
from praktika.utils import Shell from .settings import Settings
from .utils import Shell
# XXX: dead code with a bug in return installations[0]["id"] and using legacy jwt module
class GHAuth: class GHAuth:
@staticmethod @staticmethod
def _generate_jwt(client_id, pem): def _generate_jwt(client_id, pem):

View File

@ -1,8 +1,8 @@
from praktika._environment import _Environment from ._environment import _Environment
from praktika.cache import Cache from .cache import Cache
from praktika.runtime import RunConfig from .runtime import RunConfig
from praktika.settings import Settings from .settings import Settings
from praktika.utils import Utils from .utils import Utils
class CacheRunnerHooks: class CacheRunnerHooks:

View File

@ -3,14 +3,14 @@ import json
from pathlib import Path from pathlib import Path
from typing import List from typing import List
from praktika._environment import _Environment from ._environment import _Environment
from praktika.gh import GH from .gh import GH
from praktika.parser import WorkflowConfigParser from .parser import WorkflowConfigParser
from praktika.result import Result, ResultInfo, _ResultS3 from .result import Result, ResultInfo, _ResultS3
from praktika.runtime import RunConfig from .runtime import RunConfig
from praktika.s3 import S3 from .s3 import S3
from praktika.settings import Settings from .settings import Settings
from praktika.utils import Utils from .utils import Utils
@dataclasses.dataclass @dataclasses.dataclass

View File

@ -1,6 +1,6 @@
from abc import ABC, abstractmethod from abc import ABC, abstractmethod
from praktika import Workflow from . import Workflow
class HookInterface(ABC): class HookInterface(ABC):

View File

@ -1,5 +1,5 @@
from praktika.s3 import S3 from .s3 import S3
from praktika.settings import Settings from .settings import Settings
class Html: class Html:

View File

@ -2,9 +2,9 @@ import copy
import importlib.util import importlib.util
from pathlib import Path from pathlib import Path
from praktika import Job from . import Job
from praktika.settings import Settings from .settings import Settings
from praktika.utils import Utils from .utils import Utils
def _get_workflows(name=None, file=None): def _get_workflows(name=None, file=None):
@ -63,7 +63,7 @@ def _update_workflow_artifacts(workflow):
def _update_workflow_with_native_jobs(workflow): def _update_workflow_with_native_jobs(workflow):
if workflow.dockers: if workflow.dockers:
from praktika.native_jobs import _docker_build_job from .native_jobs import _docker_build_job
print(f"Enable native job [{_docker_build_job.name}] for [{workflow.name}]") print(f"Enable native job [{_docker_build_job.name}] for [{workflow.name}]")
aux_job = copy.deepcopy(_docker_build_job) aux_job = copy.deepcopy(_docker_build_job)
@ -85,7 +85,7 @@ def _update_workflow_with_native_jobs(workflow):
or workflow.enable_report or workflow.enable_report
or workflow.enable_merge_ready_status or workflow.enable_merge_ready_status
): ):
from praktika.native_jobs import _workflow_config_job from .native_jobs import _workflow_config_job
print(f"Enable native job [{_workflow_config_job.name}] for [{workflow.name}]") print(f"Enable native job [{_workflow_config_job.name}] for [{workflow.name}]")
aux_job = copy.deepcopy(_workflow_config_job) aux_job = copy.deepcopy(_workflow_config_job)
@ -96,7 +96,7 @@ def _update_workflow_with_native_jobs(workflow):
job.requires.append(aux_job.name) job.requires.append(aux_job.name)
if workflow.enable_merge_ready_status: if workflow.enable_merge_ready_status:
from praktika.native_jobs import _final_job from .native_jobs import _final_job
print(f"Enable native job [{_final_job.name}] for [{workflow.name}]") print(f"Enable native job [{_final_job.name}] for [{workflow.name}]")
aux_job = copy.deepcopy(_final_job) aux_job = copy.deepcopy(_final_job)

View File

@ -1,19 +1,19 @@
import sys import sys
from typing import Dict from typing import Dict
from praktika import Job, Workflow from . import Job, Workflow
from praktika._environment import _Environment from ._environment import _Environment
from praktika.cidb import CIDB from .cidb import CIDB
from praktika.digest import Digest from .digest import Digest
from praktika.docker import Docker from .docker import Docker
from praktika.gh import GH from .gh import GH
from praktika.hook_cache import CacheRunnerHooks from .hook_cache import CacheRunnerHooks
from praktika.hook_html import HtmlRunnerHooks from .hook_html import HtmlRunnerHooks
from praktika.mangle import _get_workflows from .mangle import _get_workflows
from praktika.result import Result, ResultInfo, _ResultS3 from .result import Result, ResultInfo, _ResultS3
from praktika.runtime import RunConfig from .runtime import RunConfig
from praktika.settings import Settings from .settings import Settings
from praktika.utils import Shell, Utils from .utils import Shell, Utils
assert Settings.CI_CONFIG_RUNS_ON assert Settings.CI_CONFIG_RUNS_ON

View File

@ -1,8 +1,8 @@
import dataclasses import dataclasses
from typing import Any, Dict, List from typing import Any, Dict, List
from praktika import Artifact, Workflow from . import Artifact, Workflow
from praktika.mangle import _get_workflows from .mangle import _get_workflows
class AddonType: class AddonType:

View File

@ -5,11 +5,11 @@ import sys
from pathlib import Path from pathlib import Path
from typing import Any, Dict, List, Optional, Union from typing import Any, Dict, List, Optional, Union
from praktika._environment import _Environment from ._environment import _Environment
from praktika.cache import Cache from .cache import Cache
from praktika.s3 import S3 from .s3 import S3
from praktika.settings import Settings from .settings import Settings
from praktika.utils import ContextManager, MetaClasses, Shell, Utils from .utils import ContextManager, MetaClasses, Shell, Utils
@dataclasses.dataclass @dataclasses.dataclass

View File

@ -6,17 +6,17 @@ import sys
import traceback import traceback
from pathlib import Path from pathlib import Path
from praktika._environment import _Environment from ._environment import _Environment
from praktika.artifact import Artifact from .artifact import Artifact
from praktika.cidb import CIDB from .cidb import CIDB
from praktika.digest import Digest from .digest import Digest
from praktika.hook_cache import CacheRunnerHooks from .hook_cache import CacheRunnerHooks
from praktika.hook_html import HtmlRunnerHooks from .hook_html import HtmlRunnerHooks
from praktika.result import Result, ResultInfo from .result import Result, ResultInfo
from praktika.runtime import RunConfig from .runtime import RunConfig
from praktika.s3 import S3 from .s3 import S3
from praktika.settings import Settings from .settings import Settings
from praktika.utils import Shell, TeePopen, Utils from .utils import Shell, TeePopen, Utils
class Runner: class Runner:

View File

@ -1,9 +1,9 @@
from dataclasses import dataclass from dataclasses import dataclass
from typing import Dict, List from typing import Dict, List
from praktika.cache import Cache from .cache import Cache
from praktika.settings import Settings from .settings import Settings
from praktika.utils import MetaClasses, Utils from .utils import MetaClasses, Utils
@dataclass @dataclass

View File

@ -4,9 +4,9 @@ from pathlib import Path
from typing import Dict from typing import Dict
from urllib.parse import quote from urllib.parse import quote
from praktika._environment import _Environment from ._environment import _Environment
from praktika.settings import Settings from .settings import Settings
from praktika.utils import Shell from .utils import Shell
class S3: class S3:

View File

@ -1,7 +1,7 @@
import dataclasses import dataclasses
import os import os
from praktika.utils import Shell from .utils import Shell
class Secret: class Secret:

View File

@ -3,9 +3,9 @@ import sys
from itertools import chain from itertools import chain
from pathlib import Path from pathlib import Path
from praktika import Workflow from . import Workflow
from praktika.mangle import _get_workflows from .mangle import _get_workflows
from praktika.settings import GHRunners, Settings from .settings import GHRunners, Settings
class Validator: class Validator:

View File

@ -1,10 +1,10 @@
from dataclasses import dataclass, field from dataclasses import dataclass, field
from typing import List, Optional from typing import List, Optional
from praktika import Artifact, Job from . import Artifact, Job
from praktika.docker import Docker from .docker import Docker
from praktika.secret import Secret from .secret import Secret
from praktika.utils import Utils from .utils import Utils
class Workflow: class Workflow:

View File

@ -1,12 +1,12 @@
import dataclasses import dataclasses
from typing import List from typing import List
from praktika import Artifact, Job, Workflow from . import Artifact, Job, Workflow
from praktika.mangle import _get_workflows from .mangle import _get_workflows
from praktika.parser import WorkflowConfigParser from .parser import WorkflowConfigParser
from praktika.runtime import RunConfig from .runtime import RunConfig
from praktika.settings import Settings from .settings import Settings
from praktika.utils import ContextManager, Shell, Utils from .utils import Shell, Utils
class YamlGenerator: class YamlGenerator: