Skip to content

Commit 2695310

Browse files
authored
Merge branch 'deepmodeling:master' into for_pbs_torque
2 parents 37c77d0 + cc351b0 commit 2695310

25 files changed

+468
-100
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: publish_conda
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
publish:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
- name: publish-to-conda
14+
uses: felix5572/conda-publish-action@v1.9
15+
with:
16+
subdir: 'conda'
17+
anacondatoken: ${{ secrets.ANACONDA_TOKEN }}
18+
platforms: 'noarch'

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ pydispatcher.egg-info
4040
.coverage
4141
dbconfig.json
4242
.vscode/*
43+
.idea
4344
*/_version.py
4445
*/_date.py
4546
*.egg

conda/conda_build_config.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
channel_sources:
2+
- defaults
3+
- conda-forge
4+
channel_targets:
5+
- deepmodeling

conda/meta.yaml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{% set name = "dpdispatcher" %}
2+
{% set version = environ.get('GIT_DESCRIBE_TAG').lstrip('v') %}
3+
4+
package:
5+
name: {{ name|lower }}
6+
version: {{ version }}
7+
8+
source:
9+
git_url: https://github.com/deepmodeling/dpdispatcher
10+
# git_rev: {{ version }}
11+
12+
build:
13+
number: 0
14+
noarch: python
15+
script: python -m pip install --no-deps --ignore-installed .
16+
17+
requirements:
18+
build:
19+
- git
20+
host:
21+
- git
22+
- python >=3.6
23+
- pip
24+
- setuptools_scm
25+
- dargs
26+
- paramiko
27+
- requests
28+
29+
run:
30+
- python >=3.6
31+
- dargs
32+
- paramiko
33+
- requests
34+
35+
test:
36+
imports:
37+
- dpdispatcher
38+
39+
about:
40+
home: https://github.com/deepmodeling/dpdispatcher
41+
license: LGPL-3.0
42+
license_family: LGPL
43+
license_file: LICENSE
44+
doc_url: https://github.com/deepmodeling/dpdispatcher
45+
dev_url: https://github.com/deepmodeling/dpdispatcher
46+
47+
extra:
48+
recipe-maintainers:
49+
- felix5572

doc/machine-auto.rst

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,23 +57,29 @@ machine:
5757
ssh connection port.
5858

5959
key_filename:
60-
| type: ``NoneType`` | ``str``, optional, default: ``None``
60+
| type: ``str`` | ``NoneType``, optional, default: ``None``
6161
| argument path: ``machine/remote_profile/key_filename``
6262
63-
key_filename used by ssh connection
63+
key filename used by ssh connection. If left None, find key in ~/.ssh or use password for login
6464

6565
passphrase:
66-
| type: ``NoneType`` | ``str``, optional, default: ``None``
66+
| type: ``str`` | ``NoneType``, optional, default: ``None``
6767
| argument path: ``machine/remote_profile/passphrase``
6868
69-
passphrase used by ssh connection
69+
passphrase of key used by ssh connection
7070

7171
timeout:
7272
| type: ``int``, optional, default: ``10``
7373
| argument path: ``machine/remote_profile/timeout``
7474
7575
timeout of ssh connection
7676

77+
totp_secret:
78+
| type: ``str`` | ``NoneType``, optional, default: ``None``
79+
| argument path: ``machine/remote_profile/totp_secret``
80+
81+
Time-based one time password secret. It should be a base32-encoded string extracted from the 2D code.
82+
7783
clean_asynchronously:
7884
| type: ``bool``, optional, default: ``False``
7985
| argument path: ``machine/clean_asynchronously``

doc/task-auto.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ task:
2727
The files to be download to local_root in task_work_path after the task finished
2828

2929
outlog:
30-
| type: ``NoneType`` | ``str``
30+
| type: ``str`` | ``NoneType``
3131
| argument path: ``task/outlog``
3232
3333
The out log file name. redirect from stdout
3434

3535
errlog:
36-
| type: ``NoneType`` | ``str``
36+
| type: ``str`` | ``NoneType``
3737
| argument path: ``task/errlog``
3838
3939
The err log file name. redirect from stderr

dpdispatcher/__init__.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
import logging
22
import os, sys
3-
3+
import warnings
44

55
ROOT_PATH=__path__[0]
66
dlog = logging.getLogger(__name__)
7+
dlog.propagate = False
78
dlog.setLevel(logging.INFO)
8-
dlogf = logging.FileHandler(os.getcwd()+os.sep+'dpdispatcher'+'.log')
9+
try:
10+
dlogf = logging.FileHandler(os.getcwd()+os.sep+'dpdispatcher'+'.log')
11+
except PermissionError:
12+
warnings.warn(f"dpdispatcher.log meet permission error. redirect the log to ~/dpdispatcher.log")
13+
dlogf = logging.FileHandler(os.path.join(os.path.expanduser('~'),'dpdispatcher.log'))
14+
915
# dlogf = logging.FileHandler('./'+os.sep+SHORT_CMD+'.log')
1016
# dlogf = logging.FileHandler(os.path.join(os.environ['HOME'], SHORT_CMD+'.log'))
1117
# dlogf = logging.FileHandler(os.path.join(os.path.expanduser('~'), SHORT_CMD+'.log'))

dpdispatcher/dp_cloud_server.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from dpdispatcher.machine import Machine
44
from dpdispatcher.dpcloudserver import api
55
from dpdispatcher.dpcloudserver.config import ALI_OSS_BUCKET_URL
6+
import time
67

78
shell_script_header_template="""
89
#!/bin/bash -l
@@ -45,7 +46,8 @@ def do_submit(self, job):
4546
job_id = api.job_create(
4647
job_type=input_data['job_type'],
4748
oss_path=input_data['job_resources'],
48-
input_data=input_data
49+
input_data=input_data,
50+
program_id=self.context.remote_profile.get('program_id', None)
4951
)
5052

5153
job.job_id = job_id
@@ -56,10 +58,19 @@ def check_status(self, job):
5658
if job.job_id == '':
5759
return JobStatus.unsubmitted
5860
dlog.debug(f"debug: check_status; job.job_id:{job.job_id}; job.job_hash:{job.job_hash}")
61+
62+
check_return = api.get_tasks(job.job_id)
5963
try:
60-
dp_job_status = api.get_tasks(job.job_id)[0]["status"]
64+
dp_job_status = check_return[0]["status"]
6165
except IndexError as e:
62-
raise RuntimeError(f"cannot find job information in dpcloudserver's database for job {job.job_id}")
66+
dlog.error(f"cannot find job information in check_return. job {job.job_id}. check_return:{check_return}; retry one more time after 60 seconds")
67+
time.sleep(60)
68+
retry_return = api.get_tasks(job.job_id)
69+
try:
70+
dp_job_status = retry_return[0]["status"]
71+
except IndexError as e:
72+
raise RuntimeError(f"cannot find job information in dpcloudserver's database for job {job.job_id} {check_return} {retry_return}")
73+
6374
job_state = self.map_dp_job_state(dp_job_status)
6475
return job_state
6576

dpdispatcher/dp_cloud_server_context.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@ def __init__ (self,
2626
):
2727
self.temp_local_root = os.path.abspath(local_root)
2828
self.remote_profile = remote_profile
29-
username = remote_profile['username']
29+
email = remote_profile.get("email", None)
30+
username = remote_profile.get('username', None)
3031
password = remote_profile['password']
3132

32-
api.login(username=username, password=password)
33+
api.login(username=username, email=email, password=password)
3334

3435
os.makedirs(DP_CLOUD_SERVER_HOME_DIR, exist_ok=True)
3536

dpdispatcher/dpcloudserver/api.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,18 @@ def post(url, params):
4747
return ret['data']
4848

4949

50-
def login(username, password):
50+
def login(password, email=None, username=None):
5151
global token
52+
post_data = {"password": password}
53+
if email is None and username is None:
54+
raise ValueError(f"Error: can not find username or email from remote_profile")
55+
if email is not None:
56+
post_data['email'] = email
57+
if username is not None:
58+
post_data['username'] = username
5259
ret = post(
5360
'/account/login',
54-
{"username": username, "password": password}
61+
post_data
5562
)
5663
dlog.debug(f"debug: login ret:{ret}")
5764
token = ret['token']
@@ -99,14 +106,15 @@ def upload(oss_task_zip, zip_task_file, endpoint, bucket_name):
99106
return result
100107

101108

102-
def job_create(job_type, oss_path, input_data):
103-
ret = post(
104-
'/data/insert_job',
105-
{
109+
def job_create(job_type, oss_path, input_data, program_id=None):
110+
post_data = {
106111
'job_type': job_type,
107112
'oss_path': oss_path,
108113
'input_data': input_data,
109-
})
114+
}
115+
if program_id is not None:
116+
post_data["program_id"] = program_id
117+
ret = post('/data/insert_job', post_data)
110118
return ret['job_id']
111119

112120

0 commit comments

Comments
 (0)