This is still in the Alpha stage.
PrimeHub Job
Submit PrimeHub jobs easier
Install
pip install primehub_job
How to Use
- PrimeHub version >= 2.8
- Set the API_TOKEN environment variable
- Make sure your group have group volume
from primehub_job import submit_phjob, get_phjob_logs, get_phjob_result, wait_and_get_phjob_result
# You can write @submit_job() to use default settings.
@submit_phjob(name='submitJob', image='datascience-notebook', instance_type='cpu')
def test(a, b='b'):
print(a)
print(b)
return a, b
# Submit a job and wait the result
wait_and_get_phjob_result(test('aaa', 'ccc'))
# Submit a job
job_id = test('aaa', 'ccc')
# Get the running logs
print(get_phjob_logs(job_id))
# Get the job result
get_phjob_result(job_id)
Restrictions
- Don't use global variables in functions
- If you want to return a model, please use the framework's saver to save model, and return the saved model path to load the model. Here is the example:
# tensorflow
def export_model(model, export_path):
if os.path.isdir(export_path):
print('Cleaning up\n')
shutil.rmtree(export_path)
model.save(export_path)
return export_path
@submit_phjob()
def training(epochs=2, dropout=0.2):
mnist = tf.keras.datasets.mnist
(x_train, y_train),(x_test, y_test) = mnist.load_data()
x_train, x_test = x_train / 255.0, x_test / 255.0
model = tf.keras.models.Sequential([
tf.keras.layers.Flatten(input_shape=(28, 28)),
tf.keras.layers.Dense(512, activation=tf.nn.relu),
tf.keras.layers.Dropout(dropout),
tf.keras.layers.Dense(10, activation=tf.nn.softmax)
])
model.compile(optimizer='adam',
loss='sparse_categorical_crossentropy',
metrics=['accuracy'])
model.fit(x_train, y_train, epochs=epochs)
model.evaluate(x_test, y_test)
return export_model(model, '1')
job_id = training()
# load trained model
model = tf.keras.models.load_model(get_phjob_folder_path(job_id) + '/' + wait_and_get_phjob_result(job_id))
Run the Tests
python -m pytest
Metadata
Release files for primehub-job 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| primehub_job-0.1.3.tar.gz | 7.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| primehub_job-0.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 19.1 kB
Release files / primehub_job-0.1.3.tar.gz
| Download URL | primehub_job-0.1.3.tar.gz |
|---|---|
| Size | 7.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a966dc3d2a8e8e9c58c1f00162a6ba3e72e6f02804c8d26fa138ed22134a52ac
|
|
BLAKE2b-256 checksum How to use checksums |
93d4f72d00f62a40a3463b6dd15632bafce4f09a79d01de01d00568d86dc62cf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.5.0.1 requests/2.23.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3
|
Release files / primehub_job-0.1.3-py3-none-any.whl
| Download URL | primehub_job-0.1.3-py3-none-any.whl |
|---|---|
| Size | 11.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ae317e1ff1db3ca9871327f92aecf9ee831338b51949d4baeee7cd7e4a0f0553
|
|
BLAKE2b-256 checksum How to use checksums |
a6217a96dab55d8075e777431276b38e748dc46fcd92194ce90ed89b9c9c80c5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.5.0.1 requests/2.23.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3
|