Repository: common-workflow-language/cwl-utils

Issue:
pack command fails on complex workflow with error 'MissingTypeName'
## Steps to reproduce

### Download complex workflow

```bash
wget "https://github.com/umccr/cwl-ica/releases/download/bclconvert-with-qc-pipeline%2F4.0.3__1682577366/bclconvert-with-qc-pipeline__4.0.3__1682577366.zip"
unzip bclconvert-with-qc-pipeline__4.0.3__1682577366.zip
cd bclconvert-with-qc-pipeline__4.0.3__1682577366/
```

### Validate cwltool --pack works fine

```bash
cwltool --version
```

```
/home/alexiswl/miniforge3/envs/cwl-ica/bin/cwltool 3.1.20230302145532
```

```bash
cwltool --pack "workflow.cwl" | jq 'keys'
```

```
[
  "$graph",
  "$namespaces",
  "$schemas",
  "cwlVersion"
]
```

### Try cwltuils pack

```python
import cwl_utils
import cwl_utils.__meta__
print(cwl_utils.__meta__.__version__)
0.26

from cwl_utils.pack import pack
pack('workflow.cwl')
```

Gives 

```
Packing workflow.cwl
Parsing 1 types from /home/alexiswl/UMCCR/Projects/202305/create-bclconvert-test/bclconvert-with-qc-pipeline__4.0.3__1682577366/schemas/bclconvert-run-configuration/2.0.0--4.0.3/bclconvert-run-configuration__2.0.0--4.0.3.yaml
Parsing 1 types from /home/alexiswl/UMCCR/Projects/202305/create-bclconvert-test/bclconvert-with-qc-pipeline__4.0.3__1682577366/schemas/fastq-list-row/1.0.0/fastq-list-row__1.0.0.yaml
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/alexiswl/miniforge3/envs/cwl-ica/lib/python3.10/site-packages/cwl_utils/pack.py", line 285, in pack
    cwl = pack_process(cwl, full_url, cwl["cwlVersion"])
  File "/home/alexiswl/miniforge3/envs/cwl-ica/lib/python3.10/site-packages/cwl_utils/pack.py", line 73, in pack_process
    cwl = resolve_schemadefs(cwl, base_url, user_defined_types)
  File "/home/alexiswl/miniforge3/envs/cwl-ica/lib/python3.10/site-packages/cwl_utils/pack.py", line 177, in resolve_schemadefs
    cwl = schemadef.inline_types(cwl, "inputs", base_url, user_defined_types)
  File "/home/alexiswl/miniforge3/envs/cwl-ica/lib/python3.10/site-packages/cwl_utils/schemadef.py", line 131, in inline_types
    cwl[port] = [_inline_type(v, base_url, user_defined_types) for v in defs]
  File "/home/alexiswl/miniforge3/envs/cwl-ica/lib/python3.10/site-packages/cwl_utils/schemadef.py", line 131, in <listcomp>
    cwl[port] = [_inline_type(v, base_url, user_defined_types) for v in defs]
  File "/home/alexiswl/miniforge3/envs/cwl-ica/lib/python3.10/site-packages/cwl_utils/schemadef.py", line 230, in _inline_type
    v["type"] = _inline_type(_type, base_url, user_defined_types)
  File "/home/alexiswl/miniforge3/envs/cwl-ica/lib/python3.10/site-packages/cwl_utils/schemadef.py", line 152, in _inline_type
    "items": _inline_type(v[:-2], base_url, user_defined_types),
  File "/home/alexiswl/miniforge3/envs/cwl-ica/lib/python3.10/site-packages/cwl_utils/schemadef.py", line 188, in _inline_type
    return _inline_type(resolve_type, path_prefix, user_defined_types)
  File "/home/alexiswl/miniforge3/envs/cwl-ica/lib/python3.10/site-packages/cwl_utils/schemadef.py", line 221, in _inline_type
    v["fields"] = [
  File "/home/alexiswl/miniforge3/envs/cwl-ica/lib/python3.10/site-packages/cwl_utils/schemadef.py", line 222, in <listcomp>
    _inline_type(_f, base_url, user_defined_types) for _f in fields
  File "/home/alexiswl/miniforge3/envs/cwl-ica/lib/python3.10/site-packages/cwl_utils/schemadef.py", line 230, in _inline_type
    v["type"] = _inline_type(_type, base_url, user_defined_types)
  File "/home/alexiswl/miniforge3/envs/cwl-ica/lib/python3.10/site-packages/cwl_utils/schemadef.py", line 191, in _inline_type
    return [_inline_type(_v, base_url, user_defined_types) for _v in v]
  File "/home/alexiswl/miniforge3/envs/cwl-ica/lib/python3.10/site-packages/cwl_utils/schemadef.py", line 191, in <listcomp>
    return [_inline_type(_v, base_url, user_defined_types) for _v in v]
  File "/home/alexiswl/miniforge3/envs/cwl-ica/lib/python3.10/site-packages/cwl_utils/schemadef.py", line 196, in _inline_type
    raise errors.MissingTypeName(
cwl_utils.errors.MissingTypeName: In file /home/alexiswl/UMCCR/Projects/202305/create-bclconvert-test/bclconvert-with-qc-pipeline__4.0.3__1682577366/schemas/bclconvert-run-configuration/2.0.0--4.0.3/bclconvert-run-configuration__2.0.0--4.0.3.yaml, type None is missing type name
```


Comments:

Patch:
diff --git a/cwl_utils/utils.py b/cwl_utils/utils.py
index 435439e..1632b74 100644
--- a/cwl_utils/utils.py
+++ b/cwl_utils/utils.py
@@ -195,14 +195,9 @@ def resolved_path(
             if link == "":
                 return base_url
             else:
-                return base_url._replace(
-                    path=str(
-                        (
-                            pathlib.Path(base_url.path).parent / pathlib.Path(link)
-                        ).resolve()
-                    )
+                return urllib.parse.urlparse(
+                    urllib.parse.urljoin(base_url.geturl(), link_url.geturl())
                 )
-
         else:
             # Remote relative path
             return urllib.parse.urlparse(


Test patch:
diff --git a/tests/test_utils.py b/tests/test_utils.py
new file mode 100644
index 0000000..f4d883d
--- /dev/null
+++ b/tests/test_utils.py
@@ -0,0 +1,14 @@
+from urllib.parse import urlparse
+
+from cwl_utils.utils import resolved_path
+
+
+def test_resoled_path() -> None:
+    base_url = urlparse(
+        "schemas/bclconvert-run-configuration/2.0.0--4.0.3/bclconvert-run-configuration__2.0.0--4.0.3.yaml"
+    )
+    link = "../../../schemas/samplesheet/2.0.0--4.0.3/samplesheet__2.0.0--4.0.3.yaml#samplesheet"
+    rpath = resolved_path(base_url, link)
+    assert rpath == urlparse(
+        "schemas/samplesheet/2.0.0--4.0.3/samplesheet__2.0.0--4.0.3.yaml#samplesheet"
+    )