Skip to content
This repository has been archived by the owner on May 31, 2024. It is now read-only.

Commit

Permalink
fix: cleaning some error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
mosoriob committed Apr 27, 2021
1 parent e29ce4c commit caa3845
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 13 deletions.
6 changes: 2 additions & 4 deletions src/mic/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,7 @@ def init_logger():
logger.removeHandler(i)

logger.addHandler(handler)
logger.setLevel(logging.DEBUG)

logger.setLevel(logging.WARNING)

def get_latest_version():
try:
Expand Down Expand Up @@ -205,10 +204,9 @@ def upload_code(upload_file: Path):
user = "upload"
password = "HVmyqAPWDNuk5SmkLOK2"
header = {'Content-Type': 'application/binary'}

try:
with open(upload_file, 'rb') as f:
r = requests.put(url, headers=header, data=f, verify=False, auth=HTTPBasicAuth(user, password))
r = requests.put(url, headers=header, data=f, verify=True, auth=HTTPBasicAuth(user, password))
r.raise_for_status()
return r
except requests.exceptions.Timeout:
Expand Down
3 changes: 1 addition & 2 deletions src/mic/commands_notebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ def upload_configuration(cwl_document, cwl_values, profile):
inputs = get_inputs(cwl_document_dict)
#outputs = get_outputs(cwl_document_dict)
parameters = get_parameters(cwl_document_dict)
print(parameters)
# write then on MIC file
add_inputs(mic_config_path, inputs, cwl_values_dict)
#add_outputs(mic_config_path, outputs, cwl_values)
Expand All @@ -182,7 +181,7 @@ def upload_configuration(cwl_document, cwl_values, profile):
#obtain cwl command
write_spec(mic_config_path, CWL_KEY, cwl_document_path)
# Message publish start
info_start_publish(True)
#info_start_publish(True)
# push the component
model_configuration = create_model_catalog_resource_cwl(
Path(mic_config_path),
Expand Down
2 changes: 0 additions & 2 deletions src/mic/cwl/cwl.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ def supported(cwl_spec):
def add_parameters(config_yaml_path: Path, cwl_spec: Dict, values: Dict):
spec = yaml.load(config_yaml_path.open(), Loader=yaml.Loader)
spec[PARAMETERS_KEY] = {}
print(cwl_spec)
print(values)
for key, item in cwl_spec.items():
name = key
value = values[key]
Expand Down
7 changes: 2 additions & 5 deletions src/mic/publisher/model_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
from mic.resources.software_version import SoftwareVersionCli
from modelcatalog import DatasetSpecification, ModelConfiguration, SoftwareImage, Parameter, Model, SoftwareVersion, \
DataTransformation
import requests

def generate_uuid():
return "https://w3id.org/okn/i/mint/{}".format(str(uuid.uuid4()))
Expand All @@ -31,8 +30,8 @@ def create_model_catalog_resource_cwl(mint_config_file, name=None, execution_dir
if code is None:
click.secho("Failed to upload. Missing information zip file", fg="red")
else:
url = upload_code(Path(code))

response = upload_code(Path(code))
url = response.text
model_catalog_inputs = create_data_set_resource(allow_local_path, inputs,
execution_dir) if inputs else None
model_catalog_outputs = create_data_set_resource(False, outputs,
Expand Down Expand Up @@ -93,8 +92,6 @@ def create_parameter_resource(parameters):
for key, item in parameters.items():
data_type = "string"
if "type" in item and item["type"] != '' and item["type"] is not None:
print(item)
print(item["type"])
data_type = MAP_PYTHON_MODEL_CATALOG[item["type"]]
_parameter = Parameter(id=generate_uuid(), label=[key], position=[position], type=[TYPE_PARAMETER], has_data_type=[data_type])
_parameter.has_default_value = [item["default_value"]]
Expand Down
18 changes: 18 additions & 0 deletions src/mic/tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from mic._utils import upload_code, download
from pathlib import Path
from filecmp import cmp

RESOURCES = "resources"

def test_upload_code(tmp_path):
file_name = "mic_full.yaml"
file_test = Path(__file__).parent / RESOURCES / file_name
response = upload_code(file_test)
assert response.status_code == 200
url = response.text
response_get = download(url)
assert response_get.status_code == 200
file_test_downloaded = tmp_path / file_name
with open(file_test_downloaded, 'wb') as f:
f.write(response_get.content)
assert cmp(file_test, file_test_downloaded)

0 comments on commit caa3845

Please sign in to comment.