Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor training job subimit. #28

Merged
merged 10 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ PAI Python SDK是阿里云 [机器学习平台 PAI(Platform for Artificial Intel

## 🔧 安装

使用以下命令安装PAI Python SDK(支持Python版本 \>= 3.6,建议使用Python版本 \>= 3.8):
使用以下命令安装PAI Python SDK(支持Python版本 \>= 3.8):

```shell
python -m pip install alipai
Expand Down
2 changes: 1 addition & 1 deletion README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ The PAI Python SDK is provided by Alibaba Cloud\'s [Platform for Artificial Inte

## Installation 🔧

Install the PAI Python SDK using the following command, which supports Python versions \>= 3.6 (it is recommended to use Python \>= 3.8):
Install the PAI Python SDK using the following command, which supports Python versions \>= 3.8 :

```shell
python -m pip install alipai
Expand Down
2 changes: 1 addition & 1 deletion docs/source/quick-tour/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
安装
------

请通过以下命令安装PAI Python SDK(请使用Python>=3.6)。
请通过以下命令安装PAI Python SDK(请使用Python>=3.8)。

.. parsed-literal::

Expand Down
7 changes: 5 additions & 2 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"PYTHONWARNINGS": "ignore",
}

UNIT_TEST_PYTHON_VERSIONS = ["3.6", "3.7", "3.8"]
UNIT_TEST_PYTHON_VERSIONS = ["3.8", "3.9", "3.10"]
INTEGRATION_TEST_PYTHON_VERSIONS = ["3.8"]
TEST_VENV_BACKEND = os.environ.get("PAI_TEST_VENV_BACKEND", "conda")

Expand Down Expand Up @@ -54,9 +54,9 @@ def integration(session: Session):
pos_args = session.posargs + ["-n", str(os.cpu_count() * 2)]
else:
pos_args = session.posargs

session.run(
"pytest",
"-vv",
"--cov-config=.coveragerc",
"--cov-append",
"--cov-report=html",
Expand All @@ -77,8 +77,10 @@ def integration(session: Session):
def unit(session: Session):
"""Run unit test."""
install_test_dependencies(session=session)
# run test cases
session.run(
"pytest",
"-vv",
"--cov-config=.coveragerc",
"--cov-append",
"--cov-report=html",
Expand Down Expand Up @@ -159,6 +161,7 @@ def notebook(session: Session):

session.run(
"pytest",
"-vv",
"--timeout",
"3000",
"--nbmake",
Expand Down
70 changes: 0 additions & 70 deletions pai/api/entity_base.py

This file was deleted.

1 change: 1 addition & 0 deletions pai/api/training_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ def create(
else:
raise ValueError("Please provide instance_type or instance_spec.")

hyperparameters = hyperparameters or dict()
hyper_parameters = [
CreateTrainingJobRequestHyperParameters(
name=name,
Expand Down
55 changes: 0 additions & 55 deletions pai/common/configs.py

This file was deleted.

41 changes: 40 additions & 1 deletion pai/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import sys
import time
import warnings
from datetime import datetime
from functools import lru_cache
from typing import Callable, Dict, List, Optional, Union

Expand Down Expand Up @@ -127,12 +128,14 @@ def http_user_agent(user_agent: Optional[Union[Dict, str]] = None) -> str:
def is_notebook() -> bool:
"""Return True if current environment is notebook."""
try:
from IPython import get_ipython

shell = get_ipython().__class__.__name__
for parent_cls in shell.__mro__:
if parent_cls.__name__ == "ZMQInteractiveShell":
return True
return False
except NameError:
except (NameError, ImportError):
return False


Expand Down Expand Up @@ -322,3 +325,39 @@ def print_table(headers: List[str], rows: List[List[str]]):
def is_package_available(package_name: str) -> bool:
"""Check if the package is available in the current environment."""
return True if importlib.util.find_spec(package_name) is not None else False


def timestamp(sep: str = "-", utc: bool = False) -> str:
"""Return a timestamp with millisecond precision.

Args:
sep: The separator between date and time.
utc: Whether to use UTC time.

Returns:
str: A timestamp with millisecond precision.

"""
if utc:
res = datetime.utcnow().strftime("%Y%m%d-%H%M%S-%f")[:-3]
else:
res = datetime.now().strftime("%Y%m%d-%H%M%S-%f")[:-3]
if sep != "-":
res = res.replace("-", sep)
return res


def name_from_base(base_name: str, sep: str = "-") -> str:
"""Return a name with base_name and timestamp.

Args:
base_name: The base name of the returned name.
sep: The separator between base_name and timestamp.

Returns:
str: A name with base_name and timestamp.

"""
return "{base_name}{sep}{timestamp}".format(
base_name=base_name, sep=sep, timestamp=timestamp(sep=sep, utc=False)
)
Loading