hexsha stringlengths 40 40 | repo stringlengths 7 114 | path stringlengths 4 124 | license listlengths 1 9 | language stringclasses 1
value | identifier stringlengths 1 71 | return_type stringlengths 1 749 ⌀ | original_string stringlengths 76 22.7k | original_docstring stringlengths 16 7.61k | docstring stringlengths 16 2.47k | docstring_tokens listlengths 6 477 | code stringlengths 14 10.2k | code_tokens listlengths 6 996 | short_docstring stringlengths 2 644 | short_docstring_tokens listlengths 1 116 | comment listlengths 1 89 | parameters listlengths 0 64 | docstring_params dict |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
8d46885a20f967bc0e3c0c331cd56fc3c5932d64 | cuisongliu/quay | data/registry_model/interface.py | [
"Apache-2.0"
] | Python | reset_security_status | null | def reset_security_status(self, manifest_or_legacy_image):
"""
Resets the security status for the given manifest or legacy image, ensuring that it will get
re-indexed.
""" |
Resets the security status for the given manifest or legacy image, ensuring that it will get
re-indexed.
| Resets the security status for the given manifest or legacy image, ensuring that it will get
re-indexed. | [
"Resets",
"the",
"security",
"status",
"for",
"the",
"given",
"manifest",
"or",
"legacy",
"image",
"ensuring",
"that",
"it",
"will",
"get",
"re",
"-",
"indexed",
"."
] | def reset_security_status(self, manifest_or_legacy_image): | [
"def",
"reset_security_status",
"(",
"self",
",",
"manifest_or_legacy_image",
")",
":"
] | Resets the security status for the given manifest or legacy image, ensuring that it will get
re-indexed. | [
"Resets",
"the",
"security",
"status",
"for",
"the",
"given",
"manifest",
"or",
"legacy",
"image",
"ensuring",
"that",
"it",
"will",
"get",
"re",
"-",
"indexed",
"."
] | [
"\"\"\"\n Resets the security status for the given manifest or legacy image, ensuring that it will get\n re-indexed.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "manifest_or_legacy_image",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "manifest_or_legacy_image",
"type": null,
"docstring": null,
"... |
8d46885a20f967bc0e3c0c331cd56fc3c5932d64 | cuisongliu/quay | data/registry_model/interface.py | [
"Apache-2.0"
] | Python | backfill_manifest_for_tag | null | def backfill_manifest_for_tag(self, tag):
"""
Backfills a manifest for the V1 tag specified. If a manifest already exists for the tag,
returns that manifest.
NOTE: This method will only be necessary until we've completed the backfill, at which point
it should be removed.
... |
Backfills a manifest for the V1 tag specified. If a manifest already exists for the tag,
returns that manifest.
NOTE: This method will only be necessary until we've completed the backfill, at which point
it should be removed.
| Backfills a manifest for the V1 tag specified. If a manifest already exists for the tag,
returns that manifest.
This method will only be necessary until we've completed the backfill, at which point
it should be removed. | [
"Backfills",
"a",
"manifest",
"for",
"the",
"V1",
"tag",
"specified",
".",
"If",
"a",
"manifest",
"already",
"exists",
"for",
"the",
"tag",
"returns",
"that",
"manifest",
".",
"This",
"method",
"will",
"only",
"be",
"necessary",
"until",
"we",
"'",
"ve",
... | def backfill_manifest_for_tag(self, tag): | [
"def",
"backfill_manifest_for_tag",
"(",
"self",
",",
"tag",
")",
":"
] | Backfills a manifest for the V1 tag specified. | [
"Backfills",
"a",
"manifest",
"for",
"the",
"V1",
"tag",
"specified",
"."
] | [
"\"\"\"\n Backfills a manifest for the V1 tag specified. If a manifest already exists for the tag,\n returns that manifest.\n\n NOTE: This method will only be necessary until we've completed the backfill, at which point\n it should be removed.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "tag",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "tag",
"type": null,
"docstring": null,
"docstring_tokens": []... |
8d46885a20f967bc0e3c0c331cd56fc3c5932d64 | cuisongliu/quay | data/registry_model/interface.py | [
"Apache-2.0"
] | Python | list_manifest_layers | null | def list_manifest_layers(self, manifest, storage, include_placements=False):
"""
Returns an *ordered list* of the layers found in the manifest, starting at the base and
working towards the leaf, including the associated Blob and its placements (if specified).
The layer information in `l... |
Returns an *ordered list* of the layers found in the manifest, starting at the base and
working towards the leaf, including the associated Blob and its placements (if specified).
The layer information in `layer_info` will be of type
`image.docker.types.ManifestImageLayer`. Should not b... | Returns an *ordered list* of the layers found in the manifest, starting at the base and
working towards the leaf, including the associated Blob and its placements (if specified).
The layer information in `layer_info` will be of type
`image.docker.types.ManifestImageLayer`. Should not be called for a manifest list. | [
"Returns",
"an",
"*",
"ordered",
"list",
"*",
"of",
"the",
"layers",
"found",
"in",
"the",
"manifest",
"starting",
"at",
"the",
"base",
"and",
"working",
"towards",
"the",
"leaf",
"including",
"the",
"associated",
"Blob",
"and",
"its",
"placements",
"(",
"... | def list_manifest_layers(self, manifest, storage, include_placements=False): | [
"def",
"list_manifest_layers",
"(",
"self",
",",
"manifest",
",",
"storage",
",",
"include_placements",
"=",
"False",
")",
":"
] | Returns an *ordered list* of the layers found in the manifest, starting at the base and
working towards the leaf, including the associated Blob and its placements (if specified). | [
"Returns",
"an",
"*",
"ordered",
"list",
"*",
"of",
"the",
"layers",
"found",
"in",
"the",
"manifest",
"starting",
"at",
"the",
"base",
"and",
"working",
"towards",
"the",
"leaf",
"including",
"the",
"associated",
"Blob",
"and",
"its",
"placements",
"(",
"... | [
"\"\"\"\n Returns an *ordered list* of the layers found in the manifest, starting at the base and\n working towards the leaf, including the associated Blob and its placements (if specified).\n\n The layer information in `layer_info` will be of type\n `image.docker.types.ManifestImageLaye... | [
{
"param": "self",
"type": null
},
{
"param": "manifest",
"type": null
},
{
"param": "storage",
"type": null
},
{
"param": "include_placements",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "manifest",
"type": null,
"docstring": null,
"docstring_tokens... |
8d46885a20f967bc0e3c0c331cd56fc3c5932d64 | cuisongliu/quay | data/registry_model/interface.py | [
"Apache-2.0"
] | Python | list_parsed_manifest_layers | null | def list_parsed_manifest_layers(
self, repository_ref, parsed_manifest, storage, include_placements=False
):
"""
Returns an *ordered list* of the layers found in the parsed manifest, starting at the base
and working towards the leaf, including the associated Blob and its placements (... |
Returns an *ordered list* of the layers found in the parsed manifest, starting at the base
and working towards the leaf, including the associated Blob and its placements (if
specified).
The layer information in `layer_info` will be of type
`image.docker.types.ManifestImageLayer... | Returns an *ordered list* of the layers found in the parsed manifest, starting at the base
and working towards the leaf, including the associated Blob and its placements (if
specified).
The layer information in `layer_info` will be of type
`image.docker.types.ManifestImageLayer`. Should not be called for a manifest li... | [
"Returns",
"an",
"*",
"ordered",
"list",
"*",
"of",
"the",
"layers",
"found",
"in",
"the",
"parsed",
"manifest",
"starting",
"at",
"the",
"base",
"and",
"working",
"towards",
"the",
"leaf",
"including",
"the",
"associated",
"Blob",
"and",
"its",
"placements"... | def list_parsed_manifest_layers(
self, repository_ref, parsed_manifest, storage, include_placements=False
): | [
"def",
"list_parsed_manifest_layers",
"(",
"self",
",",
"repository_ref",
",",
"parsed_manifest",
",",
"storage",
",",
"include_placements",
"=",
"False",
")",
":"
] | Returns an *ordered list* of the layers found in the parsed manifest, starting at the base
and working towards the leaf, including the associated Blob and its placements (if
specified). | [
"Returns",
"an",
"*",
"ordered",
"list",
"*",
"of",
"the",
"layers",
"found",
"in",
"the",
"parsed",
"manifest",
"starting",
"at",
"the",
"base",
"and",
"working",
"towards",
"the",
"leaf",
"including",
"the",
"associated",
"Blob",
"and",
"its",
"placements"... | [
"\"\"\"\n Returns an *ordered list* of the layers found in the parsed manifest, starting at the base\n and working towards the leaf, including the associated Blob and its placements (if\n specified).\n\n The layer information in `layer_info` will be of type\n `image.docker.types.M... | [
{
"param": "self",
"type": null
},
{
"param": "repository_ref",
"type": null
},
{
"param": "parsed_manifest",
"type": null
},
{
"param": "storage",
"type": null
},
{
"param": "include_placements",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "repository_ref",
"type": null,
"docstring": null,
"docstring_... |
8d46885a20f967bc0e3c0c331cd56fc3c5932d64 | cuisongliu/quay | data/registry_model/interface.py | [
"Apache-2.0"
] | Python | lookup_derived_image | null | def lookup_derived_image(
self, manifest, verb, storage, varying_metadata=None, include_placements=False
):
"""
Looks up the derived image for the given manifest, verb and optional varying metadata and
returns it or None if none.
""" |
Looks up the derived image for the given manifest, verb and optional varying metadata and
returns it or None if none.
| Looks up the derived image for the given manifest, verb and optional varying metadata and
returns it or None if none. | [
"Looks",
"up",
"the",
"derived",
"image",
"for",
"the",
"given",
"manifest",
"verb",
"and",
"optional",
"varying",
"metadata",
"and",
"returns",
"it",
"or",
"None",
"if",
"none",
"."
] | def lookup_derived_image(
self, manifest, verb, storage, varying_metadata=None, include_placements=False
): | [
"def",
"lookup_derived_image",
"(",
"self",
",",
"manifest",
",",
"verb",
",",
"storage",
",",
"varying_metadata",
"=",
"None",
",",
"include_placements",
"=",
"False",
")",
":"
] | Looks up the derived image for the given manifest, verb and optional varying metadata and
returns it or None if none. | [
"Looks",
"up",
"the",
"derived",
"image",
"for",
"the",
"given",
"manifest",
"verb",
"and",
"optional",
"varying",
"metadata",
"and",
"returns",
"it",
"or",
"None",
"if",
"none",
"."
] | [
"\"\"\"\n Looks up the derived image for the given manifest, verb and optional varying metadata and\n returns it or None if none.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "manifest",
"type": null
},
{
"param": "verb",
"type": null
},
{
"param": "storage",
"type": null
},
{
"param": "varying_metadata",
"type": null
},
{
"param": "include_placements",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "manifest",
"type": null,
"docstring": null,
"docstring_tokens... |
8d46885a20f967bc0e3c0c331cd56fc3c5932d64 | cuisongliu/quay | data/registry_model/interface.py | [
"Apache-2.0"
] | Python | lookup_or_create_derived_image | null | def lookup_or_create_derived_image(
self,
manifest,
verb,
storage_location,
storage,
varying_metadata=None,
include_placements=False,
):
"""
Looks up the derived image for the given maniest, verb and optional varying metadata and
return... |
Looks up the derived image for the given maniest, verb and optional varying metadata and
returns it.
If none exists, a new derived image is created.
| Looks up the derived image for the given maniest, verb and optional varying metadata and
returns it.
If none exists, a new derived image is created. | [
"Looks",
"up",
"the",
"derived",
"image",
"for",
"the",
"given",
"maniest",
"verb",
"and",
"optional",
"varying",
"metadata",
"and",
"returns",
"it",
".",
"If",
"none",
"exists",
"a",
"new",
"derived",
"image",
"is",
"created",
"."
] | def lookup_or_create_derived_image(
self,
manifest,
verb,
storage_location,
storage,
varying_metadata=None,
include_placements=False,
): | [
"def",
"lookup_or_create_derived_image",
"(",
"self",
",",
"manifest",
",",
"verb",
",",
"storage_location",
",",
"storage",
",",
"varying_metadata",
"=",
"None",
",",
"include_placements",
"=",
"False",
",",
")",
":"
] | Looks up the derived image for the given maniest, verb and optional varying metadata and
returns it. | [
"Looks",
"up",
"the",
"derived",
"image",
"for",
"the",
"given",
"maniest",
"verb",
"and",
"optional",
"varying",
"metadata",
"and",
"returns",
"it",
"."
] | [
"\"\"\"\n Looks up the derived image for the given maniest, verb and optional varying metadata and\n returns it.\n\n If none exists, a new derived image is created.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "manifest",
"type": null
},
{
"param": "verb",
"type": null
},
{
"param": "storage_location",
"type": null
},
{
"param": "storage",
"type": null
},
{
"param": "varying_metadata",
"type": null
},
{
... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "manifest",
"type": null,
"docstring": null,
"docstring_tokens... |
8d46885a20f967bc0e3c0c331cd56fc3c5932d64 | cuisongliu/quay | data/registry_model/interface.py | [
"Apache-2.0"
] | Python | create_blob_upload | null | def create_blob_upload(self, repository_ref, upload_id, location_name, storage_metadata):
"""
Creates a new blob upload and returns a reference.
If the blob upload could not be created, returns None.
""" |
Creates a new blob upload and returns a reference.
If the blob upload could not be created, returns None.
| Creates a new blob upload and returns a reference.
If the blob upload could not be created, returns None. | [
"Creates",
"a",
"new",
"blob",
"upload",
"and",
"returns",
"a",
"reference",
".",
"If",
"the",
"blob",
"upload",
"could",
"not",
"be",
"created",
"returns",
"None",
"."
] | def create_blob_upload(self, repository_ref, upload_id, location_name, storage_metadata): | [
"def",
"create_blob_upload",
"(",
"self",
",",
"repository_ref",
",",
"upload_id",
",",
"location_name",
",",
"storage_metadata",
")",
":"
] | Creates a new blob upload and returns a reference. | [
"Creates",
"a",
"new",
"blob",
"upload",
"and",
"returns",
"a",
"reference",
"."
] | [
"\"\"\"\n Creates a new blob upload and returns a reference.\n\n If the blob upload could not be created, returns None.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "repository_ref",
"type": null
},
{
"param": "upload_id",
"type": null
},
{
"param": "location_name",
"type": null
},
{
"param": "storage_metadata",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "repository_ref",
"type": null,
"docstring": null,
"docstring_... |
8d46885a20f967bc0e3c0c331cd56fc3c5932d64 | cuisongliu/quay | data/registry_model/interface.py | [
"Apache-2.0"
] | Python | lookup_blob_upload | null | def lookup_blob_upload(self, repository_ref, blob_upload_id):
"""
Looks up the blob upload with the given ID under the specified repository and returns it or
None if none.
""" |
Looks up the blob upload with the given ID under the specified repository and returns it or
None if none.
| Looks up the blob upload with the given ID under the specified repository and returns it or
None if none. | [
"Looks",
"up",
"the",
"blob",
"upload",
"with",
"the",
"given",
"ID",
"under",
"the",
"specified",
"repository",
"and",
"returns",
"it",
"or",
"None",
"if",
"none",
"."
] | def lookup_blob_upload(self, repository_ref, blob_upload_id): | [
"def",
"lookup_blob_upload",
"(",
"self",
",",
"repository_ref",
",",
"blob_upload_id",
")",
":"
] | Looks up the blob upload with the given ID under the specified repository and returns it or
None if none. | [
"Looks",
"up",
"the",
"blob",
"upload",
"with",
"the",
"given",
"ID",
"under",
"the",
"specified",
"repository",
"and",
"returns",
"it",
"or",
"None",
"if",
"none",
"."
] | [
"\"\"\"\n Looks up the blob upload with the given ID under the specified repository and returns it or\n None if none.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "repository_ref",
"type": null
},
{
"param": "blob_upload_id",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "repository_ref",
"type": null,
"docstring": null,
"docstring_... |
8d46885a20f967bc0e3c0c331cd56fc3c5932d64 | cuisongliu/quay | data/registry_model/interface.py | [
"Apache-2.0"
] | Python | update_blob_upload | null | def update_blob_upload(
self,
blob_upload,
uncompressed_byte_count,
piece_hashes,
piece_sha_state,
storage_metadata,
byte_count,
chunk_count,
sha_state,
):
"""
Updates the fields of the blob upload to match those given.
... |
Updates the fields of the blob upload to match those given.
Returns the updated blob upload or None if the record does not exists.
| Updates the fields of the blob upload to match those given.
Returns the updated blob upload or None if the record does not exists. | [
"Updates",
"the",
"fields",
"of",
"the",
"blob",
"upload",
"to",
"match",
"those",
"given",
".",
"Returns",
"the",
"updated",
"blob",
"upload",
"or",
"None",
"if",
"the",
"record",
"does",
"not",
"exists",
"."
] | def update_blob_upload(
self,
blob_upload,
uncompressed_byte_count,
piece_hashes,
piece_sha_state,
storage_metadata,
byte_count,
chunk_count,
sha_state,
): | [
"def",
"update_blob_upload",
"(",
"self",
",",
"blob_upload",
",",
"uncompressed_byte_count",
",",
"piece_hashes",
",",
"piece_sha_state",
",",
"storage_metadata",
",",
"byte_count",
",",
"chunk_count",
",",
"sha_state",
",",
")",
":"
] | Updates the fields of the blob upload to match those given. | [
"Updates",
"the",
"fields",
"of",
"the",
"blob",
"upload",
"to",
"match",
"those",
"given",
"."
] | [
"\"\"\"\n Updates the fields of the blob upload to match those given.\n\n Returns the updated blob upload or None if the record does not exists.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "blob_upload",
"type": null
},
{
"param": "uncompressed_byte_count",
"type": null
},
{
"param": "piece_hashes",
"type": null
},
{
"param": "piece_sha_state",
"type": null
},
{
"param": "storage_metadata",
... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "blob_upload",
"type": null,
"docstring": null,
"docstring_tok... |
8d46885a20f967bc0e3c0c331cd56fc3c5932d64 | cuisongliu/quay | data/registry_model/interface.py | [
"Apache-2.0"
] | Python | mount_blob_into_repository | null | def mount_blob_into_repository(self, blob, target_repository_ref, expiration_sec):
"""
Mounts the blob from another repository into the specified target repository, and adds an
expiration before that blob is automatically GCed.
This function is useful during push operations if an existi... |
Mounts the blob from another repository into the specified target repository, and adds an
expiration before that blob is automatically GCed.
This function is useful during push operations if an existing blob from another repository
is being pushed. Returns False if the mounting fails. ... | Mounts the blob from another repository into the specified target repository, and adds an
expiration before that blob is automatically GCed.
This function is useful during push operations if an existing blob from another repository
is being pushed. Returns False if the mounting fails. Note that this function does *not... | [
"Mounts",
"the",
"blob",
"from",
"another",
"repository",
"into",
"the",
"specified",
"target",
"repository",
"and",
"adds",
"an",
"expiration",
"before",
"that",
"blob",
"is",
"automatically",
"GCed",
".",
"This",
"function",
"is",
"useful",
"during",
"push",
... | def mount_blob_into_repository(self, blob, target_repository_ref, expiration_sec): | [
"def",
"mount_blob_into_repository",
"(",
"self",
",",
"blob",
",",
"target_repository_ref",
",",
"expiration_sec",
")",
":"
] | Mounts the blob from another repository into the specified target repository, and adds an
expiration before that blob is automatically GCed. | [
"Mounts",
"the",
"blob",
"from",
"another",
"repository",
"into",
"the",
"specified",
"target",
"repository",
"and",
"adds",
"an",
"expiration",
"before",
"that",
"blob",
"is",
"automatically",
"GCed",
"."
] | [
"\"\"\"\n Mounts the blob from another repository into the specified target repository, and adds an\n expiration before that blob is automatically GCed.\n\n This function is useful during push operations if an existing blob from another repository\n is being pushed. Returns False if the ... | [
{
"param": "self",
"type": null
},
{
"param": "blob",
"type": null
},
{
"param": "target_repository_ref",
"type": null
},
{
"param": "expiration_sec",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "blob",
"type": null,
"docstring": null,
"docstring_tokens": [... |
8d46885a20f967bc0e3c0c331cd56fc3c5932d64 | cuisongliu/quay | data/registry_model/interface.py | [
"Apache-2.0"
] | Python | create_manifest_with_temp_tag | null | def create_manifest_with_temp_tag(
self, repository_ref, manifest_interface_instance, expiration_sec, storage
):
"""
Creates a manifest under the repository and sets a temporary tag to point to it.
Returns the manifest object created or None on error.
""" |
Creates a manifest under the repository and sets a temporary tag to point to it.
Returns the manifest object created or None on error.
| Creates a manifest under the repository and sets a temporary tag to point to it.
Returns the manifest object created or None on error. | [
"Creates",
"a",
"manifest",
"under",
"the",
"repository",
"and",
"sets",
"a",
"temporary",
"tag",
"to",
"point",
"to",
"it",
".",
"Returns",
"the",
"manifest",
"object",
"created",
"or",
"None",
"on",
"error",
"."
] | def create_manifest_with_temp_tag(
self, repository_ref, manifest_interface_instance, expiration_sec, storage
): | [
"def",
"create_manifest_with_temp_tag",
"(",
"self",
",",
"repository_ref",
",",
"manifest_interface_instance",
",",
"expiration_sec",
",",
"storage",
")",
":"
] | Creates a manifest under the repository and sets a temporary tag to point to it. | [
"Creates",
"a",
"manifest",
"under",
"the",
"repository",
"and",
"sets",
"a",
"temporary",
"tag",
"to",
"point",
"to",
"it",
"."
] | [
"\"\"\"\n Creates a manifest under the repository and sets a temporary tag to point to it.\n\n Returns the manifest object created or None on error.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "repository_ref",
"type": null
},
{
"param": "manifest_interface_instance",
"type": null
},
{
"param": "expiration_sec",
"type": null
},
{
"param": "storage",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "repository_ref",
"type": null,
"docstring": null,
"docstring_... |
8d46885a20f967bc0e3c0c331cd56fc3c5932d64 | cuisongliu/quay | data/registry_model/interface.py | [
"Apache-2.0"
] | Python | convert_manifest | null | def convert_manifest(
self, manifest, namespace_name, repo_name, tag_name, allowed_mediatypes, storage
):
"""
Attempts to convert the specified into a parsed manifest with a media type in the
allowed_mediatypes set.
If not possible, or an error occurs, returns None.
... |
Attempts to convert the specified into a parsed manifest with a media type in the
allowed_mediatypes set.
If not possible, or an error occurs, returns None.
| Attempts to convert the specified into a parsed manifest with a media type in the
allowed_mediatypes set.
If not possible, or an error occurs, returns None. | [
"Attempts",
"to",
"convert",
"the",
"specified",
"into",
"a",
"parsed",
"manifest",
"with",
"a",
"media",
"type",
"in",
"the",
"allowed_mediatypes",
"set",
".",
"If",
"not",
"possible",
"or",
"an",
"error",
"occurs",
"returns",
"None",
"."
] | def convert_manifest(
self, manifest, namespace_name, repo_name, tag_name, allowed_mediatypes, storage
): | [
"def",
"convert_manifest",
"(",
"self",
",",
"manifest",
",",
"namespace_name",
",",
"repo_name",
",",
"tag_name",
",",
"allowed_mediatypes",
",",
"storage",
")",
":"
] | Attempts to convert the specified into a parsed manifest with a media type in the
allowed_mediatypes set. | [
"Attempts",
"to",
"convert",
"the",
"specified",
"into",
"a",
"parsed",
"manifest",
"with",
"a",
"media",
"type",
"in",
"the",
"allowed_mediatypes",
"set",
"."
] | [
"\"\"\"\n Attempts to convert the specified into a parsed manifest with a media type in the\n allowed_mediatypes set.\n\n If not possible, or an error occurs, returns None.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "manifest",
"type": null
},
{
"param": "namespace_name",
"type": null
},
{
"param": "repo_name",
"type": null
},
{
"param": "tag_name",
"type": null
},
{
"param": "allowed_mediatypes",
"type": null
},... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "manifest",
"type": null,
"docstring": null,
"docstring_tokens... |
8d46885a20f967bc0e3c0c331cd56fc3c5932d64 | cuisongliu/quay | data/registry_model/interface.py | [
"Apache-2.0"
] | Python | yield_tags_for_vulnerability_notification | null | def yield_tags_for_vulnerability_notification(self, layer_id_pairs):
"""
Yields tags that contain one (or more) of the given layer ID pairs, in repositories which
have been registered for vulnerability_found notifications.
Returns an iterator of LikelyVulnerableTag instances.
""... |
Yields tags that contain one (or more) of the given layer ID pairs, in repositories which
have been registered for vulnerability_found notifications.
Returns an iterator of LikelyVulnerableTag instances.
| Yields tags that contain one (or more) of the given layer ID pairs, in repositories which
have been registered for vulnerability_found notifications.
Returns an iterator of LikelyVulnerableTag instances. | [
"Yields",
"tags",
"that",
"contain",
"one",
"(",
"or",
"more",
")",
"of",
"the",
"given",
"layer",
"ID",
"pairs",
"in",
"repositories",
"which",
"have",
"been",
"registered",
"for",
"vulnerability_found",
"notifications",
".",
"Returns",
"an",
"iterator",
"of"... | def yield_tags_for_vulnerability_notification(self, layer_id_pairs): | [
"def",
"yield_tags_for_vulnerability_notification",
"(",
"self",
",",
"layer_id_pairs",
")",
":"
] | Yields tags that contain one (or more) of the given layer ID pairs, in repositories which
have been registered for vulnerability_found notifications. | [
"Yields",
"tags",
"that",
"contain",
"one",
"(",
"or",
"more",
")",
"of",
"the",
"given",
"layer",
"ID",
"pairs",
"in",
"repositories",
"which",
"have",
"been",
"registered",
"for",
"vulnerability_found",
"notifications",
"."
] | [
"\"\"\"\n Yields tags that contain one (or more) of the given layer ID pairs, in repositories which\n have been registered for vulnerability_found notifications.\n\n Returns an iterator of LikelyVulnerableTag instances.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "layer_id_pairs",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "layer_id_pairs",
"type": null,
"docstring": null,
"docstring_... |
071e46cc55fd581122b1aba9ac96cefccf189d79 | cuisongliu/quay | data/secscan_model/secscan_v2_model.py | [
"Apache-2.0"
] | Python | legacy_api_handler | <not_specific> | def legacy_api_handler(self):
"""
Exposes the legacy security scan API for legacy workers that need it.
"""
return self._legacy_secscan_api |
Exposes the legacy security scan API for legacy workers that need it.
| Exposes the legacy security scan API for legacy workers that need it. | [
"Exposes",
"the",
"legacy",
"security",
"scan",
"API",
"for",
"legacy",
"workers",
"that",
"need",
"it",
"."
] | def legacy_api_handler(self):
return self._legacy_secscan_api | [
"def",
"legacy_api_handler",
"(",
"self",
")",
":",
"return",
"self",
".",
"_legacy_secscan_api"
] | Exposes the legacy security scan API for legacy workers that need it. | [
"Exposes",
"the",
"legacy",
"security",
"scan",
"API",
"for",
"legacy",
"workers",
"that",
"need",
"it",
"."
] | [
"\"\"\"\n Exposes the legacy security scan API for legacy workers that need it.\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
071e46cc55fd581122b1aba9ac96cefccf189d79 | cuisongliu/quay | data/secscan_model/secscan_v2_model.py | [
"Apache-2.0"
] | Python | perform_indexing | <not_specific> | def perform_indexing(self, start_token=None):
"""
Performs indexing of the next set of unindexed manifests/images.
If start_token is given, the indexing should resume from that point. Returns a new start
index for the next iteration of indexing. The tokens returned and given are assumed... |
Performs indexing of the next set of unindexed manifests/images.
If start_token is given, the indexing should resume from that point. Returns a new start
index for the next iteration of indexing. The tokens returned and given are assumed to be
opaque outside of this implementation and ... | Performs indexing of the next set of unindexed manifests/images.
If start_token is given, the indexing should resume from that point. Returns a new start
index for the next iteration of indexing. The tokens returned and given are assumed to be
opaque outside of this implementation and should not be relied upon by the c... | [
"Performs",
"indexing",
"of",
"the",
"next",
"set",
"of",
"unindexed",
"manifests",
"/",
"images",
".",
"If",
"start_token",
"is",
"given",
"the",
"indexing",
"should",
"resume",
"from",
"that",
"point",
".",
"Returns",
"a",
"new",
"start",
"index",
"for",
... | def perform_indexing(self, start_token=None):
from util.secscan.analyzer import PreemptedException
iterator, next_token = self._candidates_to_scan(start_token)
if iterator is None:
logger.debug("Found no additional images to scan")
return None
with UseThenDisconne... | [
"def",
"perform_indexing",
"(",
"self",
",",
"start_token",
"=",
"None",
")",
":",
"from",
"util",
".",
"secscan",
".",
"analyzer",
"import",
"PreemptedException",
"iterator",
",",
"next_token",
"=",
"self",
".",
"_candidates_to_scan",
"(",
"start_token",
")",
... | Performs indexing of the next set of unindexed manifests/images. | [
"Performs",
"indexing",
"of",
"the",
"next",
"set",
"of",
"unindexed",
"manifests",
"/",
"images",
"."
] | [
"\"\"\"\n Performs indexing of the next set of unindexed manifests/images.\n\n If start_token is given, the indexing should resume from that point. Returns a new start\n index for the next iteration of indexing. The tokens returned and given are assumed to be\n opaque outside of this imp... | [
{
"param": "self",
"type": null
},
{
"param": "start_token",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "start_token",
"type": null,
"docstring": null,
"docstring_tok... |
b65b7f9fefc4fe32ab78eeec727289f15d73247a | cuisongliu/quay | data/secscan_model/interface.py | [
"Apache-2.0"
] | Python | load_security_information | null | def load_security_information(self, manifest_or_legacy_image, include_vulnerabilities=False):
"""
Loads the security information for the given manifest or legacy image, returning a
SecurityInformationLookupResult structure.
The manifest_or_legacy_image must be a Manifest or LegacyImage ... |
Loads the security information for the given manifest or legacy image, returning a
SecurityInformationLookupResult structure.
The manifest_or_legacy_image must be a Manifest or LegacyImage datatype from the
registry_model.
| Loads the security information for the given manifest or legacy image, returning a
SecurityInformationLookupResult structure.
The manifest_or_legacy_image must be a Manifest or LegacyImage datatype from the
registry_model. | [
"Loads",
"the",
"security",
"information",
"for",
"the",
"given",
"manifest",
"or",
"legacy",
"image",
"returning",
"a",
"SecurityInformationLookupResult",
"structure",
".",
"The",
"manifest_or_legacy_image",
"must",
"be",
"a",
"Manifest",
"or",
"LegacyImage",
"dataty... | def load_security_information(self, manifest_or_legacy_image, include_vulnerabilities=False): | [
"def",
"load_security_information",
"(",
"self",
",",
"manifest_or_legacy_image",
",",
"include_vulnerabilities",
"=",
"False",
")",
":"
] | Loads the security information for the given manifest or legacy image, returning a
SecurityInformationLookupResult structure. | [
"Loads",
"the",
"security",
"information",
"for",
"the",
"given",
"manifest",
"or",
"legacy",
"image",
"returning",
"a",
"SecurityInformationLookupResult",
"structure",
"."
] | [
"\"\"\"\n Loads the security information for the given manifest or legacy image, returning a\n SecurityInformationLookupResult structure.\n\n The manifest_or_legacy_image must be a Manifest or LegacyImage datatype from the\n registry_model.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "manifest_or_legacy_image",
"type": null
},
{
"param": "include_vulnerabilities",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "manifest_or_legacy_image",
"type": null,
"docstring": null,
"... |
b65b7f9fefc4fe32ab78eeec727289f15d73247a | cuisongliu/quay | data/secscan_model/interface.py | [
"Apache-2.0"
] | Python | perform_indexing | null | def perform_indexing(self, start_token=None):
"""
Performs indexing of the next set of unindexed manifests/images.
If start_token is given, the indexing should resume from that point. Returns a new start
index for the next iteration of indexing. The tokens returned and given are assumed... |
Performs indexing of the next set of unindexed manifests/images.
If start_token is given, the indexing should resume from that point. Returns a new start
index for the next iteration of indexing. The tokens returned and given are assumed to be
opaque outside of this implementation and ... | Performs indexing of the next set of unindexed manifests/images.
If start_token is given, the indexing should resume from that point. Returns a new start
index for the next iteration of indexing. The tokens returned and given are assumed to be
opaque outside of this implementation and should not be relied upon by the c... | [
"Performs",
"indexing",
"of",
"the",
"next",
"set",
"of",
"unindexed",
"manifests",
"/",
"images",
".",
"If",
"start_token",
"is",
"given",
"the",
"indexing",
"should",
"resume",
"from",
"that",
"point",
".",
"Returns",
"a",
"new",
"start",
"index",
"for",
... | def perform_indexing(self, start_token=None): | [
"def",
"perform_indexing",
"(",
"self",
",",
"start_token",
"=",
"None",
")",
":"
] | Performs indexing of the next set of unindexed manifests/images. | [
"Performs",
"indexing",
"of",
"the",
"next",
"set",
"of",
"unindexed",
"manifests",
"/",
"images",
"."
] | [
"\"\"\"\n Performs indexing of the next set of unindexed manifests/images.\n\n If start_token is given, the indexing should resume from that point. Returns a new start\n index for the next iteration of indexing. The tokens returned and given are assumed to be\n opaque outside of this imp... | [
{
"param": "self",
"type": null
},
{
"param": "start_token",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "start_token",
"type": null,
"docstring": null,
"docstring_tok... |
b65b7f9fefc4fe32ab78eeec727289f15d73247a | cuisongliu/quay | data/secscan_model/interface.py | [
"Apache-2.0"
] | Python | register_model_cleanup_callbacks | null | def register_model_cleanup_callbacks(self, data_model_config):
"""
Registers any cleanup callbacks with the data model.
Typically, a callback is registered to remove the manifest/image from the security indexer
if it has been GCed in the data model.
""" |
Registers any cleanup callbacks with the data model.
Typically, a callback is registered to remove the manifest/image from the security indexer
if it has been GCed in the data model.
| Registers any cleanup callbacks with the data model.
Typically, a callback is registered to remove the manifest/image from the security indexer
if it has been GCed in the data model. | [
"Registers",
"any",
"cleanup",
"callbacks",
"with",
"the",
"data",
"model",
".",
"Typically",
"a",
"callback",
"is",
"registered",
"to",
"remove",
"the",
"manifest",
"/",
"image",
"from",
"the",
"security",
"indexer",
"if",
"it",
"has",
"been",
"GCed",
"in",... | def register_model_cleanup_callbacks(self, data_model_config): | [
"def",
"register_model_cleanup_callbacks",
"(",
"self",
",",
"data_model_config",
")",
":"
] | Registers any cleanup callbacks with the data model. | [
"Registers",
"any",
"cleanup",
"callbacks",
"with",
"the",
"data",
"model",
"."
] | [
"\"\"\"\n Registers any cleanup callbacks with the data model.\n\n Typically, a callback is registered to remove the manifest/image from the security indexer\n if it has been GCed in the data model.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "data_model_config",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "data_model_config",
"type": null,
"docstring": null,
"docstri... |
39b5cbb56187dbc4071d03595d4810d516f6105c | cuisongliu/quay | workers/repositoryactioncounter.py | [
"Apache-2.0"
] | Python | _count_repository_actions | <not_specific> | def _count_repository_actions(self):
"""
Counts actions and aggregates search scores for a random repository for the previous day.
"""
# Select a repository that needs its actions for the last day updated.
to_count = model.repositoryactioncount.find_uncounted_repository()
... |
Counts actions and aggregates search scores for a random repository for the previous day.
| Counts actions and aggregates search scores for a random repository for the previous day. | [
"Counts",
"actions",
"and",
"aggregates",
"search",
"scores",
"for",
"a",
"random",
"repository",
"for",
"the",
"previous",
"day",
"."
] | def _count_repository_actions(self):
to_count = model.repositoryactioncount.find_uncounted_repository()
if to_count is None:
logger.debug("No further repositories to count")
return False
logger.debug("Found repository #%s to count", to_count.id)
yesterday = date.t... | [
"def",
"_count_repository_actions",
"(",
"self",
")",
":",
"to_count",
"=",
"model",
".",
"repositoryactioncount",
".",
"find_uncounted_repository",
"(",
")",
"if",
"to_count",
"is",
"None",
":",
"logger",
".",
"debug",
"(",
"\"No further repositories to count\"",
"... | Counts actions and aggregates search scores for a random repository for the previous day. | [
"Counts",
"actions",
"and",
"aggregates",
"search",
"scores",
"for",
"a",
"random",
"repository",
"for",
"the",
"previous",
"day",
"."
] | [
"\"\"\"\n Counts actions and aggregates search scores for a random repository for the previous day.\n \"\"\"",
"# Select a repository that needs its actions for the last day updated.",
"# Count the number of actions that occurred yesterday for the repository.",
"# Store the count for the reposit... | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
52bb2570eef863ea274a513de22717986a1d9078 | cuisongliu/quay | data/model/oci/tag.py | [
"Apache-2.0"
] | Python | list_repository_tag_history | <not_specific> | def list_repository_tag_history(
repository_id,
page,
page_size,
specific_tag_name=None,
active_tags_only=False,
since_time_ms=None,
):
"""
Returns a tuple of the full set of tags found in the specified repository, including those that
are no longer alive (unless active_tags_only is ... |
Returns a tuple of the full set of tags found in the specified repository, including those that
are no longer alive (unless active_tags_only is True), and whether additional tags exist. If
specific_tag_name is given, the tags are further filtered by name. If since is given, tags are
further filtered to... | Returns a tuple of the full set of tags found in the specified repository, including those that
are no longer alive (unless active_tags_only is True), and whether additional tags exist. If
specific_tag_name is given, the tags are further filtered by name. If since is given, tags are
further filtered to newer than that ... | [
"Returns",
"a",
"tuple",
"of",
"the",
"full",
"set",
"of",
"tags",
"found",
"in",
"the",
"specified",
"repository",
"including",
"those",
"that",
"are",
"no",
"longer",
"alive",
"(",
"unless",
"active_tags_only",
"is",
"True",
")",
"and",
"whether",
"additio... | def list_repository_tag_history(
repository_id,
page,
page_size,
specific_tag_name=None,
active_tags_only=False,
since_time_ms=None,
):
query = (
Tag.select(Tag, Manifest.id, Manifest.digest, Manifest.media_type)
.join(Manifest)
.where(Tag.repository == repository_id)... | [
"def",
"list_repository_tag_history",
"(",
"repository_id",
",",
"page",
",",
"page_size",
",",
"specific_tag_name",
"=",
"None",
",",
"active_tags_only",
"=",
"False",
",",
"since_time_ms",
"=",
"None",
",",
")",
":",
"query",
"=",
"(",
"Tag",
".",
"select",
... | Returns a tuple of the full set of tags found in the specified repository, including those that
are no longer alive (unless active_tags_only is True), and whether additional tags exist. | [
"Returns",
"a",
"tuple",
"of",
"the",
"full",
"set",
"of",
"tags",
"found",
"in",
"the",
"specified",
"repository",
"including",
"those",
"that",
"are",
"no",
"longer",
"alive",
"(",
"unless",
"active_tags_only",
"is",
"True",
")",
"and",
"whether",
"additio... | [
"\"\"\"\n Returns a tuple of the full set of tags found in the specified repository, including those that\n are no longer alive (unless active_tags_only is True), and whether additional tags exist. If\n specific_tag_name is given, the tags are further filtered by name. If since is given, tags are\n furt... | [
{
"param": "repository_id",
"type": null
},
{
"param": "page",
"type": null
},
{
"param": "page_size",
"type": null
},
{
"param": "specific_tag_name",
"type": null
},
{
"param": "active_tags_only",
"type": null
},
{
"param": "since_time_ms",
"type"... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "repository_id",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "page",
"type": null,
"docstring": null,
"docstring_t... |
52bb2570eef863ea274a513de22717986a1d9078 | cuisongliu/quay | data/model/oci/tag.py | [
"Apache-2.0"
] | Python | retarget_tag | <not_specific> | def retarget_tag(
tag_name, manifest_id, is_reversion=False, now_ms=None, raise_on_error=False,
):
"""
Creates or updates a tag with the specified name to point to the given manifest under its
repository.
If this action is a reversion to a previous manifest, is_reversion should be set to True.
... |
Creates or updates a tag with the specified name to point to the given manifest under its
repository.
If this action is a reversion to a previous manifest, is_reversion should be set to True.
Returns the newly created tag row or None on error.
| Creates or updates a tag with the specified name to point to the given manifest under its
repository.
If this action is a reversion to a previous manifest, is_reversion should be set to True.
Returns the newly created tag row or None on error. | [
"Creates",
"or",
"updates",
"a",
"tag",
"with",
"the",
"specified",
"name",
"to",
"point",
"to",
"the",
"given",
"manifest",
"under",
"its",
"repository",
".",
"If",
"this",
"action",
"is",
"a",
"reversion",
"to",
"a",
"previous",
"manifest",
"is_reversion",... | def retarget_tag(
tag_name, manifest_id, is_reversion=False, now_ms=None, raise_on_error=False,
):
try:
manifest = (
Manifest.select(Manifest, MediaType)
.join(MediaType)
.where(Manifest.id == manifest_id)
.get()
)
except Manifest.DoesNotExist:... | [
"def",
"retarget_tag",
"(",
"tag_name",
",",
"manifest_id",
",",
"is_reversion",
"=",
"False",
",",
"now_ms",
"=",
"None",
",",
"raise_on_error",
"=",
"False",
",",
")",
":",
"try",
":",
"manifest",
"=",
"(",
"Manifest",
".",
"select",
"(",
"Manifest",
"... | Creates or updates a tag with the specified name to point to the given manifest under its
repository. | [
"Creates",
"or",
"updates",
"a",
"tag",
"with",
"the",
"specified",
"name",
"to",
"point",
"to",
"the",
"given",
"manifest",
"under",
"its",
"repository",
"."
] | [
"\"\"\"\n Creates or updates a tag with the specified name to point to the given manifest under its\n repository.\n\n If this action is a reversion to a previous manifest, is_reversion should be set to True.\n Returns the newly created tag row or None on error.\n \"\"\"",
"# CHECK: Make sure that w... | [
{
"param": "tag_name",
"type": null
},
{
"param": "manifest_id",
"type": null
},
{
"param": "is_reversion",
"type": null
},
{
"param": "now_ms",
"type": null
},
{
"param": "raise_on_error",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "tag_name",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "manifest_id",
"type": null,
"docstring": null,
"docstring... |
52bb2570eef863ea274a513de22717986a1d9078 | cuisongliu/quay | data/model/oci/tag.py | [
"Apache-2.0"
] | Python | _delete_tag | <not_specific> | def _delete_tag(tag, now_ms):
"""
Deletes the given tag by marking it as expired.
"""
now_ts = int(now_ms / 1000)
with db_transaction():
updated = (
Tag.update(lifetime_end_ms=now_ms)
.where(Tag.id == tag.id, Tag.lifetime_end_ms == tag.lifetime_end_ms)
.e... |
Deletes the given tag by marking it as expired.
| Deletes the given tag by marking it as expired. | [
"Deletes",
"the",
"given",
"tag",
"by",
"marking",
"it",
"as",
"expired",
"."
] | def _delete_tag(tag, now_ms):
now_ts = int(now_ms / 1000)
with db_transaction():
updated = (
Tag.update(lifetime_end_ms=now_ms)
.where(Tag.id == tag.id, Tag.lifetime_end_ms == tag.lifetime_end_ms)
.execute()
)
if updated != 1:
return None
... | [
"def",
"_delete_tag",
"(",
"tag",
",",
"now_ms",
")",
":",
"now_ts",
"=",
"int",
"(",
"now_ms",
"/",
"1000",
")",
"with",
"db_transaction",
"(",
")",
":",
"updated",
"=",
"(",
"Tag",
".",
"update",
"(",
"lifetime_end_ms",
"=",
"now_ms",
")",
".",
"wh... | Deletes the given tag by marking it as expired. | [
"Deletes",
"the",
"given",
"tag",
"by",
"marking",
"it",
"as",
"expired",
"."
] | [
"\"\"\"\n Deletes the given tag by marking it as expired.\n \"\"\"",
"# TODO: Remove the linkage code once RepositoryTag is gone."
] | [
{
"param": "tag",
"type": null
},
{
"param": "now_ms",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "tag",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "now_ms",
"type": null,
"docstring": null,
"docstring_tokens": ... |
52bb2570eef863ea274a513de22717986a1d9078 | cuisongliu/quay | data/model/oci/tag.py | [
"Apache-2.0"
] | Python | delete_tags_for_manifest | <not_specific> | def delete_tags_for_manifest(manifest):
"""
Deletes all tags pointing to the given manifest.
Returns the list of tags deleted.
"""
query = Tag.select().where(Tag.manifest == manifest)
query = filter_to_alive_tags(query)
query = filter_to_visible_tags(query)
tags = list(query)
now_m... |
Deletes all tags pointing to the given manifest.
Returns the list of tags deleted.
| Deletes all tags pointing to the given manifest.
Returns the list of tags deleted. | [
"Deletes",
"all",
"tags",
"pointing",
"to",
"the",
"given",
"manifest",
".",
"Returns",
"the",
"list",
"of",
"tags",
"deleted",
"."
] | def delete_tags_for_manifest(manifest):
query = Tag.select().where(Tag.manifest == manifest)
query = filter_to_alive_tags(query)
query = filter_to_visible_tags(query)
tags = list(query)
now_ms = get_epoch_timestamp_ms()
with db_transaction():
for tag in tags:
_delete_tag(tag,... | [
"def",
"delete_tags_for_manifest",
"(",
"manifest",
")",
":",
"query",
"=",
"Tag",
".",
"select",
"(",
")",
".",
"where",
"(",
"Tag",
".",
"manifest",
"==",
"manifest",
")",
"query",
"=",
"filter_to_alive_tags",
"(",
"query",
")",
"query",
"=",
"filter_to_... | Deletes all tags pointing to the given manifest. | [
"Deletes",
"all",
"tags",
"pointing",
"to",
"the",
"given",
"manifest",
"."
] | [
"\"\"\"\n Deletes all tags pointing to the given manifest.\n\n Returns the list of tags deleted.\n \"\"\""
] | [
{
"param": "manifest",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "manifest",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
52bb2570eef863ea274a513de22717986a1d9078 | cuisongliu/quay | data/model/oci/tag.py | [
"Apache-2.0"
] | Python | filter_to_alive_tags | <not_specific> | def filter_to_alive_tags(query, now_ms=None, model=Tag):
"""
Adjusts the specified Tag query to only return those tags alive.
If now_ms is specified, the given timestamp (in MS) is used in place of the current timestamp
for determining wherther a tag is alive.
"""
if now_ms is None:
now... |
Adjusts the specified Tag query to only return those tags alive.
If now_ms is specified, the given timestamp (in MS) is used in place of the current timestamp
for determining wherther a tag is alive.
| Adjusts the specified Tag query to only return those tags alive.
If now_ms is specified, the given timestamp (in MS) is used in place of the current timestamp
for determining wherther a tag is alive. | [
"Adjusts",
"the",
"specified",
"Tag",
"query",
"to",
"only",
"return",
"those",
"tags",
"alive",
".",
"If",
"now_ms",
"is",
"specified",
"the",
"given",
"timestamp",
"(",
"in",
"MS",
")",
"is",
"used",
"in",
"place",
"of",
"the",
"current",
"timestamp",
... | def filter_to_alive_tags(query, now_ms=None, model=Tag):
if now_ms is None:
now_ms = get_epoch_timestamp_ms()
return query.where((model.lifetime_end_ms >> None) | (model.lifetime_end_ms > now_ms)).where(
model.hidden == False
) | [
"def",
"filter_to_alive_tags",
"(",
"query",
",",
"now_ms",
"=",
"None",
",",
"model",
"=",
"Tag",
")",
":",
"if",
"now_ms",
"is",
"None",
":",
"now_ms",
"=",
"get_epoch_timestamp_ms",
"(",
")",
"return",
"query",
".",
"where",
"(",
"(",
"model",
".",
... | Adjusts the specified Tag query to only return those tags alive. | [
"Adjusts",
"the",
"specified",
"Tag",
"query",
"to",
"only",
"return",
"those",
"tags",
"alive",
"."
] | [
"\"\"\"\n Adjusts the specified Tag query to only return those tags alive.\n\n If now_ms is specified, the given timestamp (in MS) is used in place of the current timestamp\n for determining wherther a tag is alive.\n \"\"\""
] | [
{
"param": "query",
"type": null
},
{
"param": "now_ms",
"type": null
},
{
"param": "model",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "query",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "now_ms",
"type": null,
"docstring": null,
"docstring_tokens"... |
52bb2570eef863ea274a513de22717986a1d9078 | cuisongliu/quay | data/model/oci/tag.py | [
"Apache-2.0"
] | Python | change_tag_expiration | <not_specific> | def change_tag_expiration(tag_id, expiration_datetime):
"""
Changes the expiration of the specified tag to the given expiration datetime.
If the expiration datetime is None, then the tag is marked as not expiring. Returns a tuple of
the previous expiration timestamp in seconds (if any), and whether the... |
Changes the expiration of the specified tag to the given expiration datetime.
If the expiration datetime is None, then the tag is marked as not expiring. Returns a tuple of
the previous expiration timestamp in seconds (if any), and whether the operation succeeded.
| Changes the expiration of the specified tag to the given expiration datetime.
If the expiration datetime is None, then the tag is marked as not expiring. Returns a tuple of
the previous expiration timestamp in seconds (if any), and whether the operation succeeded. | [
"Changes",
"the",
"expiration",
"of",
"the",
"specified",
"tag",
"to",
"the",
"given",
"expiration",
"datetime",
".",
"If",
"the",
"expiration",
"datetime",
"is",
"None",
"then",
"the",
"tag",
"is",
"marked",
"as",
"not",
"expiring",
".",
"Returns",
"a",
"... | def change_tag_expiration(tag_id, expiration_datetime):
try:
tag = Tag.get(id=tag_id)
except Tag.DoesNotExist:
return (None, False)
new_end_ms = None
min_expire_sec = convert_to_timedelta(config.app_config.get("LABELED_EXPIRATION_MINIMUM", "1h"))
max_expire_sec = convert_to_timedelta... | [
"def",
"change_tag_expiration",
"(",
"tag_id",
",",
"expiration_datetime",
")",
":",
"try",
":",
"tag",
"=",
"Tag",
".",
"get",
"(",
"id",
"=",
"tag_id",
")",
"except",
"Tag",
".",
"DoesNotExist",
":",
"return",
"(",
"None",
",",
"False",
")",
"new_end_m... | Changes the expiration of the specified tag to the given expiration datetime. | [
"Changes",
"the",
"expiration",
"of",
"the",
"specified",
"tag",
"to",
"the",
"given",
"expiration",
"datetime",
"."
] | [
"\"\"\"\n Changes the expiration of the specified tag to the given expiration datetime.\n\n If the expiration datetime is None, then the tag is marked as not expiring. Returns a tuple of\n the previous expiration timestamp in seconds (if any), and whether the operation succeeded.\n \"\"\""
] | [
{
"param": "tag_id",
"type": null
},
{
"param": "expiration_datetime",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "tag_id",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "expiration_datetime",
"type": null,
"docstring": null,
"doc... |
52bb2570eef863ea274a513de22717986a1d9078 | cuisongliu/quay | data/model/oci/tag.py | [
"Apache-2.0"
] | Python | lookup_notifiable_tags_for_legacy_image | null | def lookup_notifiable_tags_for_legacy_image(docker_image_id, storage_uuid, event_name):
"""
Yields any alive Tags found in repositories with an event with the given name registered and
whose legacy Image has the given docker image ID and storage UUID.
"""
event = ExternalNotificationEvent.get(name=e... |
Yields any alive Tags found in repositories with an event with the given name registered and
whose legacy Image has the given docker image ID and storage UUID.
| Yields any alive Tags found in repositories with an event with the given name registered and
whose legacy Image has the given docker image ID and storage UUID. | [
"Yields",
"any",
"alive",
"Tags",
"found",
"in",
"repositories",
"with",
"an",
"event",
"with",
"the",
"given",
"name",
"registered",
"and",
"whose",
"legacy",
"Image",
"has",
"the",
"given",
"docker",
"image",
"ID",
"and",
"storage",
"UUID",
"."
] | def lookup_notifiable_tags_for_legacy_image(docker_image_id, storage_uuid, event_name):
event = ExternalNotificationEvent.get(name=event_name)
images = (
Image.select()
.join(ImageStorage)
.where(Image.docker_image_id == docker_image_id, ImageStorage.uuid == storage_uuid)
)
for i... | [
"def",
"lookup_notifiable_tags_for_legacy_image",
"(",
"docker_image_id",
",",
"storage_uuid",
",",
"event_name",
")",
":",
"event",
"=",
"ExternalNotificationEvent",
".",
"get",
"(",
"name",
"=",
"event_name",
")",
"images",
"=",
"(",
"Image",
".",
"select",
"(",... | Yields any alive Tags found in repositories with an event with the given name registered and
whose legacy Image has the given docker image ID and storage UUID. | [
"Yields",
"any",
"alive",
"Tags",
"found",
"in",
"repositories",
"with",
"an",
"event",
"with",
"the",
"given",
"name",
"registered",
"and",
"whose",
"legacy",
"Image",
"has",
"the",
"given",
"docker",
"image",
"ID",
"and",
"storage",
"UUID",
"."
] | [
"\"\"\"\n Yields any alive Tags found in repositories with an event with the given name registered and\n whose legacy Image has the given docker image ID and storage UUID.\n \"\"\"",
"# Ensure the image is under a repository that supports the event.",
"# If found in a repository with the valid event, y... | [
{
"param": "docker_image_id",
"type": null
},
{
"param": "storage_uuid",
"type": null
},
{
"param": "event_name",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "docker_image_id",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "storage_uuid",
"type": null,
"docstring": null,
"d... |
52bb2570eef863ea274a513de22717986a1d9078 | cuisongliu/quay | data/model/oci/tag.py | [
"Apache-2.0"
] | Python | _filter_has_repository_event | <not_specific> | def _filter_has_repository_event(query, event):
""" Filters the query by ensuring the repositories returned have the given event.
NOTE: This is for legacy support in the old security notification worker and should
be removed once that code is no longer necessary.
"""
return (
qu... | Filters the query by ensuring the repositories returned have the given event.
NOTE: This is for legacy support in the old security notification worker and should
be removed once that code is no longer necessary.
| Filters the query by ensuring the repositories returned have the given event.
NOTE: This is for legacy support in the old security notification worker and should
be removed once that code is no longer necessary. | [
"Filters",
"the",
"query",
"by",
"ensuring",
"the",
"repositories",
"returned",
"have",
"the",
"given",
"event",
".",
"NOTE",
":",
"This",
"is",
"for",
"legacy",
"support",
"in",
"the",
"old",
"security",
"notification",
"worker",
"and",
"should",
"be",
"rem... | def _filter_has_repository_event(query, event):
return (
query.join(Repository)
.join(RepositoryNotification)
.where(RepositoryNotification.event == event)
) | [
"def",
"_filter_has_repository_event",
"(",
"query",
",",
"event",
")",
":",
"return",
"(",
"query",
".",
"join",
"(",
"Repository",
")",
".",
"join",
"(",
"RepositoryNotification",
")",
".",
"where",
"(",
"RepositoryNotification",
".",
"event",
"==",
"event",... | Filters the query by ensuring the repositories returned have the given event. | [
"Filters",
"the",
"query",
"by",
"ensuring",
"the",
"repositories",
"returned",
"have",
"the",
"given",
"event",
"."
] | [
"\"\"\" Filters the query by ensuring the repositories returned have the given event.\n \n NOTE: This is for legacy support in the old security notification worker and should\n be removed once that code is no longer necessary.\n \"\"\""
] | [
{
"param": "query",
"type": null
},
{
"param": "event",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "query",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "event",
"type": null,
"docstring": null,
"docstring_tokens":... |
52bb2570eef863ea274a513de22717986a1d9078 | cuisongliu/quay | data/model/oci/tag.py | [
"Apache-2.0"
] | Python | filter_tags_have_repository_event | <not_specific> | def filter_tags_have_repository_event(query, event):
""" Filters the query by ensuring the tags live in a repository that has the given
event. Also orders the results by lifetime_start_ms.
NOTE: This is for legacy support in the old security notification worker and should
be removed onc... | Filters the query by ensuring the tags live in a repository that has the given
event. Also orders the results by lifetime_start_ms.
NOTE: This is for legacy support in the old security notification worker and should
be removed once that code is no longer necessary.
| Filters the query by ensuring the tags live in a repository that has the given
event. Also orders the results by lifetime_start_ms.
This is for legacy support in the old security notification worker and should
be removed once that code is no longer necessary. | [
"Filters",
"the",
"query",
"by",
"ensuring",
"the",
"tags",
"live",
"in",
"a",
"repository",
"that",
"has",
"the",
"given",
"event",
".",
"Also",
"orders",
"the",
"results",
"by",
"lifetime_start_ms",
".",
"This",
"is",
"for",
"legacy",
"support",
"in",
"t... | def filter_tags_have_repository_event(query, event):
query = _filter_has_repository_event(query, event)
query = query.switch(Tag).order_by(Tag.lifetime_start_ms.desc())
return query | [
"def",
"filter_tags_have_repository_event",
"(",
"query",
",",
"event",
")",
":",
"query",
"=",
"_filter_has_repository_event",
"(",
"query",
",",
"event",
")",
"query",
"=",
"query",
".",
"switch",
"(",
"Tag",
")",
".",
"order_by",
"(",
"Tag",
".",
"lifetim... | Filters the query by ensuring the tags live in a repository that has the given
event. | [
"Filters",
"the",
"query",
"by",
"ensuring",
"the",
"tags",
"live",
"in",
"a",
"repository",
"that",
"has",
"the",
"given",
"event",
"."
] | [
"\"\"\" Filters the query by ensuring the tags live in a repository that has the given\n event. Also orders the results by lifetime_start_ms.\n \n NOTE: This is for legacy support in the old security notification worker and should\n be removed once that code is no longer necessary.\n \"\"... | [
{
"param": "query",
"type": null
},
{
"param": "event",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "query",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "event",
"type": null,
"docstring": null,
"docstring_tokens":... |
52bb2570eef863ea274a513de22717986a1d9078 | cuisongliu/quay | data/model/oci/tag.py | [
"Apache-2.0"
] | Python | find_repository_with_garbage | <not_specific> | def find_repository_with_garbage(limit_to_gc_policy_s):
""" Returns a repository that has garbage (defined as an expired Tag that is past
the repo's namespace's expiration window) or None if none.
"""
expiration_timestamp = get_epoch_timestamp_ms() - (limit_to_gc_policy_s * 1000)
try:
c... | Returns a repository that has garbage (defined as an expired Tag that is past
the repo's namespace's expiration window) or None if none.
| Returns a repository that has garbage (defined as an expired Tag that is past
the repo's namespace's expiration window) or None if none. | [
"Returns",
"a",
"repository",
"that",
"has",
"garbage",
"(",
"defined",
"as",
"an",
"expired",
"Tag",
"that",
"is",
"past",
"the",
"repo",
"'",
"s",
"namespace",
"'",
"s",
"expiration",
"window",
")",
"or",
"None",
"if",
"none",
"."
] | def find_repository_with_garbage(limit_to_gc_policy_s):
expiration_timestamp = get_epoch_timestamp_ms() - (limit_to_gc_policy_s * 1000)
try:
candidates = (
Tag.select(Tag.repository)
.join(Repository)
.join(Namespace, on=(Repository.namespace_user == Namespace.id))
... | [
"def",
"find_repository_with_garbage",
"(",
"limit_to_gc_policy_s",
")",
":",
"expiration_timestamp",
"=",
"get_epoch_timestamp_ms",
"(",
")",
"-",
"(",
"limit_to_gc_policy_s",
"*",
"1000",
")",
"try",
":",
"candidates",
"=",
"(",
"Tag",
".",
"select",
"(",
"Tag",... | Returns a repository that has garbage (defined as an expired Tag that is past
the repo's namespace's expiration window) or None if none. | [
"Returns",
"a",
"repository",
"that",
"has",
"garbage",
"(",
"defined",
"as",
"an",
"expired",
"Tag",
"that",
"is",
"past",
"the",
"repo",
"'",
"s",
"namespace",
"'",
"s",
"expiration",
"window",
")",
"or",
"None",
"if",
"none",
"."
] | [
"\"\"\" Returns a repository that has garbage (defined as an expired Tag that is past\n the repo's namespace's expiration window) or None if none.\n \"\"\""
] | [
{
"param": "limit_to_gc_policy_s",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "limit_to_gc_policy_s",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
3f7f480757f2833e8dc7658aeb6c8d3933eb3cc9 | cuisongliu/quay | data/registry_model/manifestbuilder.py | [
"Apache-2.0"
] | Python | create_manifest_builder | <not_specific> | def create_manifest_builder(repository_ref, storage, legacy_signing_key):
"""
Creates a new manifest builder for populating manifests under the specified repository and
returns it.
Returns None if the builder could not be constructed.
"""
builder_id = str(uuid.uuid4())
builder = _ManifestBu... |
Creates a new manifest builder for populating manifests under the specified repository and
returns it.
Returns None if the builder could not be constructed.
| Creates a new manifest builder for populating manifests under the specified repository and
returns it.
Returns None if the builder could not be constructed. | [
"Creates",
"a",
"new",
"manifest",
"builder",
"for",
"populating",
"manifests",
"under",
"the",
"specified",
"repository",
"and",
"returns",
"it",
".",
"Returns",
"None",
"if",
"the",
"builder",
"could",
"not",
"be",
"constructed",
"."
] | def create_manifest_builder(repository_ref, storage, legacy_signing_key):
builder_id = str(uuid.uuid4())
builder = _ManifestBuilder(
repository_ref, _BuilderState(builder_id, {}, {}, {}, []), storage, legacy_signing_key
)
builder._save_to_session()
return builder | [
"def",
"create_manifest_builder",
"(",
"repository_ref",
",",
"storage",
",",
"legacy_signing_key",
")",
":",
"builder_id",
"=",
"str",
"(",
"uuid",
".",
"uuid4",
"(",
")",
")",
"builder",
"=",
"_ManifestBuilder",
"(",
"repository_ref",
",",
"_BuilderState",
"("... | Creates a new manifest builder for populating manifests under the specified repository and
returns it. | [
"Creates",
"a",
"new",
"manifest",
"builder",
"for",
"populating",
"manifests",
"under",
"the",
"specified",
"repository",
"and",
"returns",
"it",
"."
] | [
"\"\"\"\n Creates a new manifest builder for populating manifests under the specified repository and\n returns it.\n\n Returns None if the builder could not be constructed.\n \"\"\""
] | [
{
"param": "repository_ref",
"type": null
},
{
"param": "storage",
"type": null
},
{
"param": "legacy_signing_key",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "repository_ref",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "storage",
"type": null,
"docstring": null,
"docstri... |
3f7f480757f2833e8dc7658aeb6c8d3933eb3cc9 | cuisongliu/quay | data/registry_model/manifestbuilder.py | [
"Apache-2.0"
] | Python | lookup_manifest_builder | <not_specific> | def lookup_manifest_builder(repository_ref, builder_id, storage, legacy_signing_key):
"""
Looks up the manifest builder with the given ID under the specified repository and returns it or
None if none.
"""
builder_state_tuple = session.get(_SESSION_KEY)
if builder_state_tuple is None:
ret... |
Looks up the manifest builder with the given ID under the specified repository and returns it or
None if none.
| Looks up the manifest builder with the given ID under the specified repository and returns it or
None if none. | [
"Looks",
"up",
"the",
"manifest",
"builder",
"with",
"the",
"given",
"ID",
"under",
"the",
"specified",
"repository",
"and",
"returns",
"it",
"or",
"None",
"if",
"none",
"."
] | def lookup_manifest_builder(repository_ref, builder_id, storage, legacy_signing_key):
builder_state_tuple = session.get(_SESSION_KEY)
if builder_state_tuple is None:
return None
builder_state = _BuilderState(*builder_state_tuple)
if builder_state.builder_id != builder_id:
return None
... | [
"def",
"lookup_manifest_builder",
"(",
"repository_ref",
",",
"builder_id",
",",
"storage",
",",
"legacy_signing_key",
")",
":",
"builder_state_tuple",
"=",
"session",
".",
"get",
"(",
"_SESSION_KEY",
")",
"if",
"builder_state_tuple",
"is",
"None",
":",
"return",
... | Looks up the manifest builder with the given ID under the specified repository and returns it or
None if none. | [
"Looks",
"up",
"the",
"manifest",
"builder",
"with",
"the",
"given",
"ID",
"under",
"the",
"specified",
"repository",
"and",
"returns",
"it",
"or",
"None",
"if",
"none",
"."
] | [
"\"\"\"\n Looks up the manifest builder with the given ID under the specified repository and returns it or\n None if none.\n \"\"\""
] | [
{
"param": "repository_ref",
"type": null
},
{
"param": "builder_id",
"type": null
},
{
"param": "storage",
"type": null
},
{
"param": "legacy_signing_key",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "repository_ref",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "builder_id",
"type": null,
"docstring": null,
"docs... |
3f7f480757f2833e8dc7658aeb6c8d3933eb3cc9 | cuisongliu/quay | data/registry_model/manifestbuilder.py | [
"Apache-2.0"
] | Python | builder_id | <not_specific> | def builder_id(self):
"""
Returns the unique ID for this builder.
"""
return self._builder_state.builder_id |
Returns the unique ID for this builder.
| Returns the unique ID for this builder. | [
"Returns",
"the",
"unique",
"ID",
"for",
"this",
"builder",
"."
] | def builder_id(self):
return self._builder_state.builder_id | [
"def",
"builder_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_builder_state",
".",
"builder_id"
] | Returns the unique ID for this builder. | [
"Returns",
"the",
"unique",
"ID",
"for",
"this",
"builder",
"."
] | [
"\"\"\"\n Returns the unique ID for this builder.\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
3f7f480757f2833e8dc7658aeb6c8d3933eb3cc9 | cuisongliu/quay | data/registry_model/manifestbuilder.py | [
"Apache-2.0"
] | Python | committed_tags | <not_specific> | def committed_tags(self):
"""
Returns the tags committed by this builder, if any.
"""
return [
registry_model.get_repo_tag(self._repository_ref, tag_name, include_legacy_image=True)
for tag_name in self._builder_state.tags.keys()
] |
Returns the tags committed by this builder, if any.
| Returns the tags committed by this builder, if any. | [
"Returns",
"the",
"tags",
"committed",
"by",
"this",
"builder",
"if",
"any",
"."
] | def committed_tags(self):
return [
registry_model.get_repo_tag(self._repository_ref, tag_name, include_legacy_image=True)
for tag_name in self._builder_state.tags.keys()
] | [
"def",
"committed_tags",
"(",
"self",
")",
":",
"return",
"[",
"registry_model",
".",
"get_repo_tag",
"(",
"self",
".",
"_repository_ref",
",",
"tag_name",
",",
"include_legacy_image",
"=",
"True",
")",
"for",
"tag_name",
"in",
"self",
".",
"_builder_state",
"... | Returns the tags committed by this builder, if any. | [
"Returns",
"the",
"tags",
"committed",
"by",
"this",
"builder",
"if",
"any",
"."
] | [
"\"\"\"\n Returns the tags committed by this builder, if any.\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
3f7f480757f2833e8dc7658aeb6c8d3933eb3cc9 | cuisongliu/quay | data/registry_model/manifestbuilder.py | [
"Apache-2.0"
] | Python | start_layer | <not_specific> | def start_layer(
self, layer_id, v1_metadata_string, location_name, calling_user, temp_tag_expiration
):
"""
Starts a new layer with the given ID to be placed into a manifest.
Returns the layer started or None if an error occurred.
"""
# Ensure the repository still e... |
Starts a new layer with the given ID to be placed into a manifest.
Returns the layer started or None if an error occurred.
| Starts a new layer with the given ID to be placed into a manifest.
Returns the layer started or None if an error occurred. | [
"Starts",
"a",
"new",
"layer",
"with",
"the",
"given",
"ID",
"to",
"be",
"placed",
"into",
"a",
"manifest",
".",
"Returns",
"the",
"layer",
"started",
"or",
"None",
"if",
"an",
"error",
"occurred",
"."
] | def start_layer(
self, layer_id, v1_metadata_string, location_name, calling_user, temp_tag_expiration
):
repository = model.repository.lookup_repository(self._repository_ref._db_id)
if repository is None:
return None
namespace_name = repository.namespace_user.username
... | [
"def",
"start_layer",
"(",
"self",
",",
"layer_id",
",",
"v1_metadata_string",
",",
"location_name",
",",
"calling_user",
",",
"temp_tag_expiration",
")",
":",
"repository",
"=",
"model",
".",
"repository",
".",
"lookup_repository",
"(",
"self",
".",
"_repository_... | Starts a new layer with the given ID to be placed into a manifest. | [
"Starts",
"a",
"new",
"layer",
"with",
"the",
"given",
"ID",
"to",
"be",
"placed",
"into",
"a",
"manifest",
"."
] | [
"\"\"\"\n Starts a new layer with the given ID to be placed into a manifest.\n\n Returns the layer started or None if an error occurred.\n \"\"\"",
"# Ensure the repository still exists.",
"# Sanity check that the ID matches the v1 metadata.",
"# Ensure the parent already exists in the re... | [
{
"param": "self",
"type": null
},
{
"param": "layer_id",
"type": null
},
{
"param": "v1_metadata_string",
"type": null
},
{
"param": "location_name",
"type": null
},
{
"param": "calling_user",
"type": null
},
{
"param": "temp_tag_expiration",
"typ... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "layer_id",
"type": null,
"docstring": null,
"docstring_tokens... |
3f7f480757f2833e8dc7658aeb6c8d3933eb3cc9 | cuisongliu/quay | data/registry_model/manifestbuilder.py | [
"Apache-2.0"
] | Python | lookup_layer | <not_specific> | def lookup_layer(self, layer_id):
"""
Returns a layer with the given ID under this builder.
If none exists, returns None.
"""
if layer_id not in self._builder_state.images:
return None
image = model.image.get_image_by_db_id(self._builder_state.images[layer_i... |
Returns a layer with the given ID under this builder.
If none exists, returns None.
| Returns a layer with the given ID under this builder.
If none exists, returns None. | [
"Returns",
"a",
"layer",
"with",
"the",
"given",
"ID",
"under",
"this",
"builder",
".",
"If",
"none",
"exists",
"returns",
"None",
"."
] | def lookup_layer(self, layer_id):
if layer_id not in self._builder_state.images:
return None
image = model.image.get_image_by_db_id(self._builder_state.images[layer_id])
if image is None:
return None
return ManifestLayer(layer_id, image.v1_json_metadata, image.id) | [
"def",
"lookup_layer",
"(",
"self",
",",
"layer_id",
")",
":",
"if",
"layer_id",
"not",
"in",
"self",
".",
"_builder_state",
".",
"images",
":",
"return",
"None",
"image",
"=",
"model",
".",
"image",
".",
"get_image_by_db_id",
"(",
"self",
".",
"_builder_s... | Returns a layer with the given ID under this builder. | [
"Returns",
"a",
"layer",
"with",
"the",
"given",
"ID",
"under",
"this",
"builder",
"."
] | [
"\"\"\"\n Returns a layer with the given ID under this builder.\n\n If none exists, returns None.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "layer_id",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "layer_id",
"type": null,
"docstring": null,
"docstring_tokens... |
3f7f480757f2833e8dc7658aeb6c8d3933eb3cc9 | cuisongliu/quay | data/registry_model/manifestbuilder.py | [
"Apache-2.0"
] | Python | assign_layer_blob | <not_specific> | def assign_layer_blob(self, layer, blob, computed_checksums):
"""
Assigns a blob to a layer.
"""
assert blob
assert not blob.uploading
repo_image = model.image.get_image_by_db_id(layer.db_id)
if repo_image is None:
return None
with db_transac... |
Assigns a blob to a layer.
| Assigns a blob to a layer. | [
"Assigns",
"a",
"blob",
"to",
"a",
"layer",
"."
] | def assign_layer_blob(self, layer, blob, computed_checksums):
assert blob
assert not blob.uploading
repo_image = model.image.get_image_by_db_id(layer.db_id)
if repo_image is None:
return None
with db_transaction():
existing_storage = repo_image.storage
... | [
"def",
"assign_layer_blob",
"(",
"self",
",",
"layer",
",",
"blob",
",",
"computed_checksums",
")",
":",
"assert",
"blob",
"assert",
"not",
"blob",
".",
"uploading",
"repo_image",
"=",
"model",
".",
"image",
".",
"get_image_by_db_id",
"(",
"layer",
".",
"db_... | Assigns a blob to a layer. | [
"Assigns",
"a",
"blob",
"to",
"a",
"layer",
"."
] | [
"\"\"\"\n Assigns a blob to a layer.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "layer",
"type": null
},
{
"param": "blob",
"type": null
},
{
"param": "computed_checksums",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "layer",
"type": null,
"docstring": null,
"docstring_tokens": ... |
3f7f480757f2833e8dc7658aeb6c8d3933eb3cc9 | cuisongliu/quay | data/registry_model/manifestbuilder.py | [
"Apache-2.0"
] | Python | validate_layer_checksum | <not_specific> | def validate_layer_checksum(self, layer, checksum):
"""
Returns whether the checksum for a layer matches that specified.
"""
return checksum in self.get_layer_checksums(layer) |
Returns whether the checksum for a layer matches that specified.
| Returns whether the checksum for a layer matches that specified. | [
"Returns",
"whether",
"the",
"checksum",
"for",
"a",
"layer",
"matches",
"that",
"specified",
"."
] | def validate_layer_checksum(self, layer, checksum):
return checksum in self.get_layer_checksums(layer) | [
"def",
"validate_layer_checksum",
"(",
"self",
",",
"layer",
",",
"checksum",
")",
":",
"return",
"checksum",
"in",
"self",
".",
"get_layer_checksums",
"(",
"layer",
")"
] | Returns whether the checksum for a layer matches that specified. | [
"Returns",
"whether",
"the",
"checksum",
"for",
"a",
"layer",
"matches",
"that",
"specified",
"."
] | [
"\"\"\"\n Returns whether the checksum for a layer matches that specified.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "layer",
"type": null
},
{
"param": "checksum",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "layer",
"type": null,
"docstring": null,
"docstring_tokens": ... |
3f7f480757f2833e8dc7658aeb6c8d3933eb3cc9 | cuisongliu/quay | data/registry_model/manifestbuilder.py | [
"Apache-2.0"
] | Python | save_precomputed_checksum | null | def save_precomputed_checksum(self, layer, checksum):
"""
Saves a precomputed checksum for a layer.
"""
checksums = self._builder_state.checksums.get(layer.layer_id) or []
checksums.append(checksum)
self._builder_state.checksums[layer.layer_id] = checksums
self._s... |
Saves a precomputed checksum for a layer.
| Saves a precomputed checksum for a layer. | [
"Saves",
"a",
"precomputed",
"checksum",
"for",
"a",
"layer",
"."
] | def save_precomputed_checksum(self, layer, checksum):
checksums = self._builder_state.checksums.get(layer.layer_id) or []
checksums.append(checksum)
self._builder_state.checksums[layer.layer_id] = checksums
self._save_to_session() | [
"def",
"save_precomputed_checksum",
"(",
"self",
",",
"layer",
",",
"checksum",
")",
":",
"checksums",
"=",
"self",
".",
"_builder_state",
".",
"checksums",
".",
"get",
"(",
"layer",
".",
"layer_id",
")",
"or",
"[",
"]",
"checksums",
".",
"append",
"(",
... | Saves a precomputed checksum for a layer. | [
"Saves",
"a",
"precomputed",
"checksum",
"for",
"a",
"layer",
"."
] | [
"\"\"\"\n Saves a precomputed checksum for a layer.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "layer",
"type": null
},
{
"param": "checksum",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "layer",
"type": null,
"docstring": null,
"docstring_tokens": ... |
3f7f480757f2833e8dc7658aeb6c8d3933eb3cc9 | cuisongliu/quay | data/registry_model/manifestbuilder.py | [
"Apache-2.0"
] | Python | commit_tag_and_manifest | <not_specific> | def commit_tag_and_manifest(self, tag_name, layer):
"""
Commits a new tag + manifest for that tag to the repository with the given name, pointing to
the given layer.
"""
legacy_image = registry_model.get_legacy_image(self._repository_ref, layer.layer_id)
if legacy_image i... |
Commits a new tag + manifest for that tag to the repository with the given name, pointing to
the given layer.
| Commits a new tag + manifest for that tag to the repository with the given name, pointing to
the given layer. | [
"Commits",
"a",
"new",
"tag",
"+",
"manifest",
"for",
"that",
"tag",
"to",
"the",
"repository",
"with",
"the",
"given",
"name",
"pointing",
"to",
"the",
"given",
"layer",
"."
] | def commit_tag_and_manifest(self, tag_name, layer):
legacy_image = registry_model.get_legacy_image(self._repository_ref, layer.layer_id)
if legacy_image is None:
return None
tag = registry_model.retarget_tag(
self._repository_ref, tag_name, legacy_image, self._storage, se... | [
"def",
"commit_tag_and_manifest",
"(",
"self",
",",
"tag_name",
",",
"layer",
")",
":",
"legacy_image",
"=",
"registry_model",
".",
"get_legacy_image",
"(",
"self",
".",
"_repository_ref",
",",
"layer",
".",
"layer_id",
")",
"if",
"legacy_image",
"is",
"None",
... | Commits a new tag + manifest for that tag to the repository with the given name, pointing to
the given layer. | [
"Commits",
"a",
"new",
"tag",
"+",
"manifest",
"for",
"that",
"tag",
"to",
"the",
"repository",
"with",
"the",
"given",
"name",
"pointing",
"to",
"the",
"given",
"layer",
"."
] | [
"\"\"\"\n Commits a new tag + manifest for that tag to the repository with the given name, pointing to\n the given layer.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "tag_name",
"type": null
},
{
"param": "layer",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "tag_name",
"type": null,
"docstring": null,
"docstring_tokens... |
3f7f480757f2833e8dc7658aeb6c8d3933eb3cc9 | cuisongliu/quay | data/registry_model/manifestbuilder.py | [
"Apache-2.0"
] | Python | done | null | def done(self):
"""
Marks the manifest builder as complete and disposes of any state.
This call is optional and it is expected manifest builders will eventually time out if
unused for an extended period of time.
"""
temp_storages = self._builder_state.temp_storages
... |
Marks the manifest builder as complete and disposes of any state.
This call is optional and it is expected manifest builders will eventually time out if
unused for an extended period of time.
| Marks the manifest builder as complete and disposes of any state.
This call is optional and it is expected manifest builders will eventually time out if
unused for an extended period of time. | [
"Marks",
"the",
"manifest",
"builder",
"as",
"complete",
"and",
"disposes",
"of",
"any",
"state",
".",
"This",
"call",
"is",
"optional",
"and",
"it",
"is",
"expected",
"manifest",
"builders",
"will",
"eventually",
"time",
"out",
"if",
"unused",
"for",
"an",
... | def done(self):
temp_storages = self._builder_state.temp_storages
for storage_id in temp_storages:
try:
storage = ImageStorage.get(id=storage_id)
if storage.uploading and storage.content_checksum != EMPTY_LAYER_BLOB_DIGEST:
ImageStoragePlac... | [
"def",
"done",
"(",
"self",
")",
":",
"temp_storages",
"=",
"self",
".",
"_builder_state",
".",
"temp_storages",
"for",
"storage_id",
"in",
"temp_storages",
":",
"try",
":",
"storage",
"=",
"ImageStorage",
".",
"get",
"(",
"id",
"=",
"storage_id",
")",
"if... | Marks the manifest builder as complete and disposes of any state. | [
"Marks",
"the",
"manifest",
"builder",
"as",
"complete",
"and",
"disposes",
"of",
"any",
"state",
"."
] | [
"\"\"\"\n Marks the manifest builder as complete and disposes of any state.\n\n This call is optional and it is expected manifest builders will eventually time out if\n unused for an extended period of time.\n \"\"\"",
"# Delete all the placements pointing to the storage.",
"# Delete... | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
cf00e80cb1f55a377f88caa3cf43fd2b560c21f9 | cuisongliu/quay | test/registry_tests.py | [
"Apache-2.0"
] | Python | _get_expected_code | <not_specific> | def _get_expected_code(expected_failure, version, success_status_code):
"""
Returns the HTTP status code for the expected failure under the specified protocol version (1 or
2).
If none, returns the success status code.
"""
if not expected_failure:
return success_status_code
return ... |
Returns the HTTP status code for the expected failure under the specified protocol version (1 or
2).
If none, returns the success status code.
| Returns the HTTP status code for the expected failure under the specified protocol version (1 or
2).
If none, returns the success status code. | [
"Returns",
"the",
"HTTP",
"status",
"code",
"for",
"the",
"expected",
"failure",
"under",
"the",
"specified",
"protocol",
"version",
"(",
"1",
"or",
"2",
")",
".",
"If",
"none",
"returns",
"the",
"success",
"status",
"code",
"."
] | def _get_expected_code(expected_failure, version, success_status_code):
if not expected_failure:
return success_status_code
return expected_failure[version] | [
"def",
"_get_expected_code",
"(",
"expected_failure",
",",
"version",
",",
"success_status_code",
")",
":",
"if",
"not",
"expected_failure",
":",
"return",
"success_status_code",
"return",
"expected_failure",
"[",
"version",
"]"
] | Returns the HTTP status code for the expected failure under the specified protocol version (1 or
2). | [
"Returns",
"the",
"HTTP",
"status",
"code",
"for",
"the",
"expected",
"failure",
"under",
"the",
"specified",
"protocol",
"version",
"(",
"1",
"or",
"2",
")",
"."
] | [
"\"\"\"\n Returns the HTTP status code for the expected failure under the specified protocol version (1 or\n 2).\n\n If none, returns the success status code.\n \"\"\""
] | [
{
"param": "expected_failure",
"type": null
},
{
"param": "version",
"type": null
},
{
"param": "success_status_code",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "expected_failure",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "version",
"type": null,
"docstring": null,
"docst... |
a958d4425742fbc86fa487c3d502d68f9c1105eb | cuisongliu/quay | util/repomirror/skopeomirror.py | [
"Apache-2.0"
] | Python | tags | <not_specific> | def tags(
self,
repository,
rule_value,
username=None,
password=None,
tls_verify=True,
proxy=None,
verbose_logs=False,
):
"""
Unless a specific tag is known, 'skopeo inspect' won't work.
Here first 'latest' is checked and then ... |
Unless a specific tag is known, 'skopeo inspect' won't work.
Here first 'latest' is checked and then the tag expression, split at commas, is each checked
until one works.
| Unless a specific tag is known, 'skopeo inspect' won't work.
Here first 'latest' is checked and then the tag expression, split at commas, is each checked
until one works. | [
"Unless",
"a",
"specific",
"tag",
"is",
"known",
"'",
"skopeo",
"inspect",
"'",
"won",
"'",
"t",
"work",
".",
"Here",
"first",
"'",
"latest",
"'",
"is",
"checked",
"and",
"then",
"the",
"tag",
"expression",
"split",
"at",
"commas",
"is",
"each",
"check... | def tags(
self,
repository,
rule_value,
username=None,
password=None,
tls_verify=True,
proxy=None,
verbose_logs=False,
):
args = ["/usr/bin/skopeo"]
if verbose_logs:
args = args + ["--debug"]
args = args + ["inspect"... | [
"def",
"tags",
"(",
"self",
",",
"repository",
",",
"rule_value",
",",
"username",
"=",
"None",
",",
"password",
"=",
"None",
",",
"tls_verify",
"=",
"True",
",",
"proxy",
"=",
"None",
",",
"verbose_logs",
"=",
"False",
",",
")",
":",
"args",
"=",
"[... | Unless a specific tag is known, 'skopeo inspect' won't work. | [
"Unless",
"a",
"specific",
"tag",
"is",
"known",
"'",
"skopeo",
"inspect",
"'",
"won",
"'",
"t",
"work",
"."
] | [
"\"\"\"\n Unless a specific tag is known, 'skopeo inspect' won't work.\n\n Here first 'latest' is checked and then the tag expression, split at commas, is each checked\n until one works.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "repository",
"type": null
},
{
"param": "rule_value",
"type": null
},
{
"param": "username",
"type": null
},
{
"param": "password",
"type": null
},
{
"param": "tls_verify",
"type": null
},
{
"p... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "repository",
"type": null,
"docstring": null,
"docstring_toke... |
d0666060fa077d49c9d8dbf5e1f18972b5b24bae | samn33/qlazy | qlazy/QState.py | [
"Apache-2.0"
] | Python | reset | null | def reset(self, qid=[]):
"""
reset to |00..0> state.
Parameters
----------
qid : list, default - qubit id's list for all of the qubits
qubit id's list to reset.
Notes
-----
If 'qid' is set, specified qubits are reset after
measurement... |
reset to |00..0> state.
Parameters
----------
qid : list, default - qubit id's list for all of the qubits
qubit id's list to reset.
Notes
-----
If 'qid' is set, specified qubits are reset after
measurement. So if the specified qubits are ent... |
qid : list, default - qubit id's list for all of the qubits
qubit id's list to reset.
Notes
If 'qid' is set, specified qubits are reset after
measurement. So if the specified qubits are entangled with the
remaining qubits, output quantum state is probabilistic. If no
qubits are set, all qubits are zero reset. | [
"qid",
":",
"list",
"default",
"-",
"qubit",
"id",
"'",
"s",
"list",
"for",
"all",
"of",
"the",
"qubits",
"qubit",
"id",
"'",
"s",
"list",
"to",
"reset",
".",
"Notes",
"If",
"'",
"qid",
"'",
"is",
"set",
"specified",
"qubits",
"are",
"reset",
"afte... | def reset(self, qid=[]):
qstate_reset(self, qid=qid) | [
"def",
"reset",
"(",
"self",
",",
"qid",
"=",
"[",
"]",
")",
":",
"qstate_reset",
"(",
"self",
",",
"qid",
"=",
"qid",
")"
] | reset to |00..0> state. | [
"reset",
"to",
"|00",
"..",
"0",
">",
"state",
"."
] | [
"\"\"\"\n reset to |00..0> state.\n\n Parameters\n ----------\n qid : list, default - qubit id's list for all of the qubits\n qubit id's list to reset.\n\n Notes\n -----\n If 'qid' is set, specified qubits are reset after\n measurement. So if the sp... | [
{
"param": "self",
"type": null
},
{
"param": "qid",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "qid",
"type": null,
"docstring": null,
"docstring_tokens": []... |
d0666060fa077d49c9d8dbf5e1f18972b5b24bae | samn33/qlazy | qlazy/QState.py | [
"Apache-2.0"
] | Python | free_all | null | def free_all(cls, *qstates):
"""
free memory of the all quantum states.
Parameters
----------
qstates : instance of QState,instance of QState,...
set of QState instances
Returns
-------
None
"""
warnings.warn("No need to call... |
free memory of the all quantum states.
Parameters
----------
qstates : instance of QState,instance of QState,...
set of QState instances
Returns
-------
None
| free memory of the all quantum states.
Parameters
qstates : instance of QState,instance of QState,
set of QState instances
Returns
None | [
"free",
"memory",
"of",
"the",
"all",
"quantum",
"states",
".",
"Parameters",
"qstates",
":",
"instance",
"of",
"QState",
"instance",
"of",
"QState",
"set",
"of",
"QState",
"instances",
"Returns",
"None"
] | def free_all(cls, *qstates):
warnings.warn("No need to call 'free_all' method because free automatically, or you can use class method 'del_all' to free memory explicitly.") | [
"def",
"free_all",
"(",
"cls",
",",
"*",
"qstates",
")",
":",
"warnings",
".",
"warn",
"(",
"\"No need to call 'free_all' method because free automatically, or you can use class method 'del_all' to free memory explicitly.\"",
")"
] | free memory of the all quantum states. | [
"free",
"memory",
"of",
"the",
"all",
"quantum",
"states",
"."
] | [
"\"\"\"\n free memory of the all quantum states.\n\n Parameters\n ----------\n qstates : instance of QState,instance of QState,...\n set of QState instances\n\n Returns\n -------\n None\n\n \"\"\""
] | [
{
"param": "cls",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cls",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
d0666060fa077d49c9d8dbf5e1f18972b5b24bae | samn33/qlazy | qlazy/QState.py | [
"Apache-2.0"
] | Python | del_all | null | def del_all(cls, *qstates):
"""
free memory of the all quantum states.
Parameters
----------
qstates : instance of QState,instance of QState,...
set of QState instances
Returns
-------
None
"""
for qs in qstates:
... |
free memory of the all quantum states.
Parameters
----------
qstates : instance of QState,instance of QState,...
set of QState instances
Returns
-------
None
| free memory of the all quantum states.
Parameters
qstates : instance of QState,instance of QState,
set of QState instances
Returns
None | [
"free",
"memory",
"of",
"the",
"all",
"quantum",
"states",
".",
"Parameters",
"qstates",
":",
"instance",
"of",
"QState",
"instance",
"of",
"QState",
"set",
"of",
"QState",
"instances",
"Returns",
"None"
] | def del_all(cls, *qstates):
for qs in qstates:
if type(qs) is list or type(qs) is tuple:
cls.del_all(*qs)
elif type(qs) is QState:
del qs
else:
raise QState_Error_FreeAll() | [
"def",
"del_all",
"(",
"cls",
",",
"*",
"qstates",
")",
":",
"for",
"qs",
"in",
"qstates",
":",
"if",
"type",
"(",
"qs",
")",
"is",
"list",
"or",
"type",
"(",
"qs",
")",
"is",
"tuple",
":",
"cls",
".",
"del_all",
"(",
"*",
"qs",
")",
"elif",
... | free memory of the all quantum states. | [
"free",
"memory",
"of",
"the",
"all",
"quantum",
"states",
"."
] | [
"\"\"\"\n free memory of the all quantum states.\n\n Parameters\n ----------\n qstates : instance of QState,instance of QState,...\n set of QState instances\n\n Returns\n -------\n None\n\n \"\"\""
] | [
{
"param": "cls",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cls",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
d0666060fa077d49c9d8dbf5e1f18972b5b24bae | samn33/qlazy | qlazy/QState.py | [
"Apache-2.0"
] | Python | partial | <not_specific> | def partial(self, qid=None):
"""
get the partial quantum state.
Parameters
----------
qid : list of int, default - list of all of the qubit id
qubit id's list to get as a partial quantum
system.
Returns
-------
qs : instance of QS... |
get the partial quantum state.
Parameters
----------
qid : list of int, default - list of all of the qubit id
qubit id's list to get as a partial quantum
system.
Returns
-------
qs : instance of QState
partial quantum state.
... | get the partial quantum state.
Parameters
qid : list of int, default - list of all of the qubit id
qubit id's list to get as a partial quantum
system.
Returns
qs : instance of QState
partial quantum state.
Notes
If 'qid' is set, specified partial quantum system are got
after remaining system are measured. So if th... | [
"get",
"the",
"partial",
"quantum",
"state",
".",
"Parameters",
"qid",
":",
"list",
"of",
"int",
"default",
"-",
"list",
"of",
"all",
"of",
"the",
"qubit",
"id",
"qubit",
"id",
"'",
"s",
"list",
"to",
"get",
"as",
"a",
"partial",
"quantum",
"system",
... | def partial(self, qid=None):
vec = self.get_amp(qid)
qs = QState(vector=vec)
return qs | [
"def",
"partial",
"(",
"self",
",",
"qid",
"=",
"None",
")",
":",
"vec",
"=",
"self",
".",
"get_amp",
"(",
"qid",
")",
"qs",
"=",
"QState",
"(",
"vector",
"=",
"vec",
")",
"return",
"qs"
] | get the partial quantum state. | [
"get",
"the",
"partial",
"quantum",
"state",
"."
] | [
"\"\"\"\n get the partial quantum state.\n\n Parameters\n ----------\n qid : list of int, default - list of all of the qubit id\n qubit id's list to get as a partial quantum\n system.\n\n Returns\n -------\n qs : instance of QState\n ... | [
{
"param": "self",
"type": null
},
{
"param": "qid",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "qid",
"type": null,
"docstring": null,
"docstring_tokens": []... |
d0666060fa077d49c9d8dbf5e1f18972b5b24bae | samn33/qlazy | qlazy/QState.py | [
"Apache-2.0"
] | Python | show | null | def show(self, qid=None, nonzero=False):
"""
show the quantum state
(elements of the state vector and probabilities).
Parameters
----------
qid : list of int, default - list of all of the qubit id
qubit id's list to show.
nonzero : bool, default Fals... |
show the quantum state
(elements of the state vector and probabilities).
Parameters
----------
qid : list of int, default - list of all of the qubit id
qubit id's list to show.
nonzero : bool, default False
if True, only non-zero amplitudes are ... | show the quantum state
(elements of the state vector and probabilities).
Parameters
qid : list of int, default - list of all of the qubit id
qubit id's list to show.
nonzero : bool, default False
if True, only non-zero amplitudes are printed.
Returns
None
Notes
If 'qid' is set, it shows the elements of quantum st... | [
"show",
"the",
"quantum",
"state",
"(",
"elements",
"of",
"the",
"state",
"vector",
"and",
"probabilities",
")",
".",
"Parameters",
"qid",
":",
"list",
"of",
"int",
"default",
"-",
"list",
"of",
"all",
"of",
"the",
"qubit",
"id",
"qubit",
"id",
"'",
"s... | def show(self, qid=None, nonzero=False):
qstate_print(self, qid, nonzero) | [
"def",
"show",
"(",
"self",
",",
"qid",
"=",
"None",
",",
"nonzero",
"=",
"False",
")",
":",
"qstate_print",
"(",
"self",
",",
"qid",
",",
"nonzero",
")"
] | show the quantum state
(elements of the state vector and probabilities). | [
"show",
"the",
"quantum",
"state",
"(",
"elements",
"of",
"the",
"state",
"vector",
"and",
"probabilities",
")",
"."
] | [
"\"\"\"\n show the quantum state \n (elements of the state vector and probabilities).\n\n Parameters\n ----------\n qid : list of int, default - list of all of the qubit id\n qubit id's list to show.\n nonzero : bool, default False\n if True, only non-... | [
{
"param": "self",
"type": null
},
{
"param": "qid",
"type": null
},
{
"param": "nonzero",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "qid",
"type": null,
"docstring": null,
"docstring_tokens": []... |
d0666060fa077d49c9d8dbf5e1f18972b5b24bae | samn33/qlazy | qlazy/QState.py | [
"Apache-2.0"
] | Python | inpro | <not_specific> | def inpro(self, qstate, qid=[]):
"""
get the inner product with quantum state.
Parameters
----------
qstate : instance of QState
one of the two quantum state.
qid : list of int, default - list of all of the qubit id
qubit id's list.
Retur... |
get the inner product with quantum state.
Parameters
----------
qstate : instance of QState
one of the two quantum state.
qid : list of int, default - list of all of the qubit id
qubit id's list.
Returns
-------
inp : complex
... | get the inner product with quantum state.
Parameters
qstate : instance of QState
one of the two quantum state.
qid : list of int, default - list of all of the qubit id
qubit id's list.
Returns
inp : complex
inner produt ().
Notes
If 'qid' is set, you can get the inner product for partial
quantum state. If the spec... | [
"get",
"the",
"inner",
"product",
"with",
"quantum",
"state",
".",
"Parameters",
"qstate",
":",
"instance",
"of",
"QState",
"one",
"of",
"the",
"two",
"quantum",
"state",
".",
"qid",
":",
"list",
"of",
"int",
"default",
"-",
"list",
"of",
"all",
"of",
... | def inpro(self, qstate, qid=[]):
if qid == []:
inp = qstate_inner_product(self, qstate)
else:
qs_0 = self.partial(qid=qid)
qs_1 = qstate.partial(qid=qid)
inp = qstate_inner_product(qs_0, qs_1)
return inp | [
"def",
"inpro",
"(",
"self",
",",
"qstate",
",",
"qid",
"=",
"[",
"]",
")",
":",
"if",
"qid",
"==",
"[",
"]",
":",
"inp",
"=",
"qstate_inner_product",
"(",
"self",
",",
"qstate",
")",
"else",
":",
"qs_0",
"=",
"self",
".",
"partial",
"(",
"qid",
... | get the inner product with quantum state. | [
"get",
"the",
"inner",
"product",
"with",
"quantum",
"state",
"."
] | [
"\"\"\"\n get the inner product with quantum state.\n\n Parameters\n ----------\n qstate : instance of QState\n one of the two quantum state.\n qid : list of int, default - list of all of the qubit id\n qubit id's list.\n\n Returns\n -------\n ... | [
{
"param": "self",
"type": null
},
{
"param": "qstate",
"type": null
},
{
"param": "qid",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "qstate",
"type": null,
"docstring": null,
"docstring_tokens":... |
d0666060fa077d49c9d8dbf5e1f18972b5b24bae | samn33/qlazy | qlazy/QState.py | [
"Apache-2.0"
] | Python | fidelity | <not_specific> | def fidelity(self, qstate, qid=[]):
"""
get the fidelity with quantum state.
Parameters
----------
qstate : instance of QState
one of the two quantum state.
qid : list of int
qubit id's list.
Returns
-------
fid : float
... |
get the fidelity with quantum state.
Parameters
----------
qstate : instance of QState
one of the two quantum state.
qid : list of int
qubit id's list.
Returns
-------
fid : float
fidelity of two quantum states. absol... | get the fidelity with quantum state.
Parameters
qstate : instance of QState
one of the two quantum state.
qid : list of int
qubit id's list.
Returns
fid : float
fidelity of two quantum states. absolute value of the
inner product of two quantum states.
Notes
If 'qid' is set, you can get the fidelity for partial qua... | [
"get",
"the",
"fidelity",
"with",
"quantum",
"state",
".",
"Parameters",
"qstate",
":",
"instance",
"of",
"QState",
"one",
"of",
"the",
"two",
"quantum",
"state",
".",
"qid",
":",
"list",
"of",
"int",
"qubit",
"id",
"'",
"s",
"list",
".",
"Returns",
"f... | def fidelity(self, qstate, qid=[]):
return abs(self.inpro(qstate, qid=qid)) | [
"def",
"fidelity",
"(",
"self",
",",
"qstate",
",",
"qid",
"=",
"[",
"]",
")",
":",
"return",
"abs",
"(",
"self",
".",
"inpro",
"(",
"qstate",
",",
"qid",
"=",
"qid",
")",
")"
] | get the fidelity with quantum state. | [
"get",
"the",
"fidelity",
"with",
"quantum",
"state",
"."
] | [
"\"\"\"\n get the fidelity with quantum state.\n\n Parameters\n ----------\n qstate : instance of QState\n one of the two quantum state.\n qid : list of int\n qubit id's list.\n\n Returns\n -------\n fid : float\n fidelity of t... | [
{
"param": "self",
"type": null
},
{
"param": "qstate",
"type": null
},
{
"param": "qid",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "qstate",
"type": null,
"docstring": null,
"docstring_tokens":... |
d0666060fa077d49c9d8dbf5e1f18972b5b24bae | samn33/qlazy | qlazy/QState.py | [
"Apache-2.0"
] | Python | operate | <not_specific> | def operate(self, pp=None, ctrl=None):
"""
operate unitary operator to quantum state.
Parameters
----------
pp : instance of PauliProduct
pauli product to operate
ctrl : int
contoroll qubit id for controlled pauli product
Returns
... |
operate unitary operator to quantum state.
Parameters
----------
pp : instance of PauliProduct
pauli product to operate
ctrl : int
contoroll qubit id for controlled pauli product
Returns
-------
self : instance of QState
... | operate unitary operator to quantum state.
Parameters
pp : instance of PauliProduct
pauli product to operate
ctrl : int
contoroll qubit id for controlled pauli product
Returns
self : instance of QState
quantum state after operation | [
"operate",
"unitary",
"operator",
"to",
"quantum",
"state",
".",
"Parameters",
"pp",
":",
"instance",
"of",
"PauliProduct",
"pauli",
"product",
"to",
"operate",
"ctrl",
":",
"int",
"contoroll",
"qubit",
"id",
"for",
"controlled",
"pauli",
"product",
"Returns",
... | def operate(self, pp=None, ctrl=None):
pauli_list = pp.pauli_list
qid = pp.qid
if ctrl is None:
for q, pauli in zip(qid, pauli_list):
if pauli == 'X':
self.x(q)
elif pauli == 'Y':
self.y(q)
elif p... | [
"def",
"operate",
"(",
"self",
",",
"pp",
"=",
"None",
",",
"ctrl",
"=",
"None",
")",
":",
"pauli_list",
"=",
"pp",
".",
"pauli_list",
"qid",
"=",
"pp",
".",
"qid",
"if",
"ctrl",
"is",
"None",
":",
"for",
"q",
",",
"pauli",
"in",
"zip",
"(",
"q... | operate unitary operator to quantum state. | [
"operate",
"unitary",
"operator",
"to",
"quantum",
"state",
"."
] | [
"\"\"\"\n operate unitary operator to quantum state.\n\n Parameters\n ----------\n pp : instance of PauliProduct\n pauli product to operate\n ctrl : int\n contoroll qubit id for controlled pauli product\n\n Returns\n -------\n self : inst... | [
{
"param": "self",
"type": null
},
{
"param": "pp",
"type": null
},
{
"param": "ctrl",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "pp",
"type": null,
"docstring": null,
"docstring_tokens": [],... |
f92b82e860914d73d8b4fdcf1ad34bdb317de926 | samn33/qlazy | qlazy/Stabilizer.py | [
"Apache-2.0"
] | Python | free_all | null | def free_all(cls, *stabs):
"""
free memory of the all stabilizer.
Parameters
----------
stabs : instance of Stabilizer,instance of Stabilizer,...
set of Stabilizer instances
Returns
-------
None
"""
warnings.warn("No need to ... |
free memory of the all stabilizer.
Parameters
----------
stabs : instance of Stabilizer,instance of Stabilizer,...
set of Stabilizer instances
Returns
-------
None
| free memory of the all stabilizer.
Parameters
stabs : instance of Stabilizer,instance of Stabilizer,
set of Stabilizer instances
Returns
None | [
"free",
"memory",
"of",
"the",
"all",
"stabilizer",
".",
"Parameters",
"stabs",
":",
"instance",
"of",
"Stabilizer",
"instance",
"of",
"Stabilizer",
"set",
"of",
"Stabilizer",
"instances",
"Returns",
"None"
] | def free_all(cls, *stabs):
warnings.warn("No need to call 'free_all' method because free automatically, or you can use class method 'del_all' to free memory explicitly.") | [
"def",
"free_all",
"(",
"cls",
",",
"*",
"stabs",
")",
":",
"warnings",
".",
"warn",
"(",
"\"No need to call 'free_all' method because free automatically, or you can use class method 'del_all' to free memory explicitly.\"",
")"
] | free memory of the all stabilizer. | [
"free",
"memory",
"of",
"the",
"all",
"stabilizer",
"."
] | [
"\"\"\"\n free memory of the all stabilizer.\n\n Parameters\n ----------\n stabs : instance of Stabilizer,instance of Stabilizer,...\n set of Stabilizer instances\n\n Returns\n -------\n None\n\n \"\"\""
] | [
{
"param": "cls",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cls",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
f92b82e860914d73d8b4fdcf1ad34bdb317de926 | samn33/qlazy | qlazy/Stabilizer.py | [
"Apache-2.0"
] | Python | del_all | null | def del_all(cls, *stabs):
"""
free memory of the all stabilizer.
Parameters
----------
stabs : instance of Stabilizer,instance of Stabilizer,...
set of Stabilizer instances
Returns
-------
None
"""
for sb in stabs:
... |
free memory of the all stabilizer.
Parameters
----------
stabs : instance of Stabilizer,instance of Stabilizer,...
set of Stabilizer instances
Returns
-------
None
| free memory of the all stabilizer.
Parameters
stabs : instance of Stabilizer,instance of Stabilizer,
set of Stabilizer instances
Returns
None | [
"free",
"memory",
"of",
"the",
"all",
"stabilizer",
".",
"Parameters",
"stabs",
":",
"instance",
"of",
"Stabilizer",
"instance",
"of",
"Stabilizer",
"set",
"of",
"Stabilizer",
"instances",
"Returns",
"None"
] | def del_all(cls, *stabs):
for sb in stabs:
if type(sb) is list or type(sb) is tuple:
cls.del_all(*sb)
elif type(sb) is Stabilizer:
del sb
else:
raise Stabilizer_Error_FreeAll() | [
"def",
"del_all",
"(",
"cls",
",",
"*",
"stabs",
")",
":",
"for",
"sb",
"in",
"stabs",
":",
"if",
"type",
"(",
"sb",
")",
"is",
"list",
"or",
"type",
"(",
"sb",
")",
"is",
"tuple",
":",
"cls",
".",
"del_all",
"(",
"*",
"sb",
")",
"elif",
"typ... | free memory of the all stabilizer. | [
"free",
"memory",
"of",
"the",
"all",
"stabilizer",
"."
] | [
"\"\"\"\n free memory of the all stabilizer.\n\n Parameters\n ----------\n stabs : instance of Stabilizer,instance of Stabilizer,...\n set of Stabilizer instances\n\n Returns\n -------\n None\n\n \"\"\""
] | [
{
"param": "cls",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cls",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
263e0f020ab74a6cce7bd127694cff680b90c970 | samn33/qlazy | qlazy/DensOp.py | [
"Apache-2.0"
] | Python | mix | <not_specific> | def mix(cls, densop=[], prob=[]):
"""
linear sum of the density operators.
Parameters
----------
densop : list of instances of DensOp
densitiy operators.
prob : list of float
probabilities (coefficients of the linear sum).
"""
N =... |
linear sum of the density operators.
Parameters
----------
densop : list of instances of DensOp
densitiy operators.
prob : list of float
probabilities (coefficients of the linear sum).
| linear sum of the density operators.
Parameters
densop : list of instances of DensOp
densitiy operators.
prob : list of float
probabilities (coefficients of the linear sum). | [
"linear",
"sum",
"of",
"the",
"density",
"operators",
".",
"Parameters",
"densop",
":",
"list",
"of",
"instances",
"of",
"DensOp",
"densitiy",
"operators",
".",
"prob",
":",
"list",
"of",
"float",
"probabilities",
"(",
"coefficients",
"of",
"the",
"linear",
... | def mix(cls, densop=[], prob=[]):
N = len(densop)
if sum(prob) != 1.0:
s = sum(prob)
prob = [p/s for p in prob]
de_out = densop[0].clone()
de_out.mul(factor=prob[0])
for i in range(1,len(densop)):
de_tmp = densop[i].clone()
de_tmp.m... | [
"def",
"mix",
"(",
"cls",
",",
"densop",
"=",
"[",
"]",
",",
"prob",
"=",
"[",
"]",
")",
":",
"N",
"=",
"len",
"(",
"densop",
")",
"if",
"sum",
"(",
"prob",
")",
"!=",
"1.0",
":",
"s",
"=",
"sum",
"(",
"prob",
")",
"prob",
"=",
"[",
"p",
... | linear sum of the density operators. | [
"linear",
"sum",
"of",
"the",
"density",
"operators",
"."
] | [
"\"\"\"\n linear sum of the density operators.\n\n Parameters\n ----------\n densop : list of instances of DensOp\n densitiy operators.\n prob : list of float\n probabilities (coefficients of the linear sum).\n\n \"\"\""
] | [
{
"param": "cls",
"type": null
},
{
"param": "densop",
"type": null
},
{
"param": "prob",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cls",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "densop",
"type": null,
"docstring": null,
"docstring_tokens": ... |
263e0f020ab74a6cce7bd127694cff680b90c970 | samn33/qlazy | qlazy/DensOp.py | [
"Apache-2.0"
] | Python | free_all | null | def free_all(cls, *densops):
"""
free memory of the all density operators.
Parameters
----------
densops : instance of DensOp,instance of DensOp,...
set of DensOp instances
Returns
-------
None
"""
warnings.warn("No need to c... |
free memory of the all density operators.
Parameters
----------
densops : instance of DensOp,instance of DensOp,...
set of DensOp instances
Returns
-------
None
| free memory of the all density operators.
Parameters
densops : instance of DensOp,instance of DensOp,
set of DensOp instances
Returns
None | [
"free",
"memory",
"of",
"the",
"all",
"density",
"operators",
".",
"Parameters",
"densops",
":",
"instance",
"of",
"DensOp",
"instance",
"of",
"DensOp",
"set",
"of",
"DensOp",
"instances",
"Returns",
"None"
] | def free_all(cls, *densops):
warnings.warn("No need to call 'free_all' method because free automatically, or you can use class method 'del_all' to free memory explicitly.") | [
"def",
"free_all",
"(",
"cls",
",",
"*",
"densops",
")",
":",
"warnings",
".",
"warn",
"(",
"\"No need to call 'free_all' method because free automatically, or you can use class method 'del_all' to free memory explicitly.\"",
")"
] | free memory of the all density operators. | [
"free",
"memory",
"of",
"the",
"all",
"density",
"operators",
"."
] | [
"\"\"\"\n free memory of the all density operators.\n\n Parameters\n ----------\n densops : instance of DensOp,instance of DensOp,...\n set of DensOp instances\n\n Returns\n -------\n None\n\n \"\"\""
] | [
{
"param": "cls",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cls",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
263e0f020ab74a6cce7bd127694cff680b90c970 | samn33/qlazy | qlazy/DensOp.py | [
"Apache-2.0"
] | Python | del_all | null | def del_all(cls, *densops):
"""
free memory of the all density operators.
Parameters
----------
densops : instance of DensOp,instance of DensOp,...
set of DensOp instances
Returns
-------
None
"""
for de in densops:
... |
free memory of the all density operators.
Parameters
----------
densops : instance of DensOp,instance of DensOp,...
set of DensOp instances
Returns
-------
None
| free memory of the all density operators.
Parameters
densops : instance of DensOp,instance of DensOp,
set of DensOp instances
Returns
None | [
"free",
"memory",
"of",
"the",
"all",
"density",
"operators",
".",
"Parameters",
"densops",
":",
"instance",
"of",
"DensOp",
"instance",
"of",
"DensOp",
"set",
"of",
"DensOp",
"instances",
"Returns",
"None"
] | def del_all(cls, *densops):
for de in densops:
if type(de) is list or type(de) is tuple:
cls.del_all(*de)
elif type(de) is DensOp:
del de
else:
raise DensOp_Error_FreeAll() | [
"def",
"del_all",
"(",
"cls",
",",
"*",
"densops",
")",
":",
"for",
"de",
"in",
"densops",
":",
"if",
"type",
"(",
"de",
")",
"is",
"list",
"or",
"type",
"(",
"de",
")",
"is",
"tuple",
":",
"cls",
".",
"del_all",
"(",
"*",
"de",
")",
"elif",
... | free memory of the all density operators. | [
"free",
"memory",
"of",
"the",
"all",
"density",
"operators",
"."
] | [
"\"\"\"\n free memory of the all density operators.\n\n Parameters\n ----------\n densops : instance of DensOp,instance of DensOp,...\n set of DensOp instances\n\n Returns\n -------\n None\n\n \"\"\""
] | [
{
"param": "cls",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cls",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
263e0f020ab74a6cce7bd127694cff680b90c970 | samn33/qlazy | qlazy/DensOp.py | [
"Apache-2.0"
] | Python | clone | <not_specific> | def clone(self):
"""
get the copy of density operator.
Parameters
----------
None
Returns
-------
densop : instance of DensOp
copy of the original density operator.
"""
# densop = densop_copy(self)
# return densop
... |
get the copy of density operator.
Parameters
----------
None
Returns
-------
densop : instance of DensOp
copy of the original density operator.
| get the copy of density operator.
Parameters
None
Returns
densop : instance of DensOp
copy of the original density operator. | [
"get",
"the",
"copy",
"of",
"density",
"operator",
".",
"Parameters",
"None",
"Returns",
"densop",
":",
"instance",
"of",
"DensOp",
"copy",
"of",
"the",
"original",
"density",
"operator",
"."
] | def clone(self):
obj = densop_copy(self)
de = ctypes.cast(obj.value, ctypes.POINTER(self.__class__)).contents
return de | [
"def",
"clone",
"(",
"self",
")",
":",
"obj",
"=",
"densop_copy",
"(",
"self",
")",
"de",
"=",
"ctypes",
".",
"cast",
"(",
"obj",
".",
"value",
",",
"ctypes",
".",
"POINTER",
"(",
"self",
".",
"__class__",
")",
")",
".",
"contents",
"return",
"de"
... | get the copy of density operator. | [
"get",
"the",
"copy",
"of",
"density",
"operator",
"."
] | [
"\"\"\"\n get the copy of density operator.\n\n Parameters\n ----------\n None\n\n Returns\n -------\n densop : instance of DensOp\n copy of the original density operator.\n\n \"\"\"",
"# densop = densop_copy(self)",
"# return densop"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
263e0f020ab74a6cce7bd127694cff680b90c970 | samn33/qlazy | qlazy/DensOp.py | [
"Apache-2.0"
] | Python | patrace | <not_specific> | def patrace(self, qid=[]):
"""
get the partial trace of density operator.
Parameters
----------
qid : list of int
qubit id's list to show.
Returns
-------
densop : instance of DensOp
density operator after partial trace.
... |
get the partial trace of density operator.
Parameters
----------
qid : list of int
qubit id's list to show.
Returns
-------
densop : instance of DensOp
density operator after partial trace.
| get the partial trace of density operator.
Parameters
qid : list of int
qubit id's list to show.
Returns
densop : instance of DensOp
density operator after partial trace. | [
"get",
"the",
"partial",
"trace",
"of",
"density",
"operator",
".",
"Parameters",
"qid",
":",
"list",
"of",
"int",
"qubit",
"id",
"'",
"s",
"list",
"to",
"show",
".",
"Returns",
"densop",
":",
"instance",
"of",
"DensOp",
"density",
"operator",
"after",
"... | def patrace(self, qid=[]):
obj = densop_patrace(self, qid=qid)
de = ctypes.cast(obj.value, ctypes.POINTER(self.__class__)).contents
return de | [
"def",
"patrace",
"(",
"self",
",",
"qid",
"=",
"[",
"]",
")",
":",
"obj",
"=",
"densop_patrace",
"(",
"self",
",",
"qid",
"=",
"qid",
")",
"de",
"=",
"ctypes",
".",
"cast",
"(",
"obj",
".",
"value",
",",
"ctypes",
".",
"POINTER",
"(",
"self",
... | get the partial trace of density operator. | [
"get",
"the",
"partial",
"trace",
"of",
"density",
"operator",
"."
] | [
"\"\"\"\n get the partial trace of density operator.\n\n Parameters\n ----------\n qid : list of int\n qubit id's list to show.\n\n Returns\n -------\n densop : instance of DensOp\n density operator after partial trace.\n\n \"\"\"",
"# ... | [
{
"param": "self",
"type": null
},
{
"param": "qid",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "qid",
"type": null,
"docstring": null,
"docstring_tokens": []... |
263e0f020ab74a6cce7bd127694cff680b90c970 | samn33/qlazy | qlazy/DensOp.py | [
"Apache-2.0"
] | Python | tenspro | <not_specific> | def tenspro(self, densop):
"""
get the tensor product with density operator.
Parameters
----------
densop : instance of DensOp
density operator to get the tensor product..
Returns
-------
densop_out : instance of DensOp
tensor pro... |
get the tensor product with density operator.
Parameters
----------
densop : instance of DensOp
density operator to get the tensor product..
Returns
-------
densop_out : instance of DensOp
tensor produt of 'self' and 'densop'.
| get the tensor product with density operator.
Parameters
densop : instance of DensOp
density operator to get the tensor product
Returns
densop_out : instance of DensOp
tensor produt of 'self' and 'densop'. | [
"get",
"the",
"tensor",
"product",
"with",
"density",
"operator",
".",
"Parameters",
"densop",
":",
"instance",
"of",
"DensOp",
"density",
"operator",
"to",
"get",
"the",
"tensor",
"product",
"Returns",
"densop_out",
":",
"instance",
"of",
"DensOp",
"tensor",
... | def tenspro(self, densop):
obj = densop_tensor_product(self, densop)
de = ctypes.cast(obj.value, ctypes.POINTER(self.__class__)).contents
return de | [
"def",
"tenspro",
"(",
"self",
",",
"densop",
")",
":",
"obj",
"=",
"densop_tensor_product",
"(",
"self",
",",
"densop",
")",
"de",
"=",
"ctypes",
".",
"cast",
"(",
"obj",
".",
"value",
",",
"ctypes",
".",
"POINTER",
"(",
"self",
".",
"__class__",
")... | get the tensor product with density operator. | [
"get",
"the",
"tensor",
"product",
"with",
"density",
"operator",
"."
] | [
"\"\"\"\n get the tensor product with density operator.\n\n Parameters\n ----------\n densop : instance of DensOp\n density operator to get the tensor product..\n\n Returns\n -------\n densop_out : instance of DensOp\n tensor produt of 'self' an... | [
{
"param": "self",
"type": null
},
{
"param": "densop",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "densop",
"type": null,
"docstring": null,
"docstring_tokens":... |
263e0f020ab74a6cce7bd127694cff680b90c970 | samn33/qlazy | qlazy/DensOp.py | [
"Apache-2.0"
] | Python | composite | <not_specific> | def composite(self, num=0):
"""
get the composite density operator of same density operators.
Parameters
----------
num : int
number of density operators..
Returns
-------
de : instance of DensOp
composite density operator.
... |
get the composite density operator of same density operators.
Parameters
----------
num : int
number of density operators..
Returns
-------
de : instance of DensOp
composite density operator.
| get the composite density operator of same density operators.
Parameters
num : int
number of density operators
Returns
de : instance of DensOp
composite density operator. | [
"get",
"the",
"composite",
"density",
"operator",
"of",
"same",
"density",
"operators",
".",
"Parameters",
"num",
":",
"int",
"number",
"of",
"density",
"operators",
"Returns",
"de",
":",
"instance",
"of",
"DensOp",
"composite",
"density",
"operator",
"."
] | def composite(self, num=0):
if num <= 1:
return self
else:
de = self.clone()
for i in range(num-1):
de_tmp = de.tenspro(self)
de = de_tmp.clone()
return de | [
"def",
"composite",
"(",
"self",
",",
"num",
"=",
"0",
")",
":",
"if",
"num",
"<=",
"1",
":",
"return",
"self",
"else",
":",
"de",
"=",
"self",
".",
"clone",
"(",
")",
"for",
"i",
"in",
"range",
"(",
"num",
"-",
"1",
")",
":",
"de_tmp",
"=",
... | get the composite density operator of same density operators. | [
"get",
"the",
"composite",
"density",
"operator",
"of",
"same",
"density",
"operators",
"."
] | [
"\"\"\"\n get the composite density operator of same density operators.\n\n Parameters\n ----------\n num : int\n number of density operators..\n\n Returns\n -------\n de : instance of DensOp\n composite density operator.\n\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "num",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "num",
"type": null,
"docstring": null,
"docstring_tokens": []... |
263e0f020ab74a6cce7bd127694cff680b90c970 | samn33/qlazy | qlazy/DensOp.py | [
"Apache-2.0"
] | Python | expect | <not_specific> | def expect(self, matrix=None):
"""
get the expectation value of matrix under this density operator.
Parameters
----------
matrix : list of list of complex
matrix expression of hermitian operator.
Returns
-------
value : float
expe... |
get the expectation value of matrix under this density operator.
Parameters
----------
matrix : list of list of complex
matrix expression of hermitian operator.
Returns
-------
value : float
expectation value.
Notes
----... | get the expectation value of matrix under this density operator.
Parameters
matrix : list of list of complex
matrix expression of hermitian operator.
Returns
value : float
expectation value.
Notes
'matrix' must be hermitian, and its dimension is equal to
the dimension of density operator. | [
"get",
"the",
"expectation",
"value",
"of",
"matrix",
"under",
"this",
"density",
"operator",
".",
"Parameters",
"matrix",
":",
"list",
"of",
"list",
"of",
"complex",
"matrix",
"expression",
"of",
"hermitian",
"operator",
".",
"Returns",
"value",
":",
"float",... | def expect(self, matrix=None):
densop = self.clone()
densop_apply_matrix(densop, matrix=matrix, dire='left')
value = densop.trace()
return value | [
"def",
"expect",
"(",
"self",
",",
"matrix",
"=",
"None",
")",
":",
"densop",
"=",
"self",
".",
"clone",
"(",
")",
"densop_apply_matrix",
"(",
"densop",
",",
"matrix",
"=",
"matrix",
",",
"dire",
"=",
"'left'",
")",
"value",
"=",
"densop",
".",
"trac... | get the expectation value of matrix under this density operator. | [
"get",
"the",
"expectation",
"value",
"of",
"matrix",
"under",
"this",
"density",
"operator",
"."
] | [
"\"\"\"\n get the expectation value of matrix under this density operator.\n\n Parameters\n ----------\n matrix : list of list of complex\n matrix expression of hermitian operator.\n\n Returns\n -------\n value : float\n expectation value.\n\n ... | [
{
"param": "self",
"type": null
},
{
"param": "matrix",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "matrix",
"type": null,
"docstring": null,
"docstring_tokens":... |
263e0f020ab74a6cce7bd127694cff680b90c970 | samn33/qlazy | qlazy/DensOp.py | [
"Apache-2.0"
] | Python | probability | <not_specific> | def probability(self, kraus=[], povm=[], qid=[]):
"""
get the probabilities for measuring operators.
(Kraus or POVM operators).
Parameters
----------
kraus : list of list of comprex
Kraus operators.
povm : list of list of comprex
POVM ope... |
get the probabilities for measuring operators.
(Kraus or POVM operators).
Parameters
----------
kraus : list of list of comprex
Kraus operators.
povm : list of list of comprex
POVM operators.
qid : list
qubit id's list to mea... | get the probabilities for measuring operators.
(Kraus or POVM operators).
Parameters
kraus : list of list of comprex
Kraus operators.
povm : list of list of comprex
POVM operators.
qid : list
qubit id's list to measure.
Returns
prob : list of float
probabilities for measuring operators.
Notes
Either 'kraus' or 'p... | [
"get",
"the",
"probabilities",
"for",
"measuring",
"operators",
".",
"(",
"Kraus",
"or",
"POVM",
"operators",
")",
".",
"Parameters",
"kraus",
":",
"list",
"of",
"list",
"of",
"comprex",
"Kraus",
"operators",
".",
"povm",
":",
"list",
"of",
"list",
"of",
... | def probability(self, kraus=[], povm=[], qid=[]):
if kraus != []:
N = len(kraus)
prob = [0.0]*N
for i in range(N):
prob[i] = densop_probability(self, matrix=kraus[i], qid=qid,
matrix_type='kraus')
... | [
"def",
"probability",
"(",
"self",
",",
"kraus",
"=",
"[",
"]",
",",
"povm",
"=",
"[",
"]",
",",
"qid",
"=",
"[",
"]",
")",
":",
"if",
"kraus",
"!=",
"[",
"]",
":",
"N",
"=",
"len",
"(",
"kraus",
")",
"prob",
"=",
"[",
"0.0",
"]",
"*",
"N... | get the probabilities for measuring operators. | [
"get",
"the",
"probabilities",
"for",
"measuring",
"operators",
"."
] | [
"\"\"\"\n get the probabilities for measuring operators. \n (Kraus or POVM operators).\n\n Parameters\n ----------\n kraus : list of list of comprex\n Kraus operators.\n povm : list of list of comprex\n POVM operators.\n qid : list\n ... | [
{
"param": "self",
"type": null
},
{
"param": "kraus",
"type": null
},
{
"param": "povm",
"type": null
},
{
"param": "qid",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "kraus",
"type": null,
"docstring": null,
"docstring_tokens": ... |
263e0f020ab74a6cce7bd127694cff680b90c970 | samn33/qlazy | qlazy/DensOp.py | [
"Apache-2.0"
] | Python | spectrum | <not_specific> | def spectrum(self):
"""
get the spectrum.
Parameters
----------
None
Returns
-------
qstate : list of QState
list of the quantum state basis.
prob : list of float
list of coefficients for each quantum states basis.
... |
get the spectrum.
Parameters
----------
None
Returns
-------
qstate : list of QState
list of the quantum state basis.
prob : list of float
list of coefficients for each quantum states basis.
| get the spectrum.
Parameters
None
Returns
qstate : list of QState
list of the quantum state basis.
prob : list of float
list of coefficients for each quantum states basis. | [
"get",
"the",
"spectrum",
".",
"Parameters",
"None",
"Returns",
"qstate",
":",
"list",
"of",
"QState",
"list",
"of",
"the",
"quantum",
"state",
"basis",
".",
"prob",
":",
"list",
"of",
"float",
"list",
"of",
"coefficients",
"for",
"each",
"quantum",
"state... | def spectrum(self):
mat = self.get_elm()
eigvals,eigvecs = self.__mat_spectrum(mat)
prob = [eigvals[i] for i in range(len(eigvals)) if abs(eigvals[i]) > EPS]
vecs = [eigvecs[i] for i in range(len(eigvals)) if abs(eigvals[i]) > EPS]
qstate = [QState(vector=vecs[i]) for i in range(... | [
"def",
"spectrum",
"(",
"self",
")",
":",
"mat",
"=",
"self",
".",
"get_elm",
"(",
")",
"eigvals",
",",
"eigvecs",
"=",
"self",
".",
"__mat_spectrum",
"(",
"mat",
")",
"prob",
"=",
"[",
"eigvals",
"[",
"i",
"]",
"for",
"i",
"in",
"range",
"(",
"l... | get the spectrum. | [
"get",
"the",
"spectrum",
"."
] | [
"\"\"\"\n get the spectrum.\n\n Parameters\n ----------\n None\n\n Returns\n -------\n qstate : list of QState\n list of the quantum state basis.\n prob : list of float\n list of coefficients for each quantum states basis.\n\n \"\"... | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
23e3635b2635dec40d3db12b0ca3139ac2f7b572 | samn33/qlazy | qlazy/QComp.py | [
"Apache-2.0"
] | Python | free_all | null | def free_all(cls, *qcomps):
"""
free memory of the all quantum computers.
Parameters
----------
qcomps : instance of QComp,instance of QComp,...
set of QComp instances
Returns
-------
None
"""
# for qc in qcomps:
# ... |
free memory of the all quantum computers.
Parameters
----------
qcomps : instance of QComp,instance of QComp,...
set of QComp instances
Returns
-------
None
| free memory of the all quantum computers.
Parameters
qcomps : instance of QComp,instance of QComp,
set of QComp instances
Returns
None | [
"free",
"memory",
"of",
"the",
"all",
"quantum",
"computers",
".",
"Parameters",
"qcomps",
":",
"instance",
"of",
"QComp",
"instance",
"of",
"QComp",
"set",
"of",
"QComp",
"instances",
"Returns",
"None"
] | def free_all(cls, *qcomps):
warnings.warn("No need to call 'free_all' method because free automatically, or you can use class method 'del_all' to free memory explicitly.") | [
"def",
"free_all",
"(",
"cls",
",",
"*",
"qcomps",
")",
":",
"warnings",
".",
"warn",
"(",
"\"No need to call 'free_all' method because free automatically, or you can use class method 'del_all' to free memory explicitly.\"",
")"
] | free memory of the all quantum computers. | [
"free",
"memory",
"of",
"the",
"all",
"quantum",
"computers",
"."
] | [
"\"\"\"\n free memory of the all quantum computers.\n\n Parameters\n ----------\n qcomps : instance of QComp,instance of QComp,...\n set of QComp instances\n\n Returns\n -------\n None\n\n \"\"\"",
"# for qc in qcomps:",
"# if type(qc) is li... | [
{
"param": "cls",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cls",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
23e3635b2635dec40d3db12b0ca3139ac2f7b572 | samn33/qlazy | qlazy/QComp.py | [
"Apache-2.0"
] | Python | del_all | null | def del_all(cls, *qcomps):
"""
free memory of the all quantum computers.
Parameters
----------
qcomps : instance of QComp,instance of QComp,...
set of QComp instances
Returns
-------
None
"""
for qc in qcomps:
if ... |
free memory of the all quantum computers.
Parameters
----------
qcomps : instance of QComp,instance of QComp,...
set of QComp instances
Returns
-------
None
| free memory of the all quantum computers.
Parameters
qcomps : instance of QComp,instance of QComp,
set of QComp instances
Returns
None | [
"free",
"memory",
"of",
"the",
"all",
"quantum",
"computers",
".",
"Parameters",
"qcomps",
":",
"instance",
"of",
"QComp",
"instance",
"of",
"QComp",
"set",
"of",
"QComp",
"instances",
"Returns",
"None"
] | def del_all(cls, *qcomps):
for qc in qcomps:
if type(qc) is list or type(qc) is tuple:
cls.del_all(*qc)
elif type(qc) is QComp:
del qc
else:
raise QComp_Error_FreeAll() | [
"def",
"del_all",
"(",
"cls",
",",
"*",
"qcomps",
")",
":",
"for",
"qc",
"in",
"qcomps",
":",
"if",
"type",
"(",
"qc",
")",
"is",
"list",
"or",
"type",
"(",
"qc",
")",
"is",
"tuple",
":",
"cls",
".",
"del_all",
"(",
"*",
"qc",
")",
"elif",
"t... | free memory of the all quantum computers. | [
"free",
"memory",
"of",
"the",
"all",
"quantum",
"computers",
"."
] | [
"\"\"\"\n free memory of the all quantum computers.\n\n Parameters\n ----------\n qcomps : instance of QComp,instance of QComp,...\n set of QComp instances\n\n Returns\n -------\n None\n\n \"\"\""
] | [
{
"param": "cls",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cls",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
99b9a36d15a4bdde9124d2407793dfa70ac5c64e | samn33/qlazy | qlazy/MData.py | [
"Apache-2.0"
] | Python | last | <not_specific> | def last(self):
""" last measured value (binary string) """
mval = self.measured_value(angle=self.angle, phase=self.phase)
digits = len(self.qid)
return '{:0{digits}b}'.format(mval, digits=digits) | last measured value (binary string) | last measured value (binary string) | [
"last",
"measured",
"value",
"(",
"binary",
"string",
")"
] | def last(self):
mval = self.measured_value(angle=self.angle, phase=self.phase)
digits = len(self.qid)
return '{:0{digits}b}'.format(mval, digits=digits) | [
"def",
"last",
"(",
"self",
")",
":",
"mval",
"=",
"self",
".",
"measured_value",
"(",
"angle",
"=",
"self",
".",
"angle",
",",
"phase",
"=",
"self",
".",
"phase",
")",
"digits",
"=",
"len",
"(",
"self",
".",
"qid",
")",
"return",
"'{:0{digits}b}'",
... | last measured value (binary string) | [
"last",
"measured",
"value",
"(",
"binary",
"string",
")"
] | [
"\"\"\" last measured value (binary string) \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
253d067fbbb99d5f78f169d1177fdd253e998cdd | risclog-solution/risclog.sqlalchemy | src/risclog/sqlalchemy/cache.py | [
"ZPL-2.1"
] | Python | save_changes | null | def save_changes(self, session=None, cursor=None):
"""
Flush modified and created object to the database before clearing the
cache.
Args:
session: A SQLAlchemy session to use instead of the default one.
"""
self.log_memory_usage()
if session is None:... |
Flush modified and created object to the database before clearing the
cache.
Args:
session: A SQLAlchemy session to use instead of the default one.
| Flush modified and created object to the database before clearing the
cache. | [
"Flush",
"modified",
"and",
"created",
"object",
"to",
"the",
"database",
"before",
"clearing",
"the",
"cache",
"."
] | def save_changes(self, session=None, cursor=None):
self.log_memory_usage()
if session is None:
session = self.session
if cursor is None and self._use_copy:
cursor = self.session.using_bind(
self._engine_name).connection().connection.cursor()
self._... | [
"def",
"save_changes",
"(",
"self",
",",
"session",
"=",
"None",
",",
"cursor",
"=",
"None",
")",
":",
"self",
".",
"log_memory_usage",
"(",
")",
"if",
"session",
"is",
"None",
":",
"session",
"=",
"self",
".",
"session",
"if",
"cursor",
"is",
"None",
... | Flush modified and created object to the database before clearing the
cache. | [
"Flush",
"modified",
"and",
"created",
"object",
"to",
"the",
"database",
"before",
"clearing",
"the",
"cache",
"."
] | [
"\"\"\"\n Flush modified and created object to the database before clearing the\n cache.\n\n Args:\n session: A SQLAlchemy session to use instead of the default one.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "session",
"type": null
},
{
"param": "cursor",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "session",
"type": null,
"docstring": "A SQLAlchemy session to use i... |
253d067fbbb99d5f78f169d1177fdd253e998cdd | risclog-solution/risclog.sqlalchemy | src/risclog/sqlalchemy/cache.py | [
"ZPL-2.1"
] | Python | _save_by_copy | <not_specific> | def _save_by_copy(self, cursor, objects):
"""
Insert objects by using PostgreSQL's COPY command. This is
database-specific but one of the most efficient ways to populate a
table. Expects instances of one single model per call.
See: https://www.postgresql.org/docs/current/sql-copy... |
Insert objects by using PostgreSQL's COPY command. This is
database-specific but one of the most efficient ways to populate a
table. Expects instances of one single model per call.
See: https://www.postgresql.org/docs/current/sql-copy.html
Args:
cursor: A Psycopg2 c... | Insert objects by using PostgreSQL's COPY command. This is
database-specific but one of the most efficient ways to populate a
table. Expects instances of one single model per call. | [
"Insert",
"objects",
"by",
"using",
"PostgreSQL",
"'",
"s",
"COPY",
"command",
".",
"This",
"is",
"database",
"-",
"specific",
"but",
"one",
"of",
"the",
"most",
"efficient",
"ways",
"to",
"populate",
"a",
"table",
".",
"Expects",
"instances",
"of",
"one",... | def _save_by_copy(self, cursor, objects):
if len(objects) == 0:
return
model = inspect(objects[0]).mapper
for table in model.tables:
file = io.StringIO()
writer = csv.DictWriter(file, table.columns.keys())
columns = [
c for c in mod... | [
"def",
"_save_by_copy",
"(",
"self",
",",
"cursor",
",",
"objects",
")",
":",
"if",
"len",
"(",
"objects",
")",
"==",
"0",
":",
"return",
"model",
"=",
"inspect",
"(",
"objects",
"[",
"0",
"]",
")",
".",
"mapper",
"for",
"table",
"in",
"model",
"."... | Insert objects by using PostgreSQL's COPY command. | [
"Insert",
"objects",
"by",
"using",
"PostgreSQL",
"'",
"s",
"COPY",
"command",
"."
] | [
"\"\"\"\n Insert objects by using PostgreSQL's COPY command. This is\n database-specific but one of the most efficient ways to populate a\n table. Expects instances of one single model per call.\n See: https://www.postgresql.org/docs/current/sql-copy.html\n\n Args:\n cu... | [
{
"param": "self",
"type": null
},
{
"param": "cursor",
"type": null
},
{
"param": "objects",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "cursor",
"type": null,
"docstring": "A Psycopg2 cursor",
"doc... |
253d067fbbb99d5f78f169d1177fdd253e998cdd | risclog-solution/risclog.sqlalchemy | src/risclog/sqlalchemy/cache.py | [
"ZPL-2.1"
] | Python | clear | null | def clear(self, session=None):
"""Clear the cache. Will result in data loss of unflushed objects."""
self._cached_instances.clear()
self._indices.clear()
gc.collect()
self.log_memory_usage() | Clear the cache. Will result in data loss of unflushed objects. | Clear the cache. Will result in data loss of unflushed objects. | [
"Clear",
"the",
"cache",
".",
"Will",
"result",
"in",
"data",
"loss",
"of",
"unflushed",
"objects",
"."
] | def clear(self, session=None):
self._cached_instances.clear()
self._indices.clear()
gc.collect()
self.log_memory_usage() | [
"def",
"clear",
"(",
"self",
",",
"session",
"=",
"None",
")",
":",
"self",
".",
"_cached_instances",
".",
"clear",
"(",
")",
"self",
".",
"_indices",
".",
"clear",
"(",
")",
"gc",
".",
"collect",
"(",
")",
"self",
".",
"log_memory_usage",
"(",
")"
] | Clear the cache. | [
"Clear",
"the",
"cache",
"."
] | [
"\"\"\"Clear the cache. Will result in data loss of unflushed objects.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "session",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "session",
"type": null,
"docstring": null,
"docstring_tokens"... |
253d067fbbb99d5f78f169d1177fdd253e998cdd | risclog-solution/risclog.sqlalchemy | src/risclog/sqlalchemy/cache.py | [
"ZPL-2.1"
] | Python | _get_model_cache | <not_specific> | def _get_model_cache(self, model):
"""
Return a list of every existing and newly created instance of `model`.
"""
model_key = self._model_key(model)
if model_key not in self._cached_instances:
# Initialize model cache if it doesn't exist yet.
if model_key... |
Return a list of every existing and newly created instance of `model`.
| Return a list of every existing and newly created instance of `model`. | [
"Return",
"a",
"list",
"of",
"every",
"existing",
"and",
"newly",
"created",
"instance",
"of",
"`",
"model",
"`",
"."
] | def _get_model_cache(self, model):
model_key = self._model_key(model)
if model_key not in self._cached_instances:
if model_key in self._preload_models_data:
query = model.query(*self._preload_models_data[model_key])
else:
query = model.query()
... | [
"def",
"_get_model_cache",
"(",
"self",
",",
"model",
")",
":",
"model_key",
"=",
"self",
".",
"_model_key",
"(",
"model",
")",
"if",
"model_key",
"not",
"in",
"self",
".",
"_cached_instances",
":",
"if",
"model_key",
"in",
"self",
".",
"_preload_models_data... | Return a list of every existing and newly created instance of `model`. | [
"Return",
"a",
"list",
"of",
"every",
"existing",
"and",
"newly",
"created",
"instance",
"of",
"`",
"model",
"`",
"."
] | [
"\"\"\"\n Return a list of every existing and newly created instance of `model`.\n \"\"\"",
"# Initialize model cache if it doesn't exist yet.",
"# XXX: We run a noop DB request here to avoid some",
"# hard-to-debug session transaction errors that crop up",
"# otherwise."
] | [
{
"param": "self",
"type": null
},
{
"param": "model",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "model",
"type": null,
"docstring": null,
"docstring_tokens": ... |
253d067fbbb99d5f78f169d1177fdd253e998cdd | risclog-solution/risclog.sqlalchemy | src/risclog/sqlalchemy/cache.py | [
"ZPL-2.1"
] | Python | _get_model_indices | <not_specific> | def _get_model_indices(self, model):
"""
Return a dictionary containing tuples of indexed attributes as keys.
"""
model_key = self._model_key(model)
if model_key not in self._indices:
self._indices[model_key] = {}
return self._indices[model_key] |
Return a dictionary containing tuples of indexed attributes as keys.
| Return a dictionary containing tuples of indexed attributes as keys. | [
"Return",
"a",
"dictionary",
"containing",
"tuples",
"of",
"indexed",
"attributes",
"as",
"keys",
"."
] | def _get_model_indices(self, model):
model_key = self._model_key(model)
if model_key not in self._indices:
self._indices[model_key] = {}
return self._indices[model_key] | [
"def",
"_get_model_indices",
"(",
"self",
",",
"model",
")",
":",
"model_key",
"=",
"self",
".",
"_model_key",
"(",
"model",
")",
"if",
"model_key",
"not",
"in",
"self",
".",
"_indices",
":",
"self",
".",
"_indices",
"[",
"model_key",
"]",
"=",
"{",
"}... | Return a dictionary containing tuples of indexed attributes as keys. | [
"Return",
"a",
"dictionary",
"containing",
"tuples",
"of",
"indexed",
"attributes",
"as",
"keys",
"."
] | [
"\"\"\"\n Return a dictionary containing tuples of indexed attributes as keys.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "model",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "model",
"type": null,
"docstring": null,
"docstring_tokens": ... |
253d067fbbb99d5f78f169d1177fdd253e998cdd | risclog-solution/risclog.sqlalchemy | src/risclog/sqlalchemy/cache.py | [
"ZPL-2.1"
] | Python | _get_attribute_index | <not_specific> | def _get_attribute_index(self, model, attributes):
"""
Return a dictionary containing model attribute values as keys and a
list of matching instances as values.
"""
model_indices = self._get_model_indices(model)
attribute_key = tuple(sorted(attributes))
if attrib... |
Return a dictionary containing model attribute values as keys and a
list of matching instances as values.
| Return a dictionary containing model attribute values as keys and a
list of matching instances as values. | [
"Return",
"a",
"dictionary",
"containing",
"model",
"attribute",
"values",
"as",
"keys",
"and",
"a",
"list",
"of",
"matching",
"instances",
"as",
"values",
"."
] | def _get_attribute_index(self, model, attributes):
model_indices = self._get_model_indices(model)
attribute_key = tuple(sorted(attributes))
if attribute_key not in model_indices:
model_cache = self._get_model_cache(model)
indexed_instances = {}
for instance in... | [
"def",
"_get_attribute_index",
"(",
"self",
",",
"model",
",",
"attributes",
")",
":",
"model_indices",
"=",
"self",
".",
"_get_model_indices",
"(",
"model",
")",
"attribute_key",
"=",
"tuple",
"(",
"sorted",
"(",
"attributes",
")",
")",
"if",
"attribute_key",... | Return a dictionary containing model attribute values as keys and a
list of matching instances as values. | [
"Return",
"a",
"dictionary",
"containing",
"model",
"attribute",
"values",
"as",
"keys",
"and",
"a",
"list",
"of",
"matching",
"instances",
"as",
"values",
"."
] | [
"\"\"\"\n Return a dictionary containing model attribute values as keys and a\n list of matching instances as values.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "model",
"type": null
},
{
"param": "attributes",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "model",
"type": null,
"docstring": null,
"docstring_tokens": ... |
253d067fbbb99d5f78f169d1177fdd253e998cdd | risclog-solution/risclog.sqlalchemy | src/risclog/sqlalchemy/cache.py | [
"ZPL-2.1"
] | Python | _model_key | <not_specific> | def _model_key(self, model):
"""
Return the key used to reference a given `model` in the instance cache
and indices.
"""
return model.__name__ |
Return the key used to reference a given `model` in the instance cache
and indices.
| Return the key used to reference a given `model` in the instance cache
and indices. | [
"Return",
"the",
"key",
"used",
"to",
"reference",
"a",
"given",
"`",
"model",
"`",
"in",
"the",
"instance",
"cache",
"and",
"indices",
"."
] | def _model_key(self, model):
return model.__name__ | [
"def",
"_model_key",
"(",
"self",
",",
"model",
")",
":",
"return",
"model",
".",
"__name__"
] | Return the key used to reference a given `model` in the instance cache
and indices. | [
"Return",
"the",
"key",
"used",
"to",
"reference",
"a",
"given",
"`",
"model",
"`",
"in",
"the",
"instance",
"cache",
"and",
"indices",
"."
] | [
"\"\"\"\n Return the key used to reference a given `model` in the instance cache\n and indices.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "model",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "model",
"type": null,
"docstring": null,
"docstring_tokens": ... |
253d067fbbb99d5f78f169d1177fdd253e998cdd | risclog-solution/risclog.sqlalchemy | src/risclog/sqlalchemy/cache.py | [
"ZPL-2.1"
] | Python | _assign_sequences | null | def _assign_sequences(self):
"""
Assign sequence values to empty model attributes specified in the
constructor.
This iterates over every cached model and its corresponding sequences
and assigns sequence values where applicable..
Empty sequence attributes are counted and ... |
Assign sequence values to empty model attributes specified in the
constructor.
This iterates over every cached model and its corresponding sequences
and assigns sequence values where applicable..
Empty sequence attributes are counted and matching sequence values are
fet... | Assign sequence values to empty model attributes specified in the
constructor.
This iterates over every cached model and its corresponding sequences
and assigns sequence values where applicable
Empty sequence attributes are counted and matching sequence values are
fetched from the database in a single request. | [
"Assign",
"sequence",
"values",
"to",
"empty",
"model",
"attributes",
"specified",
"in",
"the",
"constructor",
".",
"This",
"iterates",
"over",
"every",
"cached",
"model",
"and",
"its",
"corresponding",
"sequences",
"and",
"assigns",
"sequence",
"values",
"where",... | def _assign_sequences(self):
for model_name, objects in self._cached_instances.items():
if model_name not in self._sequences:
continue
model_sequences = self._sequences[model_name]
for sequence in model_sequences:
new_objects = list(
... | [
"def",
"_assign_sequences",
"(",
"self",
")",
":",
"for",
"model_name",
",",
"objects",
"in",
"self",
".",
"_cached_instances",
".",
"items",
"(",
")",
":",
"if",
"model_name",
"not",
"in",
"self",
".",
"_sequences",
":",
"continue",
"model_sequences",
"=",
... | Assign sequence values to empty model attributes specified in the
constructor. | [
"Assign",
"sequence",
"values",
"to",
"empty",
"model",
"attributes",
"specified",
"in",
"the",
"constructor",
"."
] | [
"\"\"\"\n Assign sequence values to empty model attributes specified in the\n constructor.\n\n This iterates over every cached model and its corresponding sequences\n and assigns sequence values where applicable..\n Empty sequence attributes are counted and matching sequence value... | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
253d067fbbb99d5f78f169d1177fdd253e998cdd | risclog-solution/risclog.sqlalchemy | src/risclog/sqlalchemy/cache.py | [
"ZPL-2.1"
] | Python | _sync_relationship_attrs | null | def _sync_relationship_attrs(self):
"""
Synchronize relationship attributes with their corresponding ID
attributes.
When using SQLAlchemy bulk functionality, the ORM behavior is changed
in multiple ways. One important change is that relationship attributes
aren't evaluat... |
Synchronize relationship attributes with their corresponding ID
attributes.
When using SQLAlchemy bulk functionality, the ORM behavior is changed
in multiple ways. One important change is that relationship attributes
aren't evaluated anymore.
To still handle related obj... | Synchronize relationship attributes with their corresponding ID
attributes.
When using SQLAlchemy bulk functionality, the ORM behavior is changed
in multiple ways. One important change is that relationship attributes
aren't evaluated anymore.
To still handle related object as expected, we iterate over
relationship att... | [
"Synchronize",
"relationship",
"attributes",
"with",
"their",
"corresponding",
"ID",
"attributes",
".",
"When",
"using",
"SQLAlchemy",
"bulk",
"functionality",
"the",
"ORM",
"behavior",
"is",
"changed",
"in",
"multiple",
"ways",
".",
"One",
"important",
"change",
... | def _sync_relationship_attrs(self):
for objects in self._cached_instances.values():
objects = self._filter_sa_result_objects(objects)
if len(objects) == 0:
continue
model = type(list(objects)[0])
rel_map = [
(rel.key, pair[1].key, p... | [
"def",
"_sync_relationship_attrs",
"(",
"self",
")",
":",
"for",
"objects",
"in",
"self",
".",
"_cached_instances",
".",
"values",
"(",
")",
":",
"objects",
"=",
"self",
".",
"_filter_sa_result_objects",
"(",
"objects",
")",
"if",
"len",
"(",
"objects",
")",... | Synchronize relationship attributes with their corresponding ID
attributes. | [
"Synchronize",
"relationship",
"attributes",
"with",
"their",
"corresponding",
"ID",
"attributes",
"."
] | [
"\"\"\"\n Synchronize relationship attributes with their corresponding ID\n attributes.\n\n When using SQLAlchemy bulk functionality, the ORM behavior is changed\n in multiple ways. One important change is that relationship attributes\n aren't evaluated anymore.\n To still ... | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
253d067fbbb99d5f78f169d1177fdd253e998cdd | risclog-solution/risclog.sqlalchemy | src/risclog/sqlalchemy/cache.py | [
"ZPL-2.1"
] | Python | _instance_change_handler | <not_specific> | def _instance_change_handler(self, instance, value, oldvalue, initiator):
"""
Re-index model instances that were changed
(to keep the index up-to-date).
Called by SQLAlchemy's model `set` event which fires when a model
attribute was changed. For more information,
see: htt... |
Re-index model instances that were changed
(to keep the index up-to-date).
Called by SQLAlchemy's model `set` event which fires when a model
attribute was changed. For more information,
see: https://docs.sqlalchemy.org/en/13/orm/events.html
| Re-index model instances that were changed
(to keep the index up-to-date).
Called by SQLAlchemy's model `set` event which fires when a model
attribute was changed. | [
"Re",
"-",
"index",
"model",
"instances",
"that",
"were",
"changed",
"(",
"to",
"keep",
"the",
"index",
"up",
"-",
"to",
"-",
"date",
")",
".",
"Called",
"by",
"SQLAlchemy",
"'",
"s",
"model",
"`",
"set",
"`",
"event",
"which",
"fires",
"when",
"a",
... | def _instance_change_handler(self, instance, value, oldvalue, initiator):
if oldvalue is sqlalchemy.util.symbol('NEVER_SET'):
return
model = type(instance)
changed_attr = initiator.key
model_indices = self._get_model_indices(model)
for attribute_key in model_indices.k... | [
"def",
"_instance_change_handler",
"(",
"self",
",",
"instance",
",",
"value",
",",
"oldvalue",
",",
"initiator",
")",
":",
"if",
"oldvalue",
"is",
"sqlalchemy",
".",
"util",
".",
"symbol",
"(",
"'NEVER_SET'",
")",
":",
"return",
"model",
"=",
"type",
"(",... | Re-index model instances that were changed
(to keep the index up-to-date). | [
"Re",
"-",
"index",
"model",
"instances",
"that",
"were",
"changed",
"(",
"to",
"keep",
"the",
"index",
"up",
"-",
"to",
"-",
"date",
")",
"."
] | [
"\"\"\"\n Re-index model instances that were changed\n (to keep the index up-to-date).\n Called by SQLAlchemy's model `set` event which fires when a model\n attribute was changed. For more information,\n see: https://docs.sqlalchemy.org/en/13/orm/events.html\n \"\"\"",
"#... | [
{
"param": "self",
"type": null
},
{
"param": "instance",
"type": null
},
{
"param": "value",
"type": null
},
{
"param": "oldvalue",
"type": null
},
{
"param": "initiator",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "instance",
"type": null,
"docstring": null,
"docstring_tokens... |
757d63caf9dea4c72b2b7a5e7d65da605641aa67 | risclog-solution/risclog.sqlalchemy | src/risclog/sqlalchemy/tests/test_fixtures.py | [
"ZPL-2.1"
] | Python | example_model | <not_specific> | def example_model(test_model_factory):
"""Create a persisted example object in the database."""
model = test_model_factory('db1')
db = risclog.sqlalchemy.db.get_database(testing=True)
db.create_all('db1')
model.persist()
transaction.commit()
return model | Create a persisted example object in the database. | Create a persisted example object in the database. | [
"Create",
"a",
"persisted",
"example",
"object",
"in",
"the",
"database",
"."
] | def example_model(test_model_factory):
model = test_model_factory('db1')
db = risclog.sqlalchemy.db.get_database(testing=True)
db.create_all('db1')
model.persist()
transaction.commit()
return model | [
"def",
"example_model",
"(",
"test_model_factory",
")",
":",
"model",
"=",
"test_model_factory",
"(",
"'db1'",
")",
"db",
"=",
"risclog",
".",
"sqlalchemy",
".",
"db",
".",
"get_database",
"(",
"testing",
"=",
"True",
")",
"db",
".",
"create_all",
"(",
"'d... | Create a persisted example object in the database. | [
"Create",
"a",
"persisted",
"example",
"object",
"in",
"the",
"database",
"."
] | [
"\"\"\"Create a persisted example object in the database.\"\"\""
] | [
{
"param": "test_model_factory",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "test_model_factory",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
604670b24889849a8548f405d7263cd739121181 | gautams3/deformable-ravens | main.py | [
"Apache-2.0"
] | Python | has_deformables | <not_specific> | def has_deformables(task):
"""
Somewhat misleading name. This method is used to determine if we should
(a) be running training AFTER environment data collection, and (b)
evaluating with test-time rollouts periodically. For (a) the reason was
the --disp option, which is needed to see cloth, will not ... |
Somewhat misleading name. This method is used to determine if we should
(a) be running training AFTER environment data collection, and (b)
evaluating with test-time rollouts periodically. For (a) the reason was
the --disp option, which is needed to see cloth, will not let us run
multiple Environmen... | Somewhat misleading name. This method is used to determine if we should
(a) be running training AFTER environment data collection, and (b)
evaluating with test-time rollouts periodically. For (a) the reason was
the --disp option, which is needed to see cloth, will not let us run
multiple Environment calls. This also ap... | [
"Somewhat",
"misleading",
"name",
".",
"This",
"method",
"is",
"used",
"to",
"determine",
"if",
"we",
"should",
"(",
"a",
")",
"be",
"running",
"training",
"AFTER",
"environment",
"data",
"collection",
"and",
"(",
"b",
")",
"evaluating",
"with",
"test",
"-... | def has_deformables(task):
return ('cable-' in task) or ('cloth' in task) or ('bag' in task) | [
"def",
"has_deformables",
"(",
"task",
")",
":",
"return",
"(",
"'cable-'",
"in",
"task",
")",
"or",
"(",
"'cloth'",
"in",
"task",
")",
"or",
"(",
"'bag'",
"in",
"task",
")"
] | Somewhat misleading name. | [
"Somewhat",
"misleading",
"name",
"."
] | [
"\"\"\"\n Somewhat misleading name. This method is used to determine if we should\n (a) be running training AFTER environment data collection, and (b)\n evaluating with test-time rollouts periodically. For (a) the reason was\n the --disp option, which is needed to see cloth, will not let us run\n mul... | [
{
"param": "task",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "task",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
604670b24889849a8548f405d7263cd739121181 | gautams3/deformable-ravens | main.py | [
"Apache-2.0"
] | Python | is_goal_conditioned | <not_specific> | def is_goal_conditioned(args):
"""
Be careful with checking this condition. See `generate_goals.py`. Here,
though, we check the task name and as an extra safety measure, check that
the agent is also named with 'goal'.
Update: all right, let's modify this to incorpoate gt_state w/out too much
ex... |
Be careful with checking this condition. See `generate_goals.py`. Here,
though, we check the task name and as an extra safety measure, check that
the agent is also named with 'goal'.
Update: all right, let's modify this to incorpoate gt_state w/out too much
extra work. :(
| Be careful with checking this condition.
all right, let's modify this to incorpoate gt_state w/out too much
extra work. | [
"Be",
"careful",
"with",
"checking",
"this",
"condition",
".",
"all",
"right",
"let",
"'",
"s",
"modify",
"this",
"to",
"incorpoate",
"gt_state",
"w",
"/",
"out",
"too",
"much",
"extra",
"work",
"."
] | def is_goal_conditioned(args):
goal_tasks = ['insertion-goal', 'cable-shape-notarget', 'cable-line-notarget',
'cloth-flat-notarget', 'bag-color-goal']
goal_task = (args.task in goal_tasks)
if goal_task:
assert 'goal' in args.agent or 'gt_state' in args.agent, \
'Agent should ... | [
"def",
"is_goal_conditioned",
"(",
"args",
")",
":",
"goal_tasks",
"=",
"[",
"'insertion-goal'",
",",
"'cable-shape-notarget'",
",",
"'cable-line-notarget'",
",",
"'cloth-flat-notarget'",
",",
"'bag-color-goal'",
"]",
"goal_task",
"=",
"(",
"args",
".",
"task",
"in"... | Be careful with checking this condition. | [
"Be",
"careful",
"with",
"checking",
"this",
"condition",
"."
] | [
"\"\"\"\n Be careful with checking this condition. See `generate_goals.py`. Here,\n though, we check the task name and as an extra safety measure, check that\n the agent is also named with 'goal'.\n\n Update: all right, let's modify this to incorpoate gt_state w/out too much\n extra work. :(\n \"\... | [
{
"param": "args",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "args",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
604670b24889849a8548f405d7263cd739121181 | gautams3/deformable-ravens | main.py | [
"Apache-2.0"
] | Python | ignore_this_demo | <not_specific> | def ignore_this_demo(args, demo_reward, t, last_extras):
"""In some cases, we should filter out demonstrations.
Filter for if t == 0, which means the initial state was a success.
Also, for the bag envs, if we end up in a catastrophic state, I exit
gracefully and we should avoid those demos (they won't ... | In some cases, we should filter out demonstrations.
Filter for if t == 0, which means the initial state was a success.
Also, for the bag envs, if we end up in a catastrophic state, I exit
gracefully and we should avoid those demos (they won't have images we
need for the dataset anyway).
| In some cases, we should filter out demonstrations.
Filter for if t == 0, which means the initial state was a success.
Also, for the bag envs, if we end up in a catastrophic state, I exit
gracefully and we should avoid those demos (they won't have images we
need for the dataset anyway). | [
"In",
"some",
"cases",
"we",
"should",
"filter",
"out",
"demonstrations",
".",
"Filter",
"for",
"if",
"t",
"==",
"0",
"which",
"means",
"the",
"initial",
"state",
"was",
"a",
"success",
".",
"Also",
"for",
"the",
"bag",
"envs",
"if",
"we",
"end",
"up",... | def ignore_this_demo(args, demo_reward, t, last_extras):
ignore = (t == 0)
if 'exit_gracefully' in last_extras:
assert last_extras['exit_gracefully']
return True
if (args.task in ['bag-color-goal']) and demo_reward <= 0.5:
return True
We can get 0.5 reward by touching the cube o... | [
"def",
"ignore_this_demo",
"(",
"args",
",",
"demo_reward",
",",
"t",
",",
"last_extras",
")",
":",
"ignore",
"=",
"(",
"t",
"==",
"0",
")",
"if",
"'exit_gracefully'",
"in",
"last_extras",
":",
"assert",
"last_extras",
"[",
"'exit_gracefully'",
"]",
"return"... | In some cases, we should filter out demonstrations. | [
"In",
"some",
"cases",
"we",
"should",
"filter",
"out",
"demonstrations",
"."
] | [
"\"\"\"In some cases, we should filter out demonstrations.\n\n Filter for if t == 0, which means the initial state was a success.\n Also, for the bag envs, if we end up in a catastrophic state, I exit\n gracefully and we should avoid those demos (they won't have images we\n need for the dataset anyway).... | [
{
"param": "args",
"type": null
},
{
"param": "demo_reward",
"type": null
},
{
"param": "t",
"type": null
},
{
"param": "last_extras",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "args",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "demo_reward",
"type": null,
"docstring": null,
"docstring_tok... |
0752d86858e00d387b22e805ee372538089ee95b | gautams3/deformable-ravens | ravens/models/mdn_utils.py | [
"Apache-2.0"
] | Python | pick_max_mean | <not_specific> | def pick_max_mean(pi, mu, var):
"""Prediction as the mean of the most-weighted gaussian.
Args are all TF:
pi: (batch_size, num_gaussians)
mu: (batch_size, num_gaussians * d_out)
var: (batch_size, num_gaussians)
Returns:
(batch_size, d_out) NUMPY
"""
mu = tf.reshape(mu, (tf.shape(mu)[0], tf.sh... | Prediction as the mean of the most-weighted gaussian.
Args are all TF:
pi: (batch_size, num_gaussians)
mu: (batch_size, num_gaussians * d_out)
var: (batch_size, num_gaussians)
Returns:
(batch_size, d_out) NUMPY
| Prediction as the mean of the most-weighted gaussian. | [
"Prediction",
"as",
"the",
"mean",
"of",
"the",
"most",
"-",
"weighted",
"gaussian",
"."
] | def pick_max_mean(pi, mu, var):
mu = tf.reshape(mu, (tf.shape(mu)[0], tf.shape(pi)[1], -1))
d_out = tf.shape(mu)[-1]
batch_size, k = pi.shape
prediction = np.zeros((batch_size, d_out))
argmax_pi = tf.argmax(pi, axis=1)
for i in range(batch_size):
ith_argmax_pi = argmax_pi[i].numpy()
prediction[i] =... | [
"def",
"pick_max_mean",
"(",
"pi",
",",
"mu",
",",
"var",
")",
":",
"mu",
"=",
"tf",
".",
"reshape",
"(",
"mu",
",",
"(",
"tf",
".",
"shape",
"(",
"mu",
")",
"[",
"0",
"]",
",",
"tf",
".",
"shape",
"(",
"pi",
")",
"[",
"1",
"]",
",",
"-",... | Prediction as the mean of the most-weighted gaussian. | [
"Prediction",
"as",
"the",
"mean",
"of",
"the",
"most",
"-",
"weighted",
"gaussian",
"."
] | [
"\"\"\"Prediction as the mean of the most-weighted gaussian.\n\n Args are all TF:\n pi: (batch_size, num_gaussians)\n mu: (batch_size, num_gaussians * d_out)\n var: (batch_size, num_gaussians)\n Returns:\n (batch_size, d_out) NUMPY\n \"\"\"",
"# shape (batch_size)"
] | [
{
"param": "pi",
"type": null
},
{
"param": "mu",
"type": null
},
{
"param": "var",
"type": null
}
] | {
"returns": [
{
"docstring": "(batch_size, d_out) NUMPY",
"docstring_tokens": [
"(",
"batch_size",
"d_out",
")",
"NUMPY"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "pi",
"type": null,
"docstring": ... |
0752d86858e00d387b22e805ee372538089ee95b | gautams3/deformable-ravens | ravens/models/mdn_utils.py | [
"Apache-2.0"
] | Python | sample_from_pdf | <not_specific> | def sample_from_pdf(pi, mu, var, num_samples=1):
"""Prediction as a sample from the gaussian mixture.
Args are all TF:
pi: (batch_size, num_gaussians)
mu: (batch_size, num_gaussians * d_out)
var: (batch_size, num_gaussians)
Returns:
(batch_size, num_samples, d_out) NUMPY
"""
pi, mu, var = pi.... | Prediction as a sample from the gaussian mixture.
Args are all TF:
pi: (batch_size, num_gaussians)
mu: (batch_size, num_gaussians * d_out)
var: (batch_size, num_gaussians)
Returns:
(batch_size, num_samples, d_out) NUMPY
| Prediction as a sample from the gaussian mixture. | [
"Prediction",
"as",
"a",
"sample",
"from",
"the",
"gaussian",
"mixture",
"."
] | def sample_from_pdf(pi, mu, var, num_samples=1):
pi, mu, var = pi.numpy(), mu.numpy(), var.numpy()
var = var**4
pi = pi * (1/pi.sum(1)[..., None])
batch_size, k = pi.shape
mu = tf.reshape(mu, (tf.shape(mu)[0], tf.shape(pi)[1], -1))
d_out = tf.shape(mu)[-1]
samples = np.zeros((batch_size, num_samples, d_ou... | [
"def",
"sample_from_pdf",
"(",
"pi",
",",
"mu",
",",
"var",
",",
"num_samples",
"=",
"1",
")",
":",
"pi",
",",
"mu",
",",
"var",
"=",
"pi",
".",
"numpy",
"(",
")",
",",
"mu",
".",
"numpy",
"(",
")",
",",
"var",
".",
"numpy",
"(",
")",
"var",
... | Prediction as a sample from the gaussian mixture. | [
"Prediction",
"as",
"a",
"sample",
"from",
"the",
"gaussian",
"mixture",
"."
] | [
"\"\"\"Prediction as a sample from the gaussian mixture.\n\n Args are all TF:\n pi: (batch_size, num_gaussians)\n mu: (batch_size, num_gaussians * d_out)\n var: (batch_size, num_gaussians)\n Returns:\n (batch_size, num_samples, d_out) NUMPY\n \"\"\"",
"# apply temperature?",
"#pi = pi**4 # apply ... | [
{
"param": "pi",
"type": null
},
{
"param": "mu",
"type": null
},
{
"param": "var",
"type": null
},
{
"param": "num_samples",
"type": null
}
] | {
"returns": [
{
"docstring": "(batch_size, num_samples, d_out) NUMPY",
"docstring_tokens": [
"(",
"batch_size",
"num_samples",
"d_out",
")",
"NUMPY"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "pi",
... |
07608c8d337a13d7b996e1fb01a58a05b7cabc92 | gautams3/deformable-ravens | ravens/agents/dummy.py | [
"Apache-2.0"
] | Python | train | null | def train(self, dataset, num_iter, writer):
"""Train on dataset for a specific number of iterations."""
for i in range(num_iter):
obs, act, info = dataset.random_sample()
# [Optional] Get heightmap from RGB-D images.
configs = act['camera_config']
colorma... | Train on dataset for a specific number of iterations. | Train on dataset for a specific number of iterations. | [
"Train",
"on",
"dataset",
"for",
"a",
"specific",
"number",
"of",
"iterations",
"."
] | def train(self, dataset, num_iter, writer):
for i in range(num_iter):
obs, act, info = dataset.random_sample()
configs = act['camera_config']
colormap, heightmap = self.get_heightmap(obs, configs)
loss = 0.
print(f'Train Iter: {self.total_iter + i} Los... | [
"def",
"train",
"(",
"self",
",",
"dataset",
",",
"num_iter",
",",
"writer",
")",
":",
"for",
"i",
"in",
"range",
"(",
"num_iter",
")",
":",
"obs",
",",
"act",
",",
"info",
"=",
"dataset",
".",
"random_sample",
"(",
")",
"configs",
"=",
"act",
"[",... | Train on dataset for a specific number of iterations. | [
"Train",
"on",
"dataset",
"for",
"a",
"specific",
"number",
"of",
"iterations",
"."
] | [
"\"\"\"Train on dataset for a specific number of iterations.\"\"\"",
"# [Optional] Get heightmap from RGB-D images.",
"# Do something here.",
"# Compute training loss here."
] | [
{
"param": "self",
"type": null
},
{
"param": "dataset",
"type": null
},
{
"param": "num_iter",
"type": null
},
{
"param": "writer",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "dataset",
"type": null,
"docstring": null,
"docstring_tokens"... |
07608c8d337a13d7b996e1fb01a58a05b7cabc92 | gautams3/deformable-ravens | ravens/agents/dummy.py | [
"Apache-2.0"
] | Python | act | <not_specific> | def act(self, obs, info):
"""Run inference and return best action given visual observations."""
act = {'camera_config': self.camera_config, 'primitive': None}
if not obs:
return act
# [Optional] Get heightmap from RGB-D images.
colormap, heightmap = self.get_heightma... | Run inference and return best action given visual observations. | Run inference and return best action given visual observations. | [
"Run",
"inference",
"and",
"return",
"best",
"action",
"given",
"visual",
"observations",
"."
] | def act(self, obs, info):
act = {'camera_config': self.camera_config, 'primitive': None}
if not obs:
return act
colormap, heightmap = self.get_heightmap(obs, self.camera_config)
p0_position = (self.bounds[:, 1] - self.bounds[:, 0]) / 2
p0_position += self.bounds[:, 0]... | [
"def",
"act",
"(",
"self",
",",
"obs",
",",
"info",
")",
":",
"act",
"=",
"{",
"'camera_config'",
":",
"self",
".",
"camera_config",
",",
"'primitive'",
":",
"None",
"}",
"if",
"not",
"obs",
":",
"return",
"act",
"colormap",
",",
"heightmap",
"=",
"s... | Run inference and return best action given visual observations. | [
"Run",
"inference",
"and",
"return",
"best",
"action",
"given",
"visual",
"observations",
"."
] | [
"\"\"\"Run inference and return best action given visual observations.\"\"\"",
"# [Optional] Get heightmap from RGB-D images.",
"# Do something here.",
"# Dummy behavior: move to the middle of the workspace.",
"# Select task-specific motion primitive."
] | [
{
"param": "self",
"type": null
},
{
"param": "obs",
"type": null
},
{
"param": "info",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "obs",
"type": null,
"docstring": null,
"docstring_tokens": []... |
14b1f05069ba5ecc9e3e5adf91df4626e21e7ab8 | gautams3/deformable-ravens | ravens/agents/transporter.py | [
"Apache-2.0"
] | Python | train | null | def train(self, dataset, num_iter, writer):
"""Train on dataset for a specific number of iterations.
Daniel: notice how little training data we use! One 'iteration' is
simply one image and an associated action, drawn by (a) sampling
demo, then (b) sampling time within it. We do heavy da... | Train on dataset for a specific number of iterations.
Daniel: notice how little training data we use! One 'iteration' is
simply one image and an associated action, drawn by (a) sampling
demo, then (b) sampling time within it. We do heavy data
augmentation, but it's still just one real i... | Train on dataset for a specific number of iterations.
Daniel: notice how little training data we use. One 'iteration' is
simply one image and an associated action, drawn by (a) sampling
demo, then (b) sampling time within it. We do heavy data
augmentation, but it's still just one real image.
If using a goal image, we ... | [
"Train",
"on",
"dataset",
"for",
"a",
"specific",
"number",
"of",
"iterations",
".",
"Daniel",
":",
"notice",
"how",
"little",
"training",
"data",
"we",
"use",
".",
"One",
"'",
"iteration",
"'",
"is",
"simply",
"one",
"image",
"and",
"an",
"associated",
... | def train(self, dataset, num_iter, writer):
for i in range(num_iter):
if self.use_goal_image:
obs, act, info, goal = dataset.random_sample(goal_images=True)
else:
obs, act, info = dataset.random_sample()
configs = act['camera_config']
... | [
"def",
"train",
"(",
"self",
",",
"dataset",
",",
"num_iter",
",",
"writer",
")",
":",
"for",
"i",
"in",
"range",
"(",
"num_iter",
")",
":",
"if",
"self",
".",
"use_goal_image",
":",
"obs",
",",
"act",
",",
"info",
",",
"goal",
"=",
"dataset",
".",... | Train on dataset for a specific number of iterations. | [
"Train",
"on",
"dataset",
"for",
"a",
"specific",
"number",
"of",
"iterations",
"."
] | [
"\"\"\"Train on dataset for a specific number of iterations.\n\n Daniel: notice how little training data we use! One 'iteration' is\n simply one image and an associated action, drawn by (a) sampling\n demo, then (b) sampling time within it. We do heavy data\n augmentation, but it's still... | [
{
"param": "self",
"type": null
},
{
"param": "dataset",
"type": null
},
{
"param": "num_iter",
"type": null
},
{
"param": "writer",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "dataset",
"type": null,
"docstring": null,
"docstring_tokens"... |
14b1f05069ba5ecc9e3e5adf91df4626e21e7ab8 | gautams3/deformable-ravens | ravens/agents/transporter.py | [
"Apache-2.0"
] | Python | act | <not_specific> | def act(self, obs, info, debug_imgs=False, goal=None):
"""Run inference and return best action given visual observations.
If goal-conditioning, provide `goal`. Both `obs` and `goal` have
'color' and 'depth' keys, but `obs['color']` and `goal['color']` are
of type list and np.array, resp... | Run inference and return best action given visual observations.
If goal-conditioning, provide `goal`. Both `obs` and `goal` have
'color' and 'depth' keys, but `obs['color']` and `goal['color']` are
of type list and np.array, respectively. This is different from
training, above, where bo... | Run inference and return best action given visual observations.
If goal-conditioning, provide `goal`.
| [
"Run",
"inference",
"and",
"return",
"best",
"action",
"given",
"visual",
"observations",
".",
"If",
"goal",
"-",
"conditioning",
"provide",
"`",
"goal",
"`",
"."
] | def act(self, obs, info, debug_imgs=False, goal=None):
act = {'camera_config': self.camera_config, 'primitive': None}
if not obs:
return act
colormap, heightmap = self.get_heightmap(obs, self.camera_config)
if goal is not None:
colormap_g, heightmap_g = self.get_h... | [
"def",
"act",
"(",
"self",
",",
"obs",
",",
"info",
",",
"debug_imgs",
"=",
"False",
",",
"goal",
"=",
"None",
")",
":",
"act",
"=",
"{",
"'camera_config'",
":",
"self",
".",
"camera_config",
",",
"'primitive'",
":",
"None",
"}",
"if",
"not",
"obs",
... | Run inference and return best action given visual observations. | [
"Run",
"inference",
"and",
"return",
"best",
"action",
"given",
"visual",
"observations",
"."
] | [
"\"\"\"Run inference and return best action given visual observations.\n\n If goal-conditioning, provide `goal`. Both `obs` and `goal` have\n 'color' and 'depth' keys, but `obs['color']` and `goal['color']` are\n of type list and np.array, respectively. This is different from\n training,... | [
{
"param": "self",
"type": null
},
{
"param": "obs",
"type": null
},
{
"param": "info",
"type": null
},
{
"param": "debug_imgs",
"type": null
},
{
"param": "goal",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "obs",
"type": null,
"docstring": null,
"docstring_tokens": []... |
14b1f05069ba5ecc9e3e5adf91df4626e21e7ab8 | gautams3/deformable-ravens | ravens/agents/transporter.py | [
"Apache-2.0"
] | Python | concatenate_c_h | <not_specific> | def concatenate_c_h(self, colormap, heightmap):
"""Concatenates color and height images to get a 6D image."""
img = np.concatenate((colormap,
heightmap[..., None],
heightmap[..., None],
heightmap[..., None]), axis=... | Concatenates color and height images to get a 6D image. | Concatenates color and height images to get a 6D image. | [
"Concatenates",
"color",
"and",
"height",
"images",
"to",
"get",
"a",
"6D",
"image",
"."
] | def concatenate_c_h(self, colormap, heightmap):
img = np.concatenate((colormap,
heightmap[..., None],
heightmap[..., None],
heightmap[..., None]), axis=2)
assert img.shape == self.input_shape, img.shape
ret... | [
"def",
"concatenate_c_h",
"(",
"self",
",",
"colormap",
",",
"heightmap",
")",
":",
"img",
"=",
"np",
".",
"concatenate",
"(",
"(",
"colormap",
",",
"heightmap",
"[",
"...",
",",
"None",
"]",
",",
"heightmap",
"[",
"...",
",",
"None",
"]",
",",
"heig... | Concatenates color and height images to get a 6D image. | [
"Concatenates",
"color",
"and",
"height",
"images",
"to",
"get",
"a",
"6D",
"image",
"."
] | [
"\"\"\"Concatenates color and height images to get a 6D image.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "colormap",
"type": null
},
{
"param": "heightmap",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "colormap",
"type": null,
"docstring": null,
"docstring_tokens... |
14b1f05069ba5ecc9e3e5adf91df4626e21e7ab8 | gautams3/deformable-ravens | ravens/agents/transporter.py | [
"Apache-2.0"
] | Python | load | null | def load(self, num_iter):
"""Load pre-trained models."""
attention_fname = 'attention-ckpt-%d.h5' % num_iter
transport_fname = 'transport-ckpt-%d.h5' % num_iter
attention_fname = os.path.join(self.models_dir, attention_fname)
transport_fname = os.path.join(self.models_dir, transp... | Load pre-trained models. | Load pre-trained models. | [
"Load",
"pre",
"-",
"trained",
"models",
"."
] | def load(self, num_iter):
attention_fname = 'attention-ckpt-%d.h5' % num_iter
transport_fname = 'transport-ckpt-%d.h5' % num_iter
attention_fname = os.path.join(self.models_dir, attention_fname)
transport_fname = os.path.join(self.models_dir, transport_fname)
self.attention_model... | [
"def",
"load",
"(",
"self",
",",
"num_iter",
")",
":",
"attention_fname",
"=",
"'attention-ckpt-%d.h5'",
"%",
"num_iter",
"transport_fname",
"=",
"'transport-ckpt-%d.h5'",
"%",
"num_iter",
"attention_fname",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",... | Load pre-trained models. | [
"Load",
"pre",
"-",
"trained",
"models",
"."
] | [
"\"\"\"Load pre-trained models.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "num_iter",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "num_iter",
"type": null,
"docstring": null,
"docstring_tokens... |
14b1f05069ba5ecc9e3e5adf91df4626e21e7ab8 | gautams3/deformable-ravens | ravens/agents/transporter.py | [
"Apache-2.0"
] | Python | _determine_task_stage | null | def _determine_task_stage(self, p0_pixel, p1_pixel):
"""Determines task stage for the bag-items tasks.
Hacky solution, unfortunately, assumes we assigned task.env. Assumes that we
have an actual `self.real_task` we can use; `self.task` is just a string.
Currently working reasonably well... | Determines task stage for the bag-items tasks.
Hacky solution, unfortunately, assumes we assigned task.env. Assumes that we
have an actual `self.real_task` we can use; `self.task` is just a string.
Currently working reasonably well for bag-items-easy. Note: see gt_state.py
for the versi... | Determines task stage for the bag-items tasks.
Hacky solution, unfortunately, assumes we assigned task.env. Assumes that we
have an actual `self.real_task` we can use; `self.task` is just a string.
Currently working reasonably well for bag-items-easy. Note: see gt_state.py
for the version that works for the gt_state ba... | [
"Determines",
"task",
"stage",
"for",
"the",
"bag",
"-",
"items",
"tasks",
".",
"Hacky",
"solution",
"unfortunately",
"assumes",
"we",
"assigned",
"task",
".",
"env",
".",
"Assumes",
"that",
"we",
"have",
"an",
"actual",
"`",
"self",
".",
"real_task",
"`",... | def _determine_task_stage(self, p0_pixel, p1_pixel):
real_task = self.real_task
colormap, heightmap, object_mask = real_task.get_object_masks(real_task.env)
if False:
nb = len([x for x in os.listdir('.') if '.png' in x])
mask = np.array(object_mask / np.max(object_mask)... | [
"def",
"_determine_task_stage",
"(",
"self",
",",
"p0_pixel",
",",
"p1_pixel",
")",
":",
"real_task",
"=",
"self",
".",
"real_task",
"colormap",
",",
"heightmap",
",",
"object_mask",
"=",
"real_task",
".",
"get_object_masks",
"(",
"real_task",
".",
"env",
")",... | Determines task stage for the bag-items tasks. | [
"Determines",
"task",
"stage",
"for",
"the",
"bag",
"-",
"items",
"tasks",
"."
] | [
"\"\"\"Determines task stage for the bag-items tasks.\n\n Hacky solution, unfortunately, assumes we assigned task.env. Assumes that we\n have an actual `self.real_task` we can use; `self.task` is just a string.\n Currently working reasonably well for bag-items-easy. Note: see gt_state.py\n ... | [
{
"param": "self",
"type": null
},
{
"param": "p0_pixel",
"type": null
},
{
"param": "p1_pixel",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "p0_pixel",
"type": null,
"docstring": null,
"docstring_tokens... |
14b1f05069ba5ecc9e3e5adf91df4626e21e7ab8 | gautams3/deformable-ravens | ravens/agents/transporter.py | [
"Apache-2.0"
] | Python | visualize_images | null | def visualize_images(self, p0, p0_theta, p1, p1_theta, original_pixels,
colormap, heightmap, colormap_g, heightmap_g, input_image, before_aug):
"""Daniel: code to debug and visualuze the image (including perturbed).
The height maps will not be grayscale because of matplotlib's color
... | Daniel: code to debug and visualuze the image (including perturbed).
The height maps will not be grayscale because of matplotlib's color
scheme, I think. Using cv2.imwrite(..., heightmap) shows grayscale.
| code to debug and visualuze the image (including perturbed).
The height maps will not be grayscale because of matplotlib's color
scheme, I think. Using cv2.imwrite(..., heightmap) shows grayscale. | [
"code",
"to",
"debug",
"and",
"visualuze",
"the",
"image",
"(",
"including",
"perturbed",
")",
".",
"The",
"height",
"maps",
"will",
"not",
"be",
"grayscale",
"because",
"of",
"matplotlib",
"'",
"s",
"color",
"scheme",
"I",
"think",
".",
"Using",
"cv2",
... | def visualize_images(self, p0, p0_theta, p1, p1_theta, original_pixels,
colormap, heightmap, colormap_g, heightmap_g, input_image, before_aug):
print(f'\nForward pass.')
p0_theta_d = (180 / np.pi) * p0_theta
p1_theta_d = (180 / np.pi) * p1_theta
heightmap = heightmap / np.max... | [
"def",
"visualize_images",
"(",
"self",
",",
"p0",
",",
"p0_theta",
",",
"p1",
",",
"p1_theta",
",",
"original_pixels",
",",
"colormap",
",",
"heightmap",
",",
"colormap_g",
",",
"heightmap_g",
",",
"input_image",
",",
"before_aug",
")",
":",
"print",
"(",
... | Daniel: code to debug and visualuze the image (including perturbed). | [
"Daniel",
":",
"code",
"to",
"debug",
"and",
"visualuze",
"the",
"image",
"(",
"including",
"perturbed",
")",
"."
] | [
"\"\"\"Daniel: code to debug and visualuze the image (including perturbed).\n\n The height maps will not be grayscale because of matplotlib's color\n scheme, I think. Using cv2.imwrite(..., heightmap) shows grayscale.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "p0",
"type": null
},
{
"param": "p0_theta",
"type": null
},
{
"param": "p1",
"type": null
},
{
"param": "p1_theta",
"type": null
},
{
"param": "original_pixels",
"type": null
},
{
"param": "col... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "p0",
"type": null,
"docstring": null,
"docstring_tokens": [],... |
e95d96f37e0a174275de0ec99199ba75598d2c27 | gautams3/deformable-ravens | ravens/agents/gt_state_2_step.py | [
"Apache-2.0"
] | Python | init_model | null | def init_model(self, dataset):
"""Initialize models, including normalization parameters."""
self.set_max_obs_vector_length(dataset)
if self.goal_conditioned:
_, _, info, goal = dataset.random_sample(goal_images=True)
obs_vector = self.info_to_gt_obs(info, goal=goal)
... | Initialize models, including normalization parameters. | Initialize models, including normalization parameters. | [
"Initialize",
"models",
"including",
"normalization",
"parameters",
"."
] | def init_model(self, dataset):
self.set_max_obs_vector_length(dataset)
if self.goal_conditioned:
_, _, info, goal = dataset.random_sample(goal_images=True)
obs_vector = self.info_to_gt_obs(info, goal=goal)
else:
_, _, info = dataset.random_sample()
... | [
"def",
"init_model",
"(",
"self",
",",
"dataset",
")",
":",
"self",
".",
"set_max_obs_vector_length",
"(",
"dataset",
")",
"if",
"self",
".",
"goal_conditioned",
":",
"_",
",",
"_",
",",
"info",
",",
"goal",
"=",
"dataset",
".",
"random_sample",
"(",
"go... | Initialize models, including normalization parameters. | [
"Initialize",
"models",
"including",
"normalization",
"parameters",
"."
] | [
"\"\"\"Initialize models, including normalization parameters.\"\"\"",
"# Setup pick model, which only has act_dim=3 unlike act_dim=6 for gt_state.",
"# Sample points from the data to get reasonable mean / std values.",
"# Setup pick-conditioned place model, which adds `act_dim` to `obs_dim`.",
"# Sample poi... | [
{
"param": "self",
"type": null
},
{
"param": "dataset",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "dataset",
"type": null,
"docstring": null,
"docstring_tokens"... |
e95d96f37e0a174275de0ec99199ba75598d2c27 | gautams3/deformable-ravens | ravens/agents/gt_state_2_step.py | [
"Apache-2.0"
] | Python | train | <not_specific> | def train(self, dataset, num_iter, writer, validation_dataset=None):
"""Train on dataset for a specific number of iterations.
As with the gt_state, need a special case to handle the num_iter=0 case.
"""
if self.pick_model is None:
self.init_model(dataset)
if self.US... | Train on dataset for a specific number of iterations.
As with the gt_state, need a special case to handle the num_iter=0 case.
| Train on dataset for a specific number of iterations.
As with the gt_state, need a special case to handle the num_iter=0 case. | [
"Train",
"on",
"dataset",
"for",
"a",
"specific",
"number",
"of",
"iterations",
".",
"As",
"with",
"the",
"gt_state",
"need",
"a",
"special",
"case",
"to",
"handle",
"the",
"num_iter",
"=",
"0",
"case",
"."
] | def train(self, dataset, num_iter, writer, validation_dataset=None):
if self.pick_model is None:
self.init_model(dataset)
if self.USE_MDN:
loss_criterion = mdn_utils.mdn_loss
else:
loss_criterion = tf.keras.losses.MeanSquaredError()
@tf.function
... | [
"def",
"train",
"(",
"self",
",",
"dataset",
",",
"num_iter",
",",
"writer",
",",
"validation_dataset",
"=",
"None",
")",
":",
"if",
"self",
".",
"pick_model",
"is",
"None",
":",
"self",
".",
"init_model",
"(",
"dataset",
")",
"if",
"self",
".",
"USE_M... | Train on dataset for a specific number of iterations. | [
"Train",
"on",
"dataset",
"for",
"a",
"specific",
"number",
"of",
"iterations",
"."
] | [
"\"\"\"Train on dataset for a specific number of iterations.\n\n As with the gt_state, need a special case to handle the num_iter=0 case.\n \"\"\"",
"#batch_obs = tf.concat((batch_obs, batch_act[:,0:3] + tf.random.normal(shape=batch_act[:,0:3].shape, stddev=0.001)), axis=1)",
"# Need this case due... | [
{
"param": "self",
"type": null
},
{
"param": "dataset",
"type": null
},
{
"param": "num_iter",
"type": null
},
{
"param": "writer",
"type": null
},
{
"param": "validation_dataset",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "dataset",
"type": null,
"docstring": null,
"docstring_tokens"... |
e95d96f37e0a174275de0ec99199ba75598d2c27 | gautams3/deformable-ravens | ravens/agents/gt_state_2_step.py | [
"Apache-2.0"
] | Python | act | <not_specific> | def act(self, obs, info, goal=None):
"""Run inference and return best action."""
act = {'camera_config': self.camera_config, 'primitive': None}
# Get observations and run pick prediction
if self.goal_conditioned:
gt_obs = self.info_to_gt_obs(info, goal=goal)
else:
... | Run inference and return best action. | Run inference and return best action. | [
"Run",
"inference",
"and",
"return",
"best",
"action",
"."
] | def act(self, obs, info, goal=None):
act = {'camera_config': self.camera_config, 'primitive': None}
if self.goal_conditioned:
gt_obs = self.info_to_gt_obs(info, goal=goal)
else:
gt_obs = self.info_to_gt_obs(info)
pick_prediction = self.pick_model(gt_obs[None, ...]... | [
"def",
"act",
"(",
"self",
",",
"obs",
",",
"info",
",",
"goal",
"=",
"None",
")",
":",
"act",
"=",
"{",
"'camera_config'",
":",
"self",
".",
"camera_config",
",",
"'primitive'",
":",
"None",
"}",
"if",
"self",
".",
"goal_conditioned",
":",
"gt_obs",
... | Run inference and return best action. | [
"Run",
"inference",
"and",
"return",
"best",
"action",
"."
] | [
"\"\"\"Run inference and return best action.\"\"\"",
"# Get observations and run pick prediction",
"#prediction = mdn_utils.pick_max_mean(pi, mu, var)",
"# unbatch",
"# Get observations and run place prediction",
"# since the pick at train time is always 0.0,",
"# the predictions are unstable if not exa... | [
{
"param": "self",
"type": null
},
{
"param": "obs",
"type": null
},
{
"param": "info",
"type": null
},
{
"param": "goal",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "obs",
"type": null,
"docstring": null,
"docstring_tokens": []... |
e95d96f37e0a174275de0ec99199ba75598d2c27 | gautams3/deformable-ravens | ravens/agents/gt_state_2_step.py | [
"Apache-2.0"
] | Python | load | null | def load(self, num_iter):
"""Load in a similar fashion as the 1-step GT agent."""
pick_fname = 'gt-state-2-step-pick-ckpt-%d' % num_iter
place_fname = 'gt-state-2-step-place-ckpt-%d' % num_iter
pick_fname = os.path.join(self.models_dir, pick_fname)
place_fname = os.path.join(se... | Load in a similar fashion as the 1-step GT agent. | Load in a similar fashion as the 1-step GT agent. | [
"Load",
"in",
"a",
"similar",
"fashion",
"as",
"the",
"1",
"-",
"step",
"GT",
"agent",
"."
] | def load(self, num_iter):
pick_fname = 'gt-state-2-step-pick-ckpt-%d' % num_iter
place_fname = 'gt-state-2-step-place-ckpt-%d' % num_iter
pick_fname = os.path.join(self.models_dir, pick_fname)
place_fname = os.path.join(self.models_dir, place_fname)
self.pick_model = keras.mod... | [
"def",
"load",
"(",
"self",
",",
"num_iter",
")",
":",
"pick_fname",
"=",
"'gt-state-2-step-pick-ckpt-%d'",
"%",
"num_iter",
"place_fname",
"=",
"'gt-state-2-step-place-ckpt-%d'",
"%",
"num_iter",
"pick_fname",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
"... | Load in a similar fashion as the 1-step GT agent. | [
"Load",
"in",
"a",
"similar",
"fashion",
"as",
"the",
"1",
"-",
"step",
"GT",
"agent",
"."
] | [
"\"\"\"Load in a similar fashion as the 1-step GT agent.\"\"\"",
"# Load other data we need for proper usage of the model.",
"# Note: we cannot call self.model methods directly, other than __call__.",
"# Actually, I'm not even sure if this works, but we don't normalize",
"# with the current model. TODO(dani... | [
{
"param": "self",
"type": null
},
{
"param": "num_iter",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "num_iter",
"type": null,
"docstring": null,
"docstring_tokens... |
c6101d2eb1a64ef4135425c08be8a40d69b0f0f9 | gautams3/deformable-ravens | ravens/models/conv_mlp.py | [
"Apache-2.0"
] | Python | compute_spatial_soft_argmax | <not_specific> | def compute_spatial_soft_argmax(self, x):
"""
Parameter-less, extract coordinates for each channel.
~H = size related to original image H size
~W = size related to original image W size
C channels
Args:
x, shape: (batch_size, ~H, ~W, C)
Returns:
... |
Parameter-less, extract coordinates for each channel.
~H = size related to original image H size
~W = size related to original image W size
C channels
Args:
x, shape: (batch_size, ~H, ~W, C)
Returns:
shape: (batch_size, C, 2)
| Parameter-less, extract coordinates for each channel.
~H = size related to original image H size
~W = size related to original image W size
C channels | [
"Parameter",
"-",
"less",
"extract",
"coordinates",
"for",
"each",
"channel",
".",
"~H",
"=",
"size",
"related",
"to",
"original",
"image",
"H",
"size",
"~W",
"=",
"size",
"related",
"to",
"original",
"image",
"W",
"size",
"C",
"channels"
] | def compute_spatial_soft_argmax(self, x):
H, W, C = 149, 69, 16
B = self.batch_size
x = tf.reshape(tf.transpose(x, [0, 3, 1, 2]), [B * C, H * W])
softmax = tf.nn.softmax(x)
softmax = tf.transpose(tf.reshape(softmax, [B, C, H, W]), [0, 2, 3, 1])
posx, posy = tf.meshgrid(tf... | [
"def",
"compute_spatial_soft_argmax",
"(",
"self",
",",
"x",
")",
":",
"H",
",",
"W",
",",
"C",
"=",
"149",
",",
"69",
",",
"16",
"B",
"=",
"self",
".",
"batch_size",
"x",
"=",
"tf",
".",
"reshape",
"(",
"tf",
".",
"transpose",
"(",
"x",
",",
"... | Parameter-less, extract coordinates for each channel. | [
"Parameter",
"-",
"less",
"extract",
"coordinates",
"for",
"each",
"channel",
"."
] | [
"\"\"\"\n Parameter-less, extract coordinates for each channel.\n\n ~H = size related to original image H size\n ~W = size related to original image W size\n C channels\n\n Args:\n x, shape: (batch_size, ~H, ~W, C)\n Returns:\n shape: (batch_size, C, 2)\n ... | [
{
"param": "self",
"type": null
},
{
"param": "x",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": "shape"
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null... |
54ed53a152bf6d731694b67bd55877398c5b56fc | gautams3/deformable-ravens | plot_combo.py | [
"Apache-2.0"
] | Python | _get_episode_results | <not_specific> | def _get_episode_results(args, data, name_task, pkl_file):
"""Given the pickle file which has results (`data`) determine what to plot.
We could use total_rewards but better to use `task.done`, because total_rewards
shows the overall sum of delta rewards, but for convex hull tasks, that is not
interpret... | Given the pickle file which has results (`data`) determine what to plot.
We could use total_rewards but better to use `task.done`, because total_rewards
shows the overall sum of delta rewards, but for convex hull tasks, that is not
interpretable, for cloth and bag-items tasks, we'd rather use coverage or o... | Given the pickle file which has results (`data`) determine what to plot.
We could use total_rewards but better to use `task.done`, because total_rewards
shows the overall sum of delta rewards, but for convex hull tasks, that is not
interpretable, for cloth and bag-items tasks, we'd rather use coverage or our
defined su... | [
"Given",
"the",
"pickle",
"file",
"which",
"has",
"results",
"(",
"`",
"data",
"`",
")",
"determine",
"what",
"to",
"plot",
".",
"We",
"could",
"use",
"total_rewards",
"but",
"better",
"to",
"use",
"`",
"task",
".",
"done",
"`",
"because",
"total_rewards... | def _get_episode_results(args, data, name_task, pkl_file):
total_rewards = []
lengths = []
dones = []
iters = []
metrics = []
for item in data:
assert len(item) == 3, len(item)
itr, episode_list, last_info = item
if len(episode_list) == 0:
print(f'Note, zero l... | [
"def",
"_get_episode_results",
"(",
"args",
",",
"data",
",",
"name_task",
",",
"pkl_file",
")",
":",
"total_rewards",
"=",
"[",
"]",
"lengths",
"=",
"[",
"]",
"dones",
"=",
"[",
"]",
"iters",
"=",
"[",
"]",
"metrics",
"=",
"[",
"]",
"for",
"item",
... | Given the pickle file which has results (`data`) determine what to plot. | [
"Given",
"the",
"pickle",
"file",
"which",
"has",
"results",
"(",
"`",
"data",
"`",
")",
"determine",
"what",
"to",
"plot",
"."
] | [
"\"\"\"Given the pickle file which has results (`data`) determine what to plot.\n\n We could use total_rewards but better to use `task.done`, because total_rewards\n shows the overall sum of delta rewards, but for convex hull tasks, that is not\n interpretable, for cloth and bag-items tasks, we'd rather us... | [
{
"param": "args",
"type": null
},
{
"param": "data",
"type": null
},
{
"param": "name_task",
"type": null
},
{
"param": "pkl_file",
"type": null
}
] | {
"returns": [
{
"docstring": "Values to report for plotting. The xs is just a scalar representing the\niteration, which should be the same for all stuff in this `data` file.\nThe ys must be whatever we designate for showing results, whether it is\nsuccess rate, coverage, percentage of beads in zone, etc. T... |
54ed53a152bf6d731694b67bd55877398c5b56fc | gautams3/deformable-ravens | plot_combo.py | [
"Apache-2.0"
] | Python | plot_single | null | def plot_single(args, goal_conditioned, name_task, name_plot):
"""Plot only one thing, similar to the table method.
Let's not plot transporter-goal-snaive.
"""
IGNORE = ['-transporter-goal-naive']
# Override any parameters here.
title_size = 40
x_size = 38
y_size = 38
tick_size = 3... | Plot only one thing, similar to the table method.
Let's not plot transporter-goal-snaive.
| Plot only one thing, similar to the table method.
Let's not plot transporter-goal-snaive. | [
"Plot",
"only",
"one",
"thing",
"similar",
"to",
"the",
"table",
"method",
".",
"Let",
"'",
"s",
"not",
"plot",
"transporter",
"-",
"goal",
"-",
"snaive",
"."
] | def plot_single(args, goal_conditioned, name_task, name_plot):
IGNORE = ['-transporter-goal-naive']
title_size = 40
x_size = 38
y_size = 38
tick_size = 35
legend_size = 25
lw = 5
ms = 12
nrows, ncols = 1, 4
fig, ax = plt.subplots(nrows, ncols, squeeze=True, figsize=(8.0*ncols, 9.... | [
"def",
"plot_single",
"(",
"args",
",",
"goal_conditioned",
",",
"name_task",
",",
"name_plot",
")",
":",
"IGNORE",
"=",
"[",
"'-transporter-goal-naive'",
"]",
"title_size",
"=",
"40",
"x_size",
"=",
"38",
"y_size",
"=",
"38",
"tick_size",
"=",
"35",
"legend... | Plot only one thing, similar to the table method. | [
"Plot",
"only",
"one",
"thing",
"similar",
"to",
"the",
"table",
"method",
"."
] | [
"\"\"\"Plot only one thing, similar to the table method.\n\n Let's not plot transporter-goal-snaive.\n \"\"\"",
"# Override any parameters here.",
"# Now make the plot.",
"# Extract all relevant subdirectories, and get results.",
"# For each agent, plot. Iterate through keys of stats_combo[agent] IN O... | [
{
"param": "args",
"type": null
},
{
"param": "goal_conditioned",
"type": null
},
{
"param": "name_task",
"type": null
},
{
"param": "name_plot",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "args",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "goal_conditioned",
"type": null,
"docstring": null,
"docstrin... |
54ed53a152bf6d731694b67bd55877398c5b56fc | gautams3/deformable-ravens | plot_combo.py | [
"Apache-2.0"
] | Python | print_table | <not_specific> | def print_table(args):
"""Use this for the broad overview table in the paper, showing convergence results.
Careful: we use some braces, so could be tricky to integrate with string formatting?
Remember that for line breaks we need an escape character for \, so \\.
NOTE: Put this between \toprule and \bo... | Use this for the broad overview table in the paper, showing convergence results.
Careful: we use some braces, so could be tricky to integrate with string formatting?
Remember that for line breaks we need an escape character for \, so \\.
NOTE: Put this between \toprule and \bottomrule commands in LaTeX for... | Use this for the broad overview table in the paper, showing convergence results.
Careful: we use some braces, so could be tricky to integrate with string formatting.
Remember that for line breaks we need an escape character for \, so \\.
NOTE: Put this between \toprule and \bottomrule commands in LaTeX for tables. | [
"Use",
"this",
"for",
"the",
"broad",
"overview",
"table",
"in",
"the",
"paper",
"showing",
"convergence",
"results",
".",
"Careful",
":",
"we",
"use",
"some",
"braces",
"so",
"could",
"be",
"tricky",
"to",
"integrate",
"with",
"string",
"formatting",
".",
... | def print_table(args):
s = ''
tasks_l = ['cable-ring', 'cable-ring-notarget', 'cable-shape', 'cloth-cover',
'cloth-flat', 'bag-alone-open', 'bag-items-easy', 'bag-items-hard',
'cable-line-notarget', 'cable-shape-notarget', 'cloth-flat-notarget', 'bag-color-goal',]
T = []
fo... | [
"def",
"print_table",
"(",
"args",
")",
":",
"s",
"=",
"''",
"tasks_l",
"=",
"[",
"'cable-ring'",
",",
"'cable-ring-notarget'",
",",
"'cable-shape'",
",",
"'cloth-cover'",
",",
"'cloth-flat'",
",",
"'bag-alone-open'",
",",
"'bag-items-easy'",
",",
"'bag-items-hard... | Use this for the broad overview table in the paper, showing convergence results. | [
"Use",
"this",
"for",
"the",
"broad",
"overview",
"table",
"in",
"the",
"paper",
"showing",
"convergence",
"results",
"."
] | [
"\"\"\"Use this for the broad overview table in the paper, showing convergence results.\n\n Careful: we use some braces, so could be tricky to integrate with string formatting?\n Remember that for line breaks we need an escape character for \\, so \\\\.\n NOTE: Put this between \\toprule and \\bottomrule c... | [
{
"param": "args",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "args",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
54ed53a152bf6d731694b67bd55877398c5b56fc | gautams3/deformable-ravens | plot_combo.py | [
"Apache-2.0"
] | Python | print_single | <not_specific> | def print_single(args, goal_conditioned, name_task, name_plot):
"""Use this for printing a SINGLE item, for single inspection.
name_task: what we used in code. name_plot: what we want to show in the plot.
For now, take the max over the iterations (easy to spot check w/curves).
Actually we have two case... | Use this for printing a SINGLE item, for single inspection.
name_task: what we used in code. name_plot: what we want to show in the plot.
For now, take the max over the iterations (easy to spot check w/curves).
Actually we have two cases to watch out for (goal conditioned or not)...
For the table, I'm... | Use this for printing a SINGLE item, for single inspection.
name_task: what we used in code. name_plot: what we want to show in the plot.
For now, take the max over the iterations (easy to spot check w/curves).
Actually we have two cases to watch out for (goal conditioned or not)
For the table, I'm going to add a few ... | [
"Use",
"this",
"for",
"printing",
"a",
"SINGLE",
"item",
"for",
"single",
"inspection",
".",
"name_task",
":",
"what",
"we",
"used",
"in",
"code",
".",
"name_plot",
":",
"what",
"we",
"want",
"to",
"show",
"in",
"the",
"plot",
".",
"For",
"now",
"take"... | def print_single(args, goal_conditioned, name_task, name_plot):
def get_max(stats_combo, ag_key):
stat_max = -1
for key in sorted(stats_combo[ag_key].keys()):
stat_max = max(stat_max, np.mean(stats_combo[ag_key][key]))
stat_max *= 100
return stat_max
a1, a2, a3, a4,... | [
"def",
"print_single",
"(",
"args",
",",
"goal_conditioned",
",",
"name_task",
",",
"name_plot",
")",
":",
"def",
"get_max",
"(",
"stats_combo",
",",
"ag_key",
")",
":",
"stat_max",
"=",
"-",
"1",
"for",
"key",
"in",
"sorted",
"(",
"stats_combo",
"[",
"a... | Use this for printing a SINGLE item, for single inspection. | [
"Use",
"this",
"for",
"printing",
"a",
"SINGLE",
"item",
"for",
"single",
"inspection",
"."
] | [
"\"\"\"Use this for printing a SINGLE item, for single inspection.\n\n name_task: what we used in code. name_plot: what we want to show in the plot.\n For now, take the max over the iterations (easy to spot check w/curves).\n Actually we have two cases to watch out for (goal conditioned or not)...\n\n F... | [
{
"param": "args",
"type": null
},
{
"param": "goal_conditioned",
"type": null
},
{
"param": "name_task",
"type": null
},
{
"param": "name_plot",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "args",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "goal_conditioned",
"type": null,
"docstring": null,
"docstrin... |
6c74ee643589a48ea028e071c8ab35c1aa0e063a | gautams3/deformable-ravens | ravens/gripper.py | [
"Apache-2.0"
] | Python | activate | null | def activate(self, possible_objects, def_IDs):
"""
Simulates suction by creating rigid fixed constraint between suction
gripper and contacted object.
:def_IDs: a list of IDs of deformable objects.
"""
if not self.activated:
# Only report contact points involv... |
Simulates suction by creating rigid fixed constraint between suction
gripper and contacted object.
:def_IDs: a list of IDs of deformable objects.
| Simulates suction by creating rigid fixed constraint between suction
gripper and contacted object. | [
"Simulates",
"suction",
"by",
"creating",
"rigid",
"fixed",
"constraint",
"between",
"suction",
"gripper",
"and",
"contacted",
"object",
"."
] | def activate(self, possible_objects, def_IDs):
if not self.activated:
points = p.getContactPoints(bodyA=self.body, linkIndexA=0)
if len(points) > 0:
for point in points:
object_id, contact_link = point[2], point[4]
if object_id in possi... | [
"def",
"activate",
"(",
"self",
",",
"possible_objects",
",",
"def_IDs",
")",
":",
"if",
"not",
"self",
".",
"activated",
":",
"points",
"=",
"p",
".",
"getContactPoints",
"(",
"bodyA",
"=",
"self",
".",
"body",
",",
"linkIndexA",
"=",
"0",
")",
"if",
... | Simulates suction by creating rigid fixed constraint between suction
gripper and contacted object. | [
"Simulates",
"suction",
"by",
"creating",
"rigid",
"fixed",
"constraint",
"between",
"suction",
"gripper",
"and",
"contacted",
"object",
"."
] | [
"\"\"\"\n Simulates suction by creating rigid fixed constraint between suction\n gripper and contacted object.\n\n :def_IDs: a list of IDs of deformable objects.\n \"\"\"",
"# Only report contact points involving linkIndexA of bodyA (the",
"# suction) -- returns a list (actually, a t... | [
{
"param": "self",
"type": null
},
{
"param": "possible_objects",
"type": null
},
{
"param": "def_IDs",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "possible_objects",
"type": null,
"docstring": null,
"docstrin... |
6c74ee643589a48ea028e071c8ab35c1aa0e063a | gautams3/deformable-ravens | ravens/gripper.py | [
"Apache-2.0"
] | Python | activate_def | <not_specific> | def activate_def(self, defId):
"""Simulates suction by anchoring vertices of the deformable object.
Get distance values in `distances`, get indices for argsort, then
resulting indices in `distances_sort` correspond _exactly_ to vertex
indices arranged from nearest to furthest to the gri... | Simulates suction by anchoring vertices of the deformable object.
Get distance values in `distances`, get indices for argsort, then
resulting indices in `distances_sort` correspond _exactly_ to vertex
indices arranged from nearest to furthest to the gripper.
| Simulates suction by anchoring vertices of the deformable object.
Get distance values in `distances`, get indices for argsort, then
resulting indices in `distances_sort` correspond _exactly_ to vertex
indices arranged from nearest to furthest to the gripper. | [
"Simulates",
"suction",
"by",
"anchoring",
"vertices",
"of",
"the",
"deformable",
"object",
".",
"Get",
"distance",
"values",
"in",
"`",
"distances",
"`",
"get",
"indices",
"for",
"argsort",
"then",
"resulting",
"indices",
"in",
"`",
"distances_sort",
"`",
"co... | def activate_def(self, defId):
_, vert_pos_l = p.getMeshData(defId, -1, flags=p.MESH_DATA_SIMULATION_MESH)
gripper_position = np.float32(p.getLinkState(self.body, 0)[0])
distances = []
for v_position in vert_pos_l:
d = gripper_position - np.float32(v_position)
dis... | [
"def",
"activate_def",
"(",
"self",
",",
"defId",
")",
":",
"_",
",",
"vert_pos_l",
"=",
"p",
".",
"getMeshData",
"(",
"defId",
",",
"-",
"1",
",",
"flags",
"=",
"p",
".",
"MESH_DATA_SIMULATION_MESH",
")",
"gripper_position",
"=",
"np",
".",
"float32",
... | Simulates suction by anchoring vertices of the deformable object. | [
"Simulates",
"suction",
"by",
"anchoring",
"vertices",
"of",
"the",
"deformable",
"object",
"."
] | [
"\"\"\"Simulates suction by anchoring vertices of the deformable object.\n\n Get distance values in `distances`, get indices for argsort, then\n resulting indices in `distances_sort` correspond _exactly_ to vertex\n indices arranged from nearest to furthest to the gripper.\n \"\"\"",
"... | [
{
"param": "self",
"type": null
},
{
"param": "defId",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "defId",
"type": null,
"docstring": null,
"docstring_tokens": ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.