Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Determine if symlinks can be used with jinja templates #2028

Open
parthea opened this issue May 7, 2024 · 0 comments
Open

Determine if symlinks can be used with jinja templates #2028

parthea opened this issue May 7, 2024 · 0 comments
Assignees
Labels
type: cleanup An internal cleanup or hygiene concern.

Comments

@parthea
Copy link
Contributor

parthea commented May 7, 2024

In PR #1999 , I attempted to use a symlink in jinja templates but encountered an error message jinja2.exceptions.TemplateNotFound: %namespace/%name/%version/%sub/services/%service/_shared_macros.j2

We should investigate if symlinks can be used. See #1999 (comment)

nox > Running session showcase_unit_alternative_templates-3.11
nox > Creating virtual environment (virtualenv) using python3.11 in .nox/showcase_unit_alternative_templates-3-11
nox > ----------------------------------------------------------------------
nox > Note: Showcase must be running for these tests to work.
nox > See https://github.com/googleapis/gapic-showcase
nox > ----------------------------------------------------------------------
nox > python -m pip install -e .
nox > python -m pip install grpcio-tools
nox > curl https://github.com/googleapis/gapic-showcase/releases/download/v0.35.0/gapic-showcase-0.35.0.desc -L --output /tmp/tmpcs2u3puq/showcase.desc
nox > curl https://github.com/googleapis/gapic-showcase/releases/download/v0.35.0/showcase_v1beta1.yaml -L --output /tmp/tmpcs2u3puq/showcase_v1beta1.yaml
nox > curl https://github.com/googleapis/gapic-showcase/releases/download/v0.35.0/showcase_grpc_service_config.json -L --output /tmp/tmpcs2u3puq/showcase_grpc_service_config.json
nox > python -m grpc_tools.protoc --experimental_allow_proto3_optional --descriptor_set_in=/tmp/tmpcs2u3puq/showcase.desc --python_gapic_opt=old-naming,python-gapic-templates=/home/runner/work/gapic-generator-python/gapic-generator-python/gapic/ads-templates,transport=grpc+rest,service-yaml=/tmp/tmpcs2u3puq/showcase_v1beta1.yaml,retry-config=/tmp/tmpcs2u3puq/showcase_grpc_service_config.json --python_gapic_out=/tmp/tmpcs2u3puq google/showcase/v1beta1/echo.proto google/showcase/v1beta1/identity.proto google/showcase/v1beta1/messaging.proto
Traceback (most recent call last):
  File "/home/runner/work/gapic-generator-python/gapic-generator-python/.nox/showcase_unit_alternative_templates-3-11/bin/protoc-gen-python_gapic", line 33, in <module>
    sys.exit(load_entry_point('gapic-generator', 'console_scripts', 'protoc-gen-python_gapic')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/gapic-generator-python/gapic-generator-python/.nox/showcase_unit_alternative_templates-3-11/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/gapic-generator-python/gapic-generator-python/.nox/showcase_unit_alternative_templates-3-11/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/home/runner/work/gapic-generator-python/gapic-generator-python/.nox/showcase_unit_alternative_templates-3-11/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/gapic-generator-python/gapic-generator-python/.nox/showcase_unit_alternative_templates-3-11/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/gapic-generator-python/gapic-generator-python/gapic/cli/generate.py", line 64, in generate
    res = generator.Generator(opts).get_response(api_schema, opts)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/gapic-generator-python/gapic-generator-python/gapic/generator/generator.py", line 122, in get_response
    self._render_template(
  File "/home/runner/work/gapic-generator-python/gapic-generator-python/gapic/generator/generator.py", line 304, in _render_template
    self._get_file(
  File "/home/runner/work/gapic-generator-python/gapic-generator-python/gapic/generator/generator.py", line 341, in _get_file
    self._env.get_template(template_name).render(
  File "/home/runner/work/gapic-generator-python/gapic-generator-python/.nox/showcase_unit_alternative_templates-3-11/lib/python3.11/site-packages/jinja2/environment.py", line 1304, in render
    self.environment.handle_exception()
  File "/home/runner/work/gapic-generator-python/gapic-generator-python/.nox/showcase_unit_alternative_templates-3-11/lib/python3.11/site-packages/jinja2/environment.py", line 939, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "/home/runner/work/gapic-generator-python/gapic-generator-python/gapic/ads-templates/%namespace/%name/%version/%sub/services/%service/client.py.j2", line 1, in top-level template code
    {% extends '_base.py.j2' %}
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/gapic-generator-python/gapic-generator-python/gapic/ads-templates/_base.py.j2", line 5, in top-level template code
    {% block content %}
    ^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/gapic-generator-python/gapic-generator-python/gapic/ads-templates/%namespace/%name/%version/%sub/services/%service/client.py.j2", line 4, in block 'content'
    {% import "%namespace/%name/%version/%sub/services/%service/_shared_macros.j2" as shared_macros %}
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/gapic-generator-python/gapic-generator-python/.nox/showcase_unit_alternative_templates-3-11/lib/python3.11/site-packages/jinja2/loaders.py", line 207, in get_source
    raise TemplateNotFound(template)
jinja2.exceptions.TemplateNotFound: %namespace/%name/%version/%sub/services/%service/_shared_macros.j2
--python_gapic_out: protoc-gen-python_gapic: Plugin failed with status code 1.
nox > Command python -m grpc_tools.protoc --experimental_allow_proto3_optional --descriptor_set_in=/tmp/tmpcs2u3puq/showcase.desc --python_gapic_opt=old-naming,python-gapic-templates=/home/runner/work/gapic-generator-python/gapic-generator-python/gapic/ads-templates,transport=grpc+rest,service-yaml=/tmp/tmpcs2u3puq/showcase_v1beta1.yaml,retry-config=/tmp/tmpcs2u3puq/showcase_grpc_service_config.json --python_gapic_out=/tmp/tmpcs2u3puq google/showcase/v1beta1/echo.proto google/showcase/v1beta1/identity.proto google/showcase/v1beta1/messaging.proto failed with exit code 1
nox > Session showcase_unit_alternative_templates-3.11 failed.

https://github.com/googleapis/gapic-generator-python/actions/runs/8991765698/job/24700074783

@parthea parthea added the type: cleanup An internal cleanup or hygiene concern. label May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: cleanup An internal cleanup or hygiene concern.
Projects
None yet
Development

No branches or pull requests

1 participant